mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: add collection list
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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 ? (
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user