Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update about , popup search ,test and changelog #337

Merged
merged 6 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update about , popup search ,test and changelog
  • Loading branch information
ashik-75 committed Sep 28, 2023
commit 2a15fa22c46a1c2f6ad89934f47197b1d07afe8e
8 changes: 8 additions & 0 deletions ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### [6.0.0] - 2023-09-28

- Add Dashboard
- Add Newsfeed with Multiple options
- Add cookie policy, privacy policy and Terms page
- Add features (diffchecker | npmpackages | diagramming)
- Add floating search bar

### [5.0.0] - 2023-09-14

- Add QR code generator
Expand Down
18 changes: 6 additions & 12 deletions ui/src/components/General/PopupSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ const items = MENU_ITEMS.map((item) => item.children).flat();

const PopupSearch: React.FC = () => {
const navigate = useNavigate();
const { isDarkMode } = useContext(DarkModeContext);
const { isDarkMode, isModalOpen, handleModalOpen } =
useContext(DarkModeContext);
const [input, setInput] = useState<string>("");
const [isModalOpen, setIsModalOpen] = useState(false);
const searchInputRef = useRef<InputRef | null>(null);

const handleCancel = () => {
setIsModalOpen(false);
};
const searchInputRef = useRef<InputRef | null>(null);

const handleClick = (url: string) => {
navigate(url);
setIsModalOpen(false);
handleModalOpen();
};

const handleAfterOpen = () => {
Expand All @@ -34,14 +31,11 @@ const PopupSearch: React.FC = () => {
}
};

useCombinedKeyPress(
() => setIsModalOpen((open) => !open),
["ControlLeft", "KeyK"]
);
useCombinedKeyPress(handleModalOpen, ["ControlLeft", "KeyK"]);

return (
<Modal
onCancel={handleCancel}
onCancel={handleModalOpen}
title="Features"
open={isModalOpen}
footer={[]}
Expand Down
13 changes: 12 additions & 1 deletion ui/src/components/Layouts/FloatingSearchBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import { Input, theme } from "antd";
import style from "./FloatingSearchBar.module.scss";
import Icon from "components/General/Icon";
import { DarkModeContext } from "lib/utils/context/DarkModeProvider";
import { useContext } from "react";

const FloatingSearchBar = () => {
const userAgent = navigator.userAgent.toLowerCase();
const addonCommand = userAgent.indexOf("win") != -1 ? "cmd + k" : "⌘ K";

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

return (
<div
className={style.fsb}
style={{
backgroundColor: colorBgContainer,
}}
onClick={handleModalOpen}
>
<Input
addonBefore={<Icon name="Search" />}
addonAfter={<>cmd + k</>}
addonAfter={<>{addonCommand}</>}
placeholder="Search..."
value={""}
onChange={handleModalOpen}
/>
</div>
);
Expand Down
26 changes: 0 additions & 26 deletions ui/src/components/Layouts/Menu/tests/Menu.test.tsx

This file was deleted.

23 changes: 20 additions & 3 deletions ui/src/lib/utils/context/DarkModeProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import useDarkMode from "lib/utils/context/DarkModeProvider/utils/hooks/useDarkMode";
import { ReactNode, createContext, useMemo } from "react";
import {
ReactNode,
createContext,
useCallback,
useMemo,
useState,
} from "react";
import { DarkModeContextType } from "./utils/types";
import { DARK_MODE_STORAGE_KEY } from "./utils/constant";

Expand All @@ -8,13 +14,24 @@ const DarkModeContext = createContext<DarkModeContextType>(
);

const DarkModeProvider = ({ children }: { children: ReactNode }) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const { isDarkMode, algorithm, toggleTheme } = useDarkMode(
DARK_MODE_STORAGE_KEY
);

const handleModalOpen = useCallback(() => {
setIsModalOpen((prev) => !prev);
}, []);

const contextValue = useMemo(() => {
return { isDarkMode, algorithm, toggleTheme };
}, [isDarkMode, algorithm, toggleTheme]);
return {
isDarkMode,
algorithm,
toggleTheme,
isModalOpen,
handleModalOpen,
};
}, [isDarkMode, algorithm, toggleTheme, handleModalOpen, isModalOpen]);

return (
<DarkModeContext.Provider value={contextValue}>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/lib/utils/context/DarkModeProvider/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ interface DarkModeContextType {
isDarkMode: boolean;
toggleTheme: () => void;
algorithm: (token: SeedToken) => MapToken;
isModalOpen: boolean;
handleModalOpen: () => void;
}

export type { DarkModeContextType };
Loading
Loading