-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from boostcampwm-2024/Feature/FE/#137_workspaโฆ
โฆce์_๋กํฐ์ ๋๋ฉ์ด์ _์ ์ฉ Feature/#137 workspace์ ๋กํฐ์ ๋๋ฉ์ด์ ์ ์ฉ
- Loading branch information
Showing
10 changed files
with
192 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Player } from "@lottiefiles/react-lottie-player"; | ||
import errorAlert from "@assets/lotties/errorAlert.json"; | ||
|
||
export const ErrorAlert = ({ size = 200 }) => { | ||
return ( | ||
<div style={{ width: size, height: size }}> | ||
<Player autoplay loop src={errorAlert} style={{ width: "100%", height: "100%" }} /> | ||
</div> | ||
); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { css } from "@styled-system/css"; | ||
|
||
export const errorModalWrapper = css({ | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
padding: "40px", | ||
}); | ||
|
||
export const errorMessageItem = css({ | ||
color: "red", | ||
fontSize: "sm", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ErrorAlert } from "@components/lotties/ErrorAlert"; | ||
import { errorMessageItem, errorModalWrapper } from "./ErrorModal.style"; | ||
import { Modal } from "./modal"; | ||
|
||
interface ErrorScreenProps { | ||
errorMessage: string; | ||
} | ||
|
||
export const ErrorModal = ({ errorMessage }: ErrorScreenProps) => { | ||
return ( | ||
<Modal | ||
isOpen | ||
primaryButtonLabel="์๋ก๊ณ ์นจ" | ||
primaryButtonOnClick={() => { | ||
window.location.reload(); | ||
}} | ||
> | ||
<div className={errorModalWrapper}> | ||
<ErrorAlert size={200} /> | ||
์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. | ||
<br /> | ||
<p className={errorMessageItem}>{errorMessage}</p> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
// <div className={overlay}> | ||
// <div className={`${glassContainer({ border: "lg" })} ${modalWrapper}`}> | ||
// <div className={animationContainer}> | ||
// <Player autoplay loop src={errorAlert} style={{ width: "100%", height: "100%" }} /> | ||
// </div> | ||
|
||
// <div className={content}> | ||
// <h2 className={title}>์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.</h2> | ||
// <p className={message}>{errorMessage}</p> | ||
// <TextButton onClick={() => window.location.reload()} variant="primary"> | ||
// ์๋ก๊ณ ์นจ | ||
// </TextButton> | ||
// </div> | ||
// </div> | ||
// </div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import { css } from "@styled-system/css"; | ||
|
||
export const container = css({ | ||
display: "flex", | ||
}); | ||
import { css, cva } from "@styled-system/css"; | ||
|
||
export const content = css({ | ||
position: "relative", | ||
padding: "md", | ||
}); | ||
|
||
export const workSpaceContainer = cva({ | ||
base: { | ||
display: "flex", | ||
transition: "opacity 0.3s ease-in-out", | ||
}, | ||
variants: { | ||
visibility: { | ||
visible: { | ||
visibility: "visible", | ||
}, | ||
hidden: { | ||
visibility: "hidden", | ||
}, | ||
}, | ||
opacity: { | ||
1: { | ||
opacity: 1, | ||
}, | ||
0: { | ||
opacity: 0, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
import { BottomNavigator } from "@components/bottomNavigator/BottomNavigator"; | ||
import { ErrorModal } from "@components/modal/ErrorModal"; | ||
import { Sidebar } from "@components/sidebar/Sidebar"; | ||
import { Page } from "@features/page/Page"; | ||
import { container, content } from "./WorkSpace.style"; | ||
import { workSpaceContainer, content } from "./WorkSpace.style"; | ||
import { IntroScreen } from "./components/IntroScreen"; | ||
import { usePagesManage } from "./hooks/usePagesManage"; | ||
import { useWorkspaceInit } from "./hooks/useWorkspaceInit"; | ||
|
||
export const WorkSpace = () => { | ||
const { isLoading, isInitialized, error } = useWorkspaceInit(); | ||
|
||
const { pages, addPage, selectPage, closePage, updatePageTitle } = usePagesManage(); | ||
const visiblePages = pages.filter((a) => a.isVisible); | ||
const visiblePages = pages.filter((page) => page.isVisible); | ||
|
||
if (error) { | ||
return <ErrorModal errorMessage="test" />; | ||
} | ||
|
||
return ( | ||
<div className={container}> | ||
<Sidebar pages={pages} handlePageAdd={addPage} handlePageSelect={selectPage} /> | ||
<div className={content}> | ||
{visiblePages.map((page) => ( | ||
<Page | ||
key={page.id} | ||
{...page} | ||
handlePageSelect={selectPage} | ||
handlePageClose={closePage} | ||
handleTitleChange={updatePageTitle} | ||
/> | ||
))} | ||
<> | ||
{isLoading && <IntroScreen />} | ||
<div | ||
className={workSpaceContainer({ | ||
visibility: isInitialized && !isLoading ? "visible" : "hidden", | ||
opacity: isInitialized && !isLoading ? 1 : 0, | ||
})} | ||
> | ||
<Sidebar pages={pages} handlePageAdd={addPage} handlePageSelect={selectPage} /> | ||
<div className={content}> | ||
{visiblePages.map((page) => ( | ||
<Page | ||
key={page.id} | ||
{...page} | ||
handlePageSelect={selectPage} | ||
handlePageClose={closePage} | ||
handleTitleChange={updatePageTitle} | ||
/> | ||
))} | ||
</div> | ||
<BottomNavigator pages={visiblePages} handlePageSelect={selectPage} /> | ||
</div> | ||
<BottomNavigator pages={visiblePages} handlePageSelect={selectPage} /> | ||
</div> | ||
</> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
client/src/features/workSpace/components/IntroScreen.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { css } from "@styled-system/css"; | ||
|
||
export const IntroScreenContainer = css({ | ||
display: "flex", | ||
zIndex: 50, | ||
position: "fixed", | ||
inset: 0, | ||
justifyContent: "center", | ||
alignItems: "center", | ||
backgroundImage: "linear-gradient(135deg, gray, green)", | ||
backgroundSize: "cover", | ||
transition: "opacity 0.5s ease-in-out", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { LoadingSpinner } from "@components/lotties/LoadingSpinner"; | ||
import { IntroScreenContainer } from "./IntroScreen.style"; | ||
|
||
export const IntroScreen = () => { | ||
return ( | ||
<div className={IntroScreenContainer}> | ||
<LoadingSpinner size={200} /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
interface UseWorkspaceInitReturn { | ||
isLoading: boolean; | ||
isInitialized: boolean; | ||
error: Error | null; | ||
} | ||
|
||
export const useWorkspaceInit = (): UseWorkspaceInitReturn => { | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [isInitialized, setIsInitialized] = useState(false); | ||
const [error, setError] = useState<Error | null>(null); | ||
|
||
useEffect(() => { | ||
const initializeWorkspace = async () => { | ||
try { | ||
// TODO: ํ์ํ ์ด๊ธฐ ๋ฐ์ดํฐ ๋ก๋ | ||
// ์์: | ||
// await Promise.all([ | ||
// fetchUserSettings(), | ||
// fetchInitialPages(), | ||
// fetchWorkspaceData(), | ||
// ]); | ||
|
||
// ๊ฐ๋ฐ ์ค์๋ ์์๋ก ๋๋ ์ด๋ฅผ ์ค์ ์คํ๋์ ํ๋ฉด ํ์ธ | ||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
|
||
setIsInitialized(true); | ||
} catch (err) { | ||
setError(err instanceof Error ? err : new Error("Failed to initialize workspace")); | ||
} finally { | ||
// ํ์ด๋ ์์ ํจ๊ณผ๋ฅผ ์ํ ์ฝ๊ฐ์ ๋๋ ์ด | ||
setTimeout(() => { | ||
setIsLoading(false); | ||
}, 500); | ||
} | ||
}; | ||
|
||
initializeWorkspace(); | ||
}, []); | ||
|
||
return { isLoading, isInitialized, error }; | ||
}; |