Skip to content

Commit

Permalink
(refactor, feat): titlebar merges with appbar and sidebar, edit profi…
Browse files Browse the repository at this point in the history
…le ux tweaked, remove avatar, organisation of components into more files
  • Loading branch information
Aktindo committed Apr 18, 2024
1 parent 5e3d6ee commit 0984625
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 159 deletions.
24 changes: 10 additions & 14 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ import { GamesStore } from "./stores/GamesStore";
import { ipcRenderer } from "electron";
import {
Button,
Image,
Modal,
ModalHeader,
ModalBody,
ModalFooter,
ModalContent,
Progress,
} from "@nextui-org/react";
import launcherIcon from "./assets/images/ICON_GrayScale.png";
import exportedRoutes from "./routes";
import { SelectLauncherImage } from "./components/images/selectlauncher.component";
import { toast } from "react-toastify";
import { FiCheckCircle, FiUserCheck } from "react-icons/fi";
import { UserStore } from "./stores/UserStore";
import { FiUserCheck } from "react-icons/fi";
import { observer } from "mobx-react";
import { ThemeStore } from "./stores/ThemeStore";
//#endregion
Expand All @@ -35,10 +31,6 @@ const AppComp: React.FC = () => {
const [verificationModalVisible, setVerificationModalVisible] =
React.useState(false);

const closeHandler = () => {
setUpdateModalVisible(false);
};

//#region Routes
const page = useRoutes(exportedRoutes);

Expand Down Expand Up @@ -93,6 +85,7 @@ const AppComp: React.FC = () => {
isDismissable={false}
onClose={() => setUpdateModalVisible(false)}
isOpen={updateModalVisible}
// isOpen={true}
hideCloseButton
>
<ModalContent>
Expand All @@ -108,17 +101,20 @@ const AppComp: React.FC = () => {
</ModalHeader>
<ModalBody className="mt-2 whitespace-pre-wrap">
<p>{updateMessage}</p>
<div>
<Progress isIndeterminate size="sm" />
</div>
{!updateDownloaded && (
<div>
<Progress size="sm" />
</div>
)}
</ModalBody>
{updateDownloaded && (
<ModalFooter>
<Button
color="success"
color="primary"
variant="shadow"
onPress={() => ipcRenderer.send("restart_app")}
>
Restart
Restart Now
</Button>
</ModalFooter>
)}
Expand Down
1 change: 1 addition & 0 deletions client/src/assets/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
--toastify-color-success: #17c964;
--toastify-color-warning: #f5a524;
--toastify-color-error: #f31260;
--animate-delay: 0.5s;
}

.Toastify__toast {
Expand Down
44 changes: 44 additions & 0 deletions client/src/components/appbar/appbar-end.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Button, Tooltip } from "@nextui-org/react";
import React, { FC } from "react";
import { HiCog } from "react-icons/hi";
import { Link } from "react-router-dom";
import UserDropdown from "../dropdowns/user/userdropdown.component";
import { User } from "@/stores/UserStore";

interface IProps {
dashboard: boolean;
user: User;
cookies: any;
}

/**
* @author
* @function @AppbarEnd
**/

export const AppbarEnd: FC<IProps> = ({ dashboard, user, cookies }) => {
return (
<div className="ml-auto">
{dashboard && (
<div className="flex items-center">
<Tooltip content="Settings" placement="bottom">
<Link to="/settings">
<Button className="bg-content2 mr-2" size="md" isIconOnly>
<HiCog size="25" className="w-auto" />
</Button>
</Link>
</Tooltip>
<UserDropdown
user={{
username: user?.username || "",
verified: user?.verified || false,
accessToken: cookies.accessToken || "",
moderator: user?.moderator,
pfp: user?.pfp,
}}
/>
</div>
)}
</div>
);
};
56 changes: 56 additions & 0 deletions client/src/components/appbar/appbar-start.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { SidebarStore } from "@/stores/SidebarStore";
import { Button, Tooltip } from "@nextui-org/react";
import React, { FC } from "react";
import { FiArrowLeft, FiMenu } from "react-icons/fi";
import { Link } from "react-router-dom";
import { SearchInput } from "../search/search-input.component";
import { observer } from "mobx-react";

interface IProps {
isSettings: boolean;
pageName: string;
searchBarVisible: boolean;
}

/**
* @author
* @function @AppbarStart
**/

const AppbarStartComp: FC<IProps> = ({
isSettings,
pageName,
searchBarVisible,
}) => {
const { open } = SidebarStore;

return (
<nav className="flex items-center text-base mr-auto">
{isSettings ? (
<Link to="/store">
<Button className="mr-5" startContent={<FiArrowLeft size={20} />}>
Back
</Button>
</Link>
) : (
<Tooltip
placement="bottom"
content={open ? "Close Sidebar" : "Open Sidebar"}
>
<Button
onPress={() => SidebarStore.setOpen(!open)}
className="mr-5"
isIconOnly
color={open ? "primary" : "default"}
>
{<FiMenu size={24} />}
</Button>
</Tooltip>
)}
<p className="font-heading text-2xl uppercase mr-10">{pageName}</p>
{searchBarVisible && <SearchInput searchType="game" />}
</nav>
);
};

export const AppbarStart = observer(AppbarStartComp);
102 changes: 22 additions & 80 deletions client/src/components/appbar/appbar.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UserDropdown from "../dropdowns/user/userdropdown.component";
import { getTokensCookie } from "@/utils/storage";
import { User } from "@/stores/UserStore";
import { User, UserStore } from "@/stores/UserStore";
import { Badge, Button, Input, Tooltip } from "@nextui-org/react";
import { HiCog } from "react-icons/hi";
import { Link } from "react-router-dom";
Expand All @@ -11,6 +11,10 @@ import { SearchStore } from "@/stores/SearchStore";
import { HiBellAlert } from "react-icons/hi2";
import { sendVerificationLink } from "@/handlers/api";
import { useState } from "react";
import { SearchInput } from "../search/search-input.component";
import { VerificationBanner } from "./verification-banner.component";
import { AppbarStart } from "./appbar-start.component";
import { AppbarEnd } from "./appbar-end.component";

export interface AppBarProps {
user?: User;
Expand All @@ -35,87 +39,25 @@ export const AppBar: React.FC<AppBarProps> = ({
return (
<>
{user && !user?.verified && (
<div className="bg-warning items-center flex p-2 bg-opacity-10 mb-5 rounded-lg text-warning">
<HiBellAlert size={20} />{" "}
<span className="ml-2 font-medium">
Some features are disabled. Please verify your e-mail to secure
your account.
</span>
<Button
onPress={() =>
sendVerificationLink(user?.tokens.accessToken || "", setLoading)
}
className="ml-auto"
color="warning"
isLoading={loading}
>
Resend Verification Link
</Button>
</div>
<VerificationBanner
loading={loading}
setLoading={setLoading}
user={user}
/>
)}
<header className="w-full flex items-center py-2 pt-0">
<nav className="flex items-center text-base mr-auto">
{settings ? (
<Link to="/store">
<Button className="mr-5" startContent={<FiArrowLeft size={20} />}>
Back
</Button>
</Link>
) : (
<Tooltip
placement="bottom"
content={SidebarStore.open ? "Close Sidebar" : "Open Sidebar"}
>
<Button
onPress={() => SidebarStore.setOpen(!SidebarStore.open)}
className="mr-5"
isIconOnly
color={SidebarStore.open ? "primary" : "default"}
>
{<FiMenu size={24} />}
</Button>
</Tooltip>
)}
<p className="font-heading text-2xl uppercase mr-10">{pageName}</p>
{searchBarVisible && (
<Input
onChange={(e) => {
SearchStore.setSearch({
type: searchType || "game",
query: e.target.value,
});
}}
className="mr-5"
placeholder="Search..."
value={
(SearchStore.search.type == searchType || "game") &&
SearchStore.search.query
}
/>
)}
</nav>
<div className="ml-auto">
{dashboard && (
<div className="flex items-center">
<Tooltip content="Settings" placement="bottom">
<Link to="/settings">
<Button className="bg-content2 mr-2" size="md" isIconOnly>
<HiCog size="25" className="w-auto" />
</Button>
</Link>
</Tooltip>
<UserDropdown
user={{
username: user?.username || "",
verified: user?.verified || false,
accessToken: cookies.accessToken || "",
moderator: user?.moderator,
pfp: user?.pfp,
}}
/>
</div>
)}
</div>
<AppbarStart
isSettings={settings || false}
pageName={pageName}
searchBarVisible={searchBarVisible}
/>
{user && (
<AppbarEnd
cookies={cookies}
dashboard={dashboard || true}
user={user}
/>
)}
</header>
</>
);
Expand Down
42 changes: 42 additions & 0 deletions client/src/components/appbar/verification-banner.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { sendVerificationLink } from "@/handlers/api";
import { User } from "@/stores/UserStore";
import { Button } from "@nextui-org/react";
import React, { FC } from "react";
import { HiBellAlert } from "react-icons/hi2";

interface IProps {
user: User;
loading: boolean;
setLoading: any;
}

/**
* @author
* @function @VerificationBanner
**/

export const VerificationBanner: FC<IProps> = ({
user,
loading,
setLoading,
}) => {
return (
<div className="bg-warning items-center flex p-2 bg-opacity-10 mb-5 rounded-lg text-warning">
<HiBellAlert size={20} />{" "}
<span className="ml-2 font-medium">
Some features are disabled. Please verify your e-mail to secure your
account.
</span>
<Button
onPress={() =>
sendVerificationLink(user?.tokens.accessToken || "", setLoading)
}
className="ml-auto"
color="warning"
isLoading={loading}
>
Resend Verification Link
</Button>
</div>
);
};
34 changes: 34 additions & 0 deletions client/src/components/search/search-input.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { SearchStore, SearchType } from "@/stores/SearchStore";
import { Input } from "@nextui-org/react";
import { observer } from "mobx-react";
import React, { FC } from "react";

interface IProps {
searchType: SearchType;
}

/**
* @author
* @function @SearchInput
**/

const SearchInputComp: FC<IProps> = ({ searchType }) => {
return (
<Input
onChange={(e) => {
SearchStore.setSearch({
type: searchType || "game",
query: e.target.value,
});
}}
className="mr-5"
placeholder="Search..."
value={
(SearchStore.search.type == searchType || "game") &&
SearchStore.search.query
}
/>
);
};

export const SearchInput = observer(SearchInputComp);
2 changes: 1 addition & 1 deletion client/src/components/sidebar/sidebar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const Sidebar: React.FC<SidebarProps> = ({ active, settings }) => {
variants={sidebarVariants}
initial={false}
animate={SidebarStore.open ? "sidebarOpen" : "sidebarClosed"}
className="bg-content1 mr-10 rounded-tr-xl h-full rounded-br-xl"
className="bg-content1 mr-10 h-full rounded-br-xl"
>
<div className="h-[85vh] p-5">
<div className="h-full">
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/titlebar/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FiMaximize, FiMinus, FiX } from "react-icons/fi";

const Titlebar = () => {
return (
<nav className="titlebar h-[40px] w-screen sticky z-50 top-0 bg-opacity-80 bg-background">
<nav className="titlebar h-[40px] z-50 backdrop-blur-lg w-screen sticky top-0 bg-content1">
<div className="flex flex-row mb-2 text-lg h-full tracking-wider font-heading pl-5">
<div className="mt-1">
Select Launcher{" "}
Expand Down
Loading

0 comments on commit 0984625

Please sign in to comment.