diff --git a/inertia/components/common/dropdown/dropdown.tsx b/inertia/components/common/dropdown/dropdown.tsx index 613203b..b578c31 100644 --- a/inertia/components/common/dropdown/dropdown.tsx +++ b/inertia/components/common/dropdown/dropdown.tsx @@ -8,35 +8,39 @@ import useClickOutside from '~/hooks/use_click_outside'; import useGlobalHotkeys from '~/hooks/use_global_hotkeys'; import useToggle from '~/hooks/use_modal'; -const DropdownStyle = styled.div<{ opened: boolean }>(({ opened, theme }) => ({ - cursor: 'pointer', - userSelect: 'none', - position: 'relative', - minWidth: 'fit-content', - width: 'fit-content', - maxWidth: '250px', - backgroundColor: opened ? theme.colors.secondary : theme.colors.background, - padding: '4px', - borderRadius: theme.border.radius, +const DropdownStyle = styled.div<{ opened: boolean; svgSize?: number }>( + ({ opened, theme, svgSize = 24 }) => ({ + cursor: 'pointer', + userSelect: 'none', + position: 'relative', + minWidth: 'fit-content', + width: 'fit-content', + maxWidth: '250px', + backgroundColor: opened ? theme.colors.secondary : theme.colors.background, + padding: '4px', + borderRadius: theme.border.radius, - '&:hover': { - backgroundColor: theme.colors.secondary, - }, + '&:hover': { + backgroundColor: theme.colors.secondary, + }, - '& svg': { - height: '24px', - width: '24px', - }, -})); + '& svg': { + height: `${svgSize}px`, + width: `${svgSize}px`, + }, + }) +); export default function Dropdown({ children, label, className, + svgSize, }: { children: ReactNode; label: ReactNode | string; className?: string; + svgSize?: number; }) { const dropdownRef = useRef(null); const { isShowing, toggle, close } = useToggle(); @@ -55,6 +59,7 @@ export default function Dropdown({ onClick={toggle} ref={dropdownRef} className={className} + svgSize={svgSize} > {label} {children} diff --git a/inertia/components/dashboard/collection/collection_container.tsx b/inertia/components/dashboard/collection/collection_container.tsx index 4dff6c9..60f2b0c 100644 --- a/inertia/components/dashboard/collection/collection_container.tsx +++ b/inertia/components/dashboard/collection/collection_container.tsx @@ -1,9 +1,9 @@ import styled from '@emotion/styled'; import { Link } from '@inertiajs/react'; import { RxHamburgerMenu } from 'react-icons/rx'; -import CollectionControls from '~/components/dashboard/collection/collection_controls'; -import CollectionDescription from '~/components/dashboard/collection/collection_description'; -import CollectionHeader from '~/components/dashboard/collection/collection_header'; +import CollectionControls from '~/components/dashboard/collection/header/collection_controls'; +import CollectionDescription from '~/components/dashboard/collection/header/collection_description'; +import CollectionHeader from '~/components/dashboard/collection/header/collection_header'; import LinkList from '~/components/dashboard/link/link_list'; import { NoCollection } from '~/components/dashboard/link/no_item'; import Footer from '~/components/footer/footer'; diff --git a/inertia/components/dashboard/collection/collection_controls.tsx b/inertia/components/dashboard/collection/header/collection_controls.tsx similarity index 93% rename from inertia/components/dashboard/collection/collection_controls.tsx rename to inertia/components/dashboard/collection/header/collection_controls.tsx index 08ad781..9274e51 100644 --- a/inertia/components/dashboard/collection/collection_controls.tsx +++ b/inertia/components/dashboard/collection/header/collection_controls.tsx @@ -7,7 +7,7 @@ import Dropdown from '~/components/common/dropdown/dropdown'; import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item'; const CollectionControls = () => ( - }> + } svgSize={18}> Add diff --git a/inertia/components/dashboard/collection/collection_description.tsx b/inertia/components/dashboard/collection/header/collection_description.tsx similarity index 100% rename from inertia/components/dashboard/collection/collection_description.tsx rename to inertia/components/dashboard/collection/header/collection_description.tsx diff --git a/inertia/components/dashboard/collection/collection_header.tsx b/inertia/components/dashboard/collection/header/collection_header.tsx similarity index 100% rename from inertia/components/dashboard/collection/collection_header.tsx rename to inertia/components/dashboard/collection/header/collection_header.tsx diff --git a/inertia/components/dashboard/collection/list/collection_item.tsx b/inertia/components/dashboard/collection/list/collection_item.tsx new file mode 100644 index 0000000..609880e --- /dev/null +++ b/inertia/components/dashboard/collection/list/collection_item.tsx @@ -0,0 +1,8 @@ +import styled from '@emotion/styled'; +import { Item } from '~/components/dashboard/side_nav/nav_item'; + +const CollectionItem = styled(Item)(({ theme }) => ({ + backgroundColor: theme.colors.secondary, +})); + +export default CollectionItem; diff --git a/inertia/components/dashboard/collection/list/collection_list.tsx b/inertia/components/dashboard/collection/list/collection_list.tsx new file mode 100644 index 0000000..48e3c2d --- /dev/null +++ b/inertia/components/dashboard/collection/list/collection_list.tsx @@ -0,0 +1,66 @@ +import { useTheme } from '@emotion/react'; +import styled from '@emotion/styled'; +import { AiFillFolderOpen, AiOutlineFolder } from 'react-icons/ai'; +import TextEllipsis from '~/components/common/text_ellipsis'; +import CollectionItem from '~/components/dashboard/collection/list/collection_item'; +import CollectionListContainer from '~/components/dashboard/collection/list/collection_list_container'; +import useActiveCollection from '~/hooks/use_active_collection'; +import useCollections from '~/hooks/use_collections'; + +const SideMenu = styled.nav(({ theme }) => ({ + height: '100%', + paddingLeft: '10px', + marginLeft: '5px', + borderLeft: `1px solid ${theme.colors.lightGrey}`, + display: 'flex', + gap: '.35em', + flexDirection: 'column', +})); + +const CollectionLabel = styled.p(({ theme }) => ({ + color: theme.colors.grey, +})); +const CollectionListStyle = styled.div({ + padding: '1px', + paddingRight: '5px', + display: 'flex', + flex: 1, + gap: '.35em', + flexDirection: 'column', + overflow: 'auto', +}); + +export default function CollectionList() { + const { activeCollection, setActiveCollection } = useActiveCollection(); + const { collections } = useCollections(); + const theme = useTheme(); + return ( + + + Collections • {collections.length} + + {collections.map((collection) => ( + setActiveCollection(collection)} + key={collection.id} + > + {collection.id === activeCollection?.id ? ( + + ) : ( + + )} + {collection.name} + + ))} + + + + ); +} diff --git a/inertia/components/dashboard/collection/list/collection_list_container.tsx b/inertia/components/dashboard/collection/list/collection_list_container.tsx new file mode 100644 index 0000000..fbfc951 --- /dev/null +++ b/inertia/components/dashboard/collection/list/collection_list_container.tsx @@ -0,0 +1,11 @@ +import styled from '@emotion/styled'; + +const CollectionListContainer = styled.div({ + height: '100%', + minHeight: 0, + paddingInline: '10px', + display: 'flex', + flexDirection: 'column', +}); + +export default CollectionListContainer; diff --git a/inertia/components/dashboard/link/link_controls.tsx b/inertia/components/dashboard/link/link_controls.tsx index db765ea..9ca5d7e 100644 --- a/inertia/components/dashboard/link/link_controls.tsx +++ b/inertia/components/dashboard/link/link_controls.tsx @@ -66,6 +66,7 @@ export default function LinkControls({ link }: { link: Link }) { } css={{ backgroundColor: theme.colors.secondary }} + svgSize={18} > {!link.favorite ? ( diff --git a/inertia/components/dashboard/side_nav/nav_item.tsx b/inertia/components/dashboard/side_nav/nav_item.tsx index 2496c58..fd46eb4 100644 --- a/inertia/components/dashboard/side_nav/nav_item.tsx +++ b/inertia/components/dashboard/side_nav/nav_item.tsx @@ -4,7 +4,7 @@ import { Link } from '@inertiajs/react'; export const Item = styled.div(({ theme }) => ({ userSelect: 'none', height: '40px', - width: '280px', + width: '250px', color: theme.colors.font, backgroundColor: theme.colors.background, padding: '8px 12px', diff --git a/inertia/components/dashboard/side_nav/user_card.tsx b/inertia/components/dashboard/side_nav/user_card.tsx index 2773ee4..fc7b361 100644 --- a/inertia/components/dashboard/side_nav/user_card.tsx +++ b/inertia/components/dashboard/side_nav/user_card.tsx @@ -8,7 +8,12 @@ export default function UserCard() { return ( isAuthenticated && ( - + {user.nickName} ) diff --git a/inertia/pages/dashboard.tsx b/inertia/pages/dashboard.tsx index defc1ae..846a6d4 100644 --- a/inertia/pages/dashboard.tsx +++ b/inertia/pages/dashboard.tsx @@ -8,6 +8,7 @@ import { ReactNode, useEffect, useMemo, useState } from 'react'; import { useHotkeys } from 'react-hotkeys-hook'; import { useSwipeable } from 'react-swipeable'; import CollectionContainer from '~/components/dashboard/collection/collection_container'; +import CollectionList from '~/components/dashboard/collection/list/collection_list'; import SideNavigation from '~/components/dashboard/side_nav/side_navigation'; import SwiperHandler from '~/components/dashboard/swiper_handler'; import DashboardLayout from '~/components/layouts/dashboard_layout'; @@ -55,6 +56,7 @@ export default function DashboardPage(props: Readonly) { )} +