Skip to content

Commit

Permalink
refator: sd
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogtiti committed Jul 22, 2024
1 parent e468fec commit 9d55adb
Show file tree
Hide file tree
Showing 12 changed files with 579 additions and 441 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ dev

*.key
*.key.pub

masks.json
69 changes: 40 additions & 29 deletions app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Sd = dynamic(async () => (await import("./sd")).Sd, {
loading: () => <Loading noLogo />,
});

const SdPanel = dynamic(async () => (await import("./sd-panel")).SdPanel, {
const SdPanel = dynamic(async () => (await import("./sd")).SdPanel, {
loading: () => <Loading noLogo />,
});

Expand Down Expand Up @@ -130,48 +130,59 @@ const loadAsyncGoogleFont = () => {
document.head.appendChild(linkEl);
};

export function WindowContent(props: { children: React.ReactNode }) {
return (
<div className={styles["window-content"]} id={SlotID.AppBody}>
{props?.children}
</div>
);
}

function Screen() {
const config = useAppConfig();
const location = useLocation();
const isHome =
location.pathname === Path.Home || location.pathname === Path.SdPanel;
const isHome = location.pathname === Path.Home;
const isAuth = location.pathname === Path.Auth;
const isSd = location.pathname === Path.Sd;
const isSdPanel = location.pathname === Path.SdPanel;

const isMobileScreen = useMobileScreen();
const shouldTightBorder =
getClientConfig()?.isApp || (config.tightBorder && !isMobileScreen);

useEffect(() => {
loadAsyncGoogleFont();
}, []);

const renderContent = () => {
if (isAuth) return <AuthPage />;
if (isSd) return <Sd />;
if (isSdPanel) return <SdPanel />;
return (
<>
<SideBar className={isHome ? styles["sidebar-show"] : ""} />
<WindowContent>
<Routes>
<Route path={Path.Home} element={<Chat />} />
<Route path={Path.NewChat} element={<NewChat />} />
<Route path={Path.Masks} element={<MaskPage />} />
<Route path={Path.Chat} element={<Chat />} />
<Route path={Path.Sd} element={<Sd />} />
<Route path={Path.SdPanel} element={<Sd />} />
<Route path={Path.Settings} element={<Settings />} />
</Routes>
</WindowContent>
</>
);
};

return (
<div
className={
styles.container +
` ${shouldTightBorder ? styles["tight-container"] : styles.container} ${
getLang() === "ar" ? styles["rtl-screen"] : ""
}`
}
className={`${styles.container} ${
shouldTightBorder ? styles["tight-container"] : styles.container
} ${getLang() === "ar" ? styles["rtl-screen"] : ""}`}
>
{isAuth ? (
<>
<AuthPage />
</>
) : (
<>
<SideBar className={isHome ? styles["sidebar-show"] : ""} />
<div className={styles["window-content"]} id={SlotID.AppBody}>
<Routes>
<Route path={Path.Home} element={<Chat />} />
<Route path={Path.NewChat} element={<NewChat />} />
<Route path={Path.Masks} element={<MaskPage />} />
<Route path={Path.Chat} element={<Chat />} />
<Route path={Path.Sd} element={<Sd />} />
<Route path={Path.SdPanel} element={<Sd />} />
<Route path={Path.Settings} element={<Settings />} />
</Routes>
</div>
</>
)}
{renderContent()}
</div>
);
}
Expand Down
278 changes: 0 additions & 278 deletions app/components/sd.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions app/components/sd/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./sd";
export * from "./sd-panel";
Loading

0 comments on commit 9d55adb

Please sign in to comment.