feat: add collection list

This commit is contained in:
Sonny
2024-05-14 13:54:50 +02:00
committed by Sonny
parent 5a8bda0322
commit a58d78302e
12 changed files with 122 additions and 24 deletions

View File

@@ -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';

View File

@@ -7,7 +7,7 @@ import Dropdown from '~/components/common/dropdown/dropdown';
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
const CollectionControls = () => (
<Dropdown label={<BsThreeDotsVertical />}>
<Dropdown label={<BsThreeDotsVertical />} svgSize={18}>
<DropdownItemLink href={PATHS.LINK.CREATE}>
<IoIosAddCircleOutline /> Add
</DropdownItemLink>

View File

@@ -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;

View File

@@ -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 (
<SideMenu>
<CollectionListContainer>
<CollectionLabel>Collections {collections.length}</CollectionLabel>
<CollectionListStyle>
{collections.map((collection) => (
<CollectionItem
css={{
cursor: 'pointer',
color:
activeCollection?.id === collection.id
? theme.colors.primary
: theme.colors.font,
}}
onClick={() => setActiveCollection(collection)}
key={collection.id}
>
{collection.id === activeCollection?.id ? (
<AiFillFolderOpen size={24} />
) : (
<AiOutlineFolder size={24} />
)}
<TextEllipsis>{collection.name}</TextEllipsis>
</CollectionItem>
))}
</CollectionListStyle>
</CollectionListContainer>
</SideMenu>
);
}

View File

@@ -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;

View File

@@ -66,6 +66,7 @@ export default function LinkControls({ link }: { link: Link }) {
<Dropdown
label={<BsThreeDotsVertical css={{ color: theme.colors.grey }} />}
css={{ backgroundColor: theme.colors.secondary }}
svgSize={18}
>
<StartItem onClick={onFavorite}>
{!link.favorite ? (

View File

@@ -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',

View File

@@ -8,7 +8,12 @@ export default function UserCard() {
return (
isAuthenticated && (
<Item className="disable-hover">
<RoundedImage src={user.avatarUrl} width={24} alt={altImage} />
<RoundedImage
src={user.avatarUrl}
width={24}
alt={altImage}
referrerPolicy="no-referrer"
/>
{user.nickName}
</Item>
)