From 50c2952f5cc86b94a92a9a5161f6ceb8e81db9a6 Mon Sep 17 00:00:00 2001 From: qridwan <404ridwan@gmail.com> Date: Sun, 7 Jul 2024 23:29:38 +0600 Subject: [PATCH] feat: Add create note functionality and toggle button to create or discard note --- src/components/Home/NoteLists.tsx | 29 ++++++++++++++++++--- src/components/layouts/Header.tsx | 9 ++++--- src/components/layouts/Sidebar.module.css | 5 ++-- src/components/layouts/Sidebar.tsx | 31 ++++++++++++----------- src/components/shared/Footer.tsx | 20 ++++++--------- src/layouts/MainLayout.tsx | 4 +-- 6 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/components/Home/NoteLists.tsx b/src/components/Home/NoteLists.tsx index f4eedb4..3652521 100644 --- a/src/components/Home/NoteLists.tsx +++ b/src/components/Home/NoteLists.tsx @@ -1,16 +1,37 @@ -import { Grid, Text } from '@mantine/core'; +import { Button, Grid, Text } from '@mantine/core'; import { noteType } from '../../types/note'; import BoiLoader from '../../atoms/Loader'; import { SingleNote } from './SingleNote'; +import React, { useEffect } from 'react'; +import CreateNote from '../../pages/CreateNote'; +import { IconSquarePlus, IconX } from '@tabler/icons-react'; const NoteLists = ({ type, notes, isLoading }: { type: string, notes: noteType[] | any, isLoading: boolean }) => { + const [isAddNoteOpen, setIsAddNoteOpen] = React.useState(false); + + useEffect(() => { + isLoading && setIsAddNoteOpen(false); + }, [isLoading]); + const addNote = + + { + isAddNoteOpen && + } + return ( + { - isLoading ? : notes?.length > 0 ? notes.map((note: any) => - - ) : No notes Found! + isLoading ? : notes?.length > 0 ? <> + {addNote} + {notes.map((note: any) => + + )} + : <> + {addNote} + No notes Found! + } ); diff --git a/src/components/layouts/Header.tsx b/src/components/layouts/Header.tsx index a0d4035..3238a46 100644 --- a/src/components/layouts/Header.tsx +++ b/src/components/layouts/Header.tsx @@ -134,14 +134,17 @@ export default XHeader; const useStyles = createStyles((theme) => ({ header: { - paddingTop: theme.spacing.sm, + // paddingTop: theme.spacing.sm, backgroundColor: theme.colors.gray[1], borderBottom: theme.colors.yellow, - // marginBottom: rem(10), + position: "fixed", + top: 0, + width: "100%", + zIndex: 1, }, mainSection: { - paddingBottom: theme.spacing.sm, + // paddingBottom: theme.spacing.sm, }, user: { diff --git a/src/components/layouts/Sidebar.module.css b/src/components/layouts/Sidebar.module.css index 8f03b84..5f3b6b3 100644 --- a/src/components/layouts/Sidebar.module.css +++ b/src/components/layouts/Sidebar.module.css @@ -1,12 +1,13 @@ .navbar { background-color: var(--mantine-color-gray-1); - width: rem(300px); + width: rem(250px); padding: var(--mantine-spacing-md); - padding-top: 0; + padding-top: 100px; display: flex; flex-direction: column; border-right: rem(1px) solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4)); + position: fixed; } /* //media query */ diff --git a/src/components/layouts/Sidebar.tsx b/src/components/layouts/Sidebar.tsx index c3691d4..b639540 100644 --- a/src/components/layouts/Sidebar.tsx +++ b/src/components/layouts/Sidebar.tsx @@ -76,23 +76,24 @@ export function XSidebar({ toggle }: { toggle: () => void }) {