This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: followed collections on nav

+88 -45
+3 -2
src/webapp/features/collections/components/collectionNavItem/CollectionNavItem.tsx
··· 6 6 import { isMarginUri } from '@/lib/utils/margin'; 7 7 import MarginLogo from '@/components/MarginLogo'; 8 8 import { CollectionAccessType } from '@semble/types'; 9 + import { abbreviateNumber } from '@/lib/utils/text'; 9 10 10 11 interface Props { 11 12 name: string; ··· 41 42 rightSection={ 42 43 props.cardCount > 0 ? ( 43 44 <Badge 45 + fullWidth 44 46 className={ 45 47 isActive 46 48 ? isOpenCollection ··· 48 50 : styles.badgeActive 49 51 : styles.badge 50 52 } 51 - circle 52 53 > 53 - {props.cardCount} 54 + {abbreviateNumber(props.cardCount)} 54 55 </Badge> 55 56 ) : null 56 57 }
+77 -35
src/webapp/features/collections/components/collectionsNavList/CollectionsNavList.tsx
··· 1 1 'use client'; 2 2 3 3 import Link from 'next/link'; 4 - import { NavLink, Stack } from '@mantine/core'; 5 - import { BiCollection, BiRightArrowAlt } from 'react-icons/bi'; 4 + import { ActionIcon, Group, NavLink, Stack, Text } from '@mantine/core'; 5 + import { BiRightArrowAlt } from 'react-icons/bi'; 6 6 import CollectionNavItem from '../collectionNavItem/CollectionNavItem'; 7 7 import useMyCollections from '../../lib/queries/useMyCollections'; 8 - import { useToggle } from '@mantine/hooks'; 9 8 import CollectionsNavListError from './Error.CollectionsNavList'; 10 9 import CreateCollectionShortcut from '../createCollectionShortcut/CreateCollectionShortcut'; 11 10 import useMyProfile from '@/features/profile/lib/queries/useMyProfile'; 12 11 import { getRecordKey } from '@/lib/utils/atproto'; 13 12 import { useNavbarContext } from '@/providers/navbar'; 13 + import useFollowingCollections from '@/features/follows/lib/queries/useFollowingCollections'; 14 14 15 15 export default function CollectionsNavList() { 16 16 const { toggleMobile } = useNavbarContext(); 17 17 const { data, error } = useMyCollections({ limit: 30 }); 18 - const { data: profile } = useMyProfile(); 19 - const [opened, toggleMenu] = useToggle([true, false]); 18 + const { data: profile, error: profileError } = useMyProfile(); 19 + const { data: followingCollections, error: errorFollowingCollections } = 20 + useFollowingCollections({ identifier: profile.handle, limit: 30 }); 20 21 21 - if (error) { 22 + if (error || errorFollowingCollections || profileError) { 22 23 return <CollectionsNavListError />; 23 24 } 24 25 25 26 const collections = 26 27 data?.pages.flatMap((page) => page.collections ?? []) ?? []; 27 28 29 + const followedCollections = 30 + followingCollections?.pages.flatMap((page) => page.collections ?? []) ?? []; 31 + 28 32 return ( 29 - <NavLink 30 - variant="subtle" 31 - c="gray" 32 - label="Collections" 33 - leftSection={<BiCollection size={22} />} 34 - opened={opened} 35 - onClick={() => toggleMenu()} 36 - > 37 - <CreateCollectionShortcut /> 33 + <Stack gap={'xs'}> 34 + <Group justify="space-between"> 35 + <Text fw={600} c={'gray'}> 36 + Collections 37 + </Text> 38 38 39 - <NavLink 40 - component={Link} 41 - href={`/profile/${profile.handle}/collections`} 42 - label="View all" 43 - variant="subtle" 44 - c="blue" 45 - leftSection={<BiRightArrowAlt size={25} />} 46 - onClick={toggleMobile} 47 - /> 39 + <Group gap={'xs'}> 40 + <ActionIcon 41 + component={Link} 42 + href={`/profile/${profile.handle}/collections`} 43 + variant="light" 44 + radius={'xl'} 45 + color="blue" 46 + onClick={toggleMobile} 47 + > 48 + <BiRightArrowAlt size={18} /> 49 + </ActionIcon> 50 + <CreateCollectionShortcut /> 51 + </Group> 52 + </Group> 48 53 49 54 <Stack gap={0}> 50 - {collections.map((collection) => ( 51 - <CollectionNavItem 52 - key={collection.id} 53 - name={collection.name} 54 - url={`/profile/${collection.author.handle}/collections/${getRecordKey(collection.uri!!)}`} 55 - cardCount={collection.cardCount} 56 - accessType={collection.accessType} 57 - uri={collection.uri} 58 - /> 59 - ))} 55 + <NavLink label="My Collections" c={'gray'}> 56 + <Stack gap={0}> 57 + {collections.map((collection) => ( 58 + <CollectionNavItem 59 + key={collection.id} 60 + name={collection.name} 61 + url={`/profile/${collection.author.handle}/collections/${getRecordKey(collection.uri!!)}`} 62 + cardCount={collection.cardCount} 63 + accessType={collection.accessType} 64 + uri={collection.uri} 65 + /> 66 + ))} 67 + <NavLink 68 + component={Link} 69 + href={`/profile/${profile.handle}/collections`} 70 + label="View all" 71 + variant="subtle" 72 + c="blue" 73 + leftSection={<BiRightArrowAlt size={25} />} 74 + onClick={toggleMobile} 75 + /> 76 + </Stack> 77 + </NavLink> 78 + 79 + <NavLink label="Following" c={'gray'}> 80 + <Stack gap={0}> 81 + {followedCollections.map((collection) => ( 82 + <CollectionNavItem 83 + key={collection.id} 84 + name={collection.name} 85 + url={`/profile/${collection.author.handle}/collections/${getRecordKey(collection.uri!!)}`} 86 + cardCount={collection.cardCount} 87 + accessType={collection.accessType} 88 + uri={collection.uri} 89 + /> 90 + ))} 91 + <NavLink 92 + component={Link} 93 + href={`/profile/${profile.handle}/network/collections-following`} 94 + label="View all" 95 + variant="subtle" 96 + c="blue" 97 + leftSection={<BiRightArrowAlt size={25} />} 98 + onClick={toggleMobile} 99 + /> 100 + </Stack> 101 + </NavLink> 60 102 </Stack> 61 - </NavLink> 103 + </Stack> 62 104 ); 63 105 }
+8 -8
src/webapp/features/collections/components/createCollectionShortcut/CreateCollectionShortcut.tsx
··· 1 - import { NavLink } from '@mantine/core'; 1 + import { ActionIcon, Button, NavLink } from '@mantine/core'; 2 2 import { Fragment, useState } from 'react'; 3 3 import { FiPlus } from 'react-icons/fi'; 4 4 import CreateCollectionDrawer from '@/features/collections/components/createCollectionDrawer/CreateCollectionDrawer'; ··· 8 8 9 9 return ( 10 10 <Fragment> 11 - <NavLink 12 - component="button" 13 - label={'Create'} 14 - variant="subtle" 15 - c="blue" 16 - leftSection={<FiPlus size={25} />} 11 + <ActionIcon 12 + variant="light" 13 + radius={'xl'} 14 + color="blue" 17 15 onClick={() => setIsDrawerOpen(true)} 18 - /> 16 + > 17 + <FiPlus size={18} /> 18 + </ActionIcon> 19 19 <CreateCollectionDrawer 20 20 isOpen={isDrawerOpen} 21 21 onClose={() => setIsDrawerOpen(false)}