Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeparticle committed Oct 1, 2023
1 parent 697c640 commit c5052c3
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 62 deletions.
6 changes: 2 additions & 4 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { ConfigProvider, Layout } from "antd";
import { ErrorBoundary } from "react-error-boundary";
import RoutesWithPageTitle from "pages/Routes";
import Sidebar from "components/Layouts/Sidebar";
import FloatingHeader from "components/Layouts/FloatingHeader";
import CookieConsent from "pages/Footer/CookieConsent";
import useTheme from "lib/utils/hooks/useTheme";
import PopupSearch from "components/General/PopupSearch";
import FloatingSearchBar from "components/Layouts/FloatingSearchBar";
import FloatingBar from "components/Layouts/FloatingBar";

const { Content } = Layout;

Expand All @@ -21,8 +20,7 @@ const App: React.FC = () => {
<Sidebar />
<Layout>
<Content>
<FloatingSearchBar />
<FloatingHeader />
<FloatingBar />
<RoutesWithPageTitle />
</Content>
</Layout>
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/General/Notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
} from "./utils/constants";
import useGetNotifications from "lib/utils/hooks/useGetNotifications";
import NotificationList from "./components/NotificationList";
import { NotificationProps } from "./utils/types";
import { getLocalstorageValue, setLocalstorageValue } from "lib/utils/helper";
import { compareDate } from "./utils/helper";

const Notification: React.FC<NotificationProps> = ({ colorText }) => {
const Notification: React.FC = () => {
const { notifications, isLoading, isError } = useGetNotifications(
NOTIFICATION_KEY,
NOTIFICATION_URL
Expand Down Expand Up @@ -43,7 +42,6 @@ const Notification: React.FC<NotificationProps> = ({ colorText }) => {
return (
<NotificationList
notifications={notifications}
colorText={colorText}
isLoading={isLoading}
isError={isError}
showRedFlag={showRedFlag}
Expand Down
6 changes: 1 addition & 5 deletions ui/src/components/General/Notification/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ interface Markdown {
features: string[];
}

interface NotificationProps {
colorText: string;
}

interface NotificationListProps {
notifications: Markdown[] | undefined;
showRedFlag: boolean;
Expand All @@ -17,4 +13,4 @@ interface NotificationListProps {
handleRedFlagNotification: () => void;
}

export type { Markdown, NotificationProps, NotificationListProps };
export type { Markdown, NotificationListProps };
18 changes: 18 additions & 0 deletions ui/src/components/Layouts/FloatingBar/FloatingBar.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.fb {
z-index: var(--bt-z-index-dropdown);
display: flex;
height: 64px;
align-items: center;
justify-content: flex-end;
flex-direction: row;

&__container {
right: var(--bt-size-10);
position: sticky;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
gap: 10px;
}
}
29 changes: 29 additions & 0 deletions ui/src/components/Layouts/FloatingBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import styles from "./FloatingBar.module.scss";
import FloatingSearchBar from "../FloatingSearchBar";
import FloatingHeader from "../FloatingHeader";
import { theme } from "antd";
const FloatingBar: React.FC = () => {
const {
token: { colorBgContainer },
} = theme.useToken();

return (
<div className={styles.fb}>
<div className={styles.fb__container}>
<FloatingSearchBar
styles={{
backgroundColor: colorBgContainer,
}}
/>
<FloatingHeader
styles={{
backgroundColor: colorBgContainer,
}}
/>
</div>
</div>
);
};

export default FloatingBar;
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
.fb {
position: absolute;
top: var(--bt-size-8);
right: var(--bt-size-20);
padding: var(--bt-size-4) 0 var(--bt-size-4) 0;
border-radius: var(--bt-size-10);
z-index: var(--bt-z-index-dropdown);
.fh {
display: flex;
align-items: center;
border-radius: var(--bt-size-10);
padding: var(--bt-size-4);
position: sticky;
flex-direction: row;

&__button {
border: none;
Expand Down
23 changes: 9 additions & 14 deletions ui/src/components/Layouts/FloatingHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import { Button, theme } from "antd";
import { Button } from "antd";
import style from "./FloatingHeader.module.scss";
import Notification from "components/General/Notification";
import Icon from "components/General/Icon";
import { Link } from "react-router-dom";

const FloatingHeader = () => {
const {
token: { colorBgContainer, colorText },
} = theme.useToken();
interface FloatingHeaderProps {
styles?: React.CSSProperties;
}

const FloatingHeader: React.FC<FloatingHeaderProps> = ({ styles }) => {
return (
<div
className={style.fb}
style={{
backgroundColor: colorBgContainer,
}}
>
<Notification colorText={colorText} />
<div className={style.fh} style={styles}>
<Notification />
<Link to="/feedback">
<Button className={style.fb__button}>
<Icon name="Megaphone" size={20} color={colorText} />
<Button className={style.fh__button}>
<Icon name="Megaphone" size={20} />
</Button>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.fsb {
position: absolute;
top: var(--bt-size-8);
right: 150px;
padding: var(--bt-size-4);
border-radius: var(--bt-size-10);
z-index: var(--bt-z-index-dropdown);
display: flex;
align-items: center;
justify-content: center;
&__input {
display: flex;
align-items: center;
position: sticky;
border-radius: var(--bt-size-10);
padding: var(--bt-size-4);
}
}

@media screen and (max-width: 900px) {
.fsb {
display: none;
&__input {
display: none;
}
}
}
34 changes: 15 additions & 19 deletions ui/src/components/Layouts/FloatingSearchBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
import { Input, theme } from "antd";
import { Input } from "antd";
import style from "./FloatingSearchBar.module.scss";
import Icon from "components/General/Icon";
import { useContext } from "react";
import { SearchModalContext } from "lib/utils/context/SearchModalProvider";
import useUserAgent from "lib/utils/hooks/useUserAgent";

const FloatingSearchBar = () => {
interface FloatingSearchBarProps {
styles?: React.CSSProperties;
}

const FloatingSearchBar: React.FC<FloatingSearchBarProps> = ({ styles }) => {
const os = useUserAgent();
const addonCommand = os === "win" ? "ctrl + k" : "⌘ K";

const {
token: { colorBgContainer },
} = theme.useToken();
const { handleModalOpen } = useContext(SearchModalContext);

return (
<div
className={style.fsb}
style={{
backgroundColor: colorBgContainer,
}}
<Input
style={styles}
addonBefore={<Icon name="Search" />}
addonAfter={<>{addonCommand}</>}
placeholder="Search..."
value={""}
onChange={handleModalOpen}
className={style.fsb__input}
onClick={handleModalOpen}
>
<Input
addonBefore={<Icon name="Search" />}
addonAfter={<>{addonCommand}</>}
placeholder="Search..."
value={""}
onChange={handleModalOpen}
/>
</div>
/>
);
};

Expand Down

0 comments on commit c5052c3

Please sign in to comment.