refactor: change SPA to MPA

This commit is contained in:
Tristan Yang
2022-09-21 08:35:48 +08:00
parent c1868fed57
commit 953095e5ce
8 changed files with 234 additions and 16 deletions
+15
View File
@@ -0,0 +1,15 @@
import ReactDOM from "react-dom/client";
import { Reset } from "styled-reset";
import Embed from "./embed/index";
import "./assets/base.css";
import MarkdownStyleOverride from "./common/component/MarkdownStyleOverride";
const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
root.render(
<>
<Reset />
<Embed />
<MarkdownStyleOverride />
</>
);
+13
View File
@@ -0,0 +1,13 @@
import React from "react";
import styled from "styled-components";
const Styled = styled.section`
width: 800px;
height: 800px;
`;
type Props = {};
const Chat = (props: Props) => {
return <Styled>Chat</Styled>;
};
export default Chat;
+22
View File
@@ -0,0 +1,22 @@
import { useState } from "react";
import styled from "styled-components";
const Styled = styled.aside`
pointer-events: all;
`;
import Chat from "./Chat";
type Props = {};
function Embed({}: Props) {
const [visible, setVisible] = useState(false);
const toggleVisible = () => {
setVisible((prev) => !prev);
};
return (
<Styled>
<button onClick={toggleVisible}>{visible ? "close" : "open"}</button>
{visible && <Chat />}
</Styled>
);
}
export default Embed;