Skip to content

Commit

Permalink
chore: layout fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
w84april committed Nov 20, 2024
1 parent 5bbd7bc commit 2dfa07e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
5 changes: 3 additions & 2 deletions apps/common/components/MobileNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type {ReactElement} from 'react';
export function MobileNavbar({onClose}: {onClose: VoidFunction}): ReactElement {
const pathName = usePathname();

const currentTab = pathName?.startsWith('/apps') ? pathName?.split('/')[2] : '/';
const currentTab = pathName?.startsWith('/apps/') ? pathName?.split('/')[2] : 'apps';

return (
<div
className={
Expand All @@ -25,7 +26,7 @@ export function MobileNavbar({onClose}: {onClose: VoidFunction}): ReactElement {
currentTab === tab.route ? 'text-white' : 'text-gray-400'
)}
onClick={onClose}
href={tab.route === '/apps' ? tab.route : `/apps/${tab.route}`}>
href={tab.route === 'apps' ? `/${tab.route}` : `/apps/${tab.route}`}>
<div className={'flex size-6 items-center justify-center'}>
{iconsDict[tab.route as keyof typeof iconsDict]}
</div>
Expand Down
38 changes: 19 additions & 19 deletions apps/common/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Sidebar(props: TSidebarProps): ReactElement {
const router = useRouter();
const {configuration, dispatch} = useSearch();

const currentTab = pathName?.startsWith('/apps') ? pathName?.split('/')[2] : '/';
const currentTab = pathName?.startsWith('/apps/') ? pathName?.split('/')[2] : 'apps';

const onSearchClick = useCallback(() => {
if (!configuration.searchValue) {
Expand Down Expand Up @@ -58,24 +58,24 @@ export function Sidebar(props: TSidebarProps): ReactElement {
/>
</div>
<div className={'mt-6 flex flex-col'}>
{props.tabs.map(tab => (
<Link
className={cl(
'py-2 px-[28px] flex gap-4 text-base hover:bg-gray-600/40',
currentTab === tab.route ? 'text-white font-bold' : 'text-gray-400'
)}
href={tab.route === '/apps' ? tab.route : `/apps/${tab.route}`}
key={tab.route}>
<div className={'flex size-6 items-center justify-center'}>
{
iconsDict[
tab.route as 'apps' | 'community-apps' | 'vaults' | 'yearn-x' | 'integrations'
]
}
</div>
<p>{tab.title}</p>
</Link>
))}
{props.tabs.map(tab => {
const href = tab.route === 'apps' ? `/${tab.route}` : `/apps/${tab.route}`;
return (
<Link
className={cl(
'py-2 px-[28px] flex gap-4 text-base hover:bg-gray-600/40',
currentTab === tab.route ? 'text-white font-bold' : 'text-gray-400'
)}
shallow
href={href}
key={tab.route}>
<div className={'flex size-6 items-center justify-center'}>
{iconsDict[tab.route as keyof typeof iconsDict]}
</div>
<p>{tab.title}</p>
</Link>
);
})}
</div>
</div>

Expand Down
10 changes: 5 additions & 5 deletions apps/common/icons/IconVaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@ export function IconVaults(props: React.SVGProps<SVGSVGElement>): ReactElement {
width={'16'}
height={'16'}
rx={'3'}
stroke={'#9D9D9D'}
stroke={'currentColor'}
strokeWidth={'1.5'}
strokeLinecap={'round'}
strokeLinejoin={'round'}
/>
<path
d={'M12.7763 9.10264L13.0352 8.13672'}
stroke={'#9D9D9D'}
stroke={'currentColor'}
strokeWidth={'1.5'}
strokeLinecap={'round'}
strokeLinejoin={'round'}
/>
<path
d={'M10.9648 15.8634L11.2236 14.8975'}
stroke={'#9D9D9D'}
stroke={'currentColor'}
strokeWidth={'1.5'}
strokeLinecap={'round'}
strokeLinejoin={'round'}
/>
<path
d={'M14.8974 12.7763L15.8633 13.0352'}
stroke={'#9D9D9D'}
stroke={'currentColor'}
strokeWidth={'1.5'}
strokeLinecap={'round'}
strokeLinejoin={'round'}
/>
<path
d={'M8.13661 10.9648L9.10254 11.2236'}
stroke={'#9D9D9D'}
stroke={'currentColor'}
strokeWidth={'1.5'}
strokeLinecap={'round'}
strokeLinejoin={'round'}
Expand Down
14 changes: 8 additions & 6 deletions pages/apps/[category].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ import type {TApp} from '@common/types/category';

export default function Index(props: {router: NextRouter}): ReactElement {
const [shuffledApps, set_shuffledApps] = useState<TApp[]>();
const currentCatrgory = useMemo(() => {
const currentTab = props.router.asPath?.startsWith('/apps') ? props.router.asPath?.split('/')[2] : '/';
const currentCategory = useMemo(() => {
const currentTab = props.router.asPath?.startsWith('/apps/')
? props.router.asPath?.split('/')[2]
: 'featured-apps';
return CATEGORIES_DICT[currentTab as keyof typeof CATEGORIES_DICT];
}, [props.router.asPath]);

/**********************************************************************************************
** On component mount we shuffle the array of Apps to avoid any bias.
**********************************************************************************************/
useMountEffect(() => {
if (currentCatrgory?.apps.length < 1) {
if (currentCategory?.apps.length < 1) {
return;
}
set_shuffledApps(currentCatrgory?.apps.toSorted(() => 0.5 - Math.random()));
set_shuffledApps(currentCategory?.apps.toSorted(() => 0.5 - Math.random()));
});

return (
<div className={'mt-24 flex w-full justify-start px-4 !pl-8 pb-14 md:mt-10'}>
<div className={'flex w-full max-w-4xl flex-col'}>
<div className={'mb-10 flex w-full flex-col justify-start'}>
<p className={'text-3xl font-bold text-white md:text-[64px] md:leading-[64px]'}>
{currentCatrgory?.categoryName}
{currentCategory?.categoryName}
</p>

<p className={'mt-4 max-w-[610px] text-base text-gray-400'}>
{currentCatrgory?.categoryDescription}
{currentCategory?.categoryDescription}
</p>
</div>

Expand Down
13 changes: 8 additions & 5 deletions pages/apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export default function Home(): ReactElement {
</div>

<div>
<CarouselSlideArrows
onScrollBack={onScrollBack}
onScrollForward={onScrollForward}
className={'mb-6'}
/>
<div className={'mb-6 flex items-start justify-between'}>
<p className={'text-lg font-bold text-white'}>{'Featured Apps'}</p>
<CarouselSlideArrows
onScrollBack={onScrollBack}
onScrollForward={onScrollForward}
className={'w-auto'}
/>
</div>

<AppsCarousel
ref={carouselRef}
Expand Down

0 comments on commit 2dfa07e

Please sign in to comment.