Skip to content

Commit

Permalink
Merge pull request #1605 from decentdao/reskin/sidebar
Browse files Browse the repository at this point in the history
Reskin/sidebar
  • Loading branch information
adamgall authored Apr 30, 2024
2 parents c648099 + 48561aa commit 1eb53e7
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 290 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@adraffy/ens-normalize": "^1.10.1",
"@apollo/client": "^3.7.10",
"@chakra-ui/react": "^2.8.2",
"@decent-org/fractal-ui": "^0.2.5",
"@decent-org/fractal-ui": "^0.3.0",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@ethersproject/abstract-signer": "^5.7.0",
Expand Down
1 change: 0 additions & 1 deletion src/components/ui/menus/OptionMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function OptionMenu({
>
<MenuButton
as={buttonAs}
h="fit-content"
onClick={(event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
}}
Expand Down
53 changes: 33 additions & 20 deletions src/components/ui/page/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Drawer,
DrawerCloseButton,
DrawerContent,
DrawerOverlay,
Flex,
Hide,
IconButton,
Expand All @@ -20,7 +19,6 @@ import { useFractal } from '../../../../providers/App/AppProvider';
import { AccountDisplay } from '../../menus/AccountDisplay';
import { DAOSearch } from '../../menus/DAOSearch';
import { FavoritesMenu } from '../../menus/FavoritesMenu';
import Divider from '../../utils/Divider';
import { NavigationLinks } from '../Navigation/NavigationLinks';

function HeaderLogo() {
Expand Down Expand Up @@ -66,39 +64,54 @@ function HeaderLogo() {
size="full"
isFullHeight
>
<DrawerOverlay />
<DrawerContent
bg="chocolate.900"
bg="#221D25D6" // TODO get this into `decent-ui` repo
border="none"
backdropFilter="auto"
backdropBlur="10px"
>
<DrawerCloseButton
size="lg"
zIndex="banner"
/>
<Flex
mt={4}
justifyContent="space-between"
>
<Link
data-testid="navigationLogo-homeLink"
to={BASE_ROUTES.landing}
aria-label={t('ariaLabelFractalBrand')}
onClick={onClose}
>
<DecentLogo
aria-hidden
h="2.5rem"
w="2.125rem"
ml="1.75rem"
/>
</Link>
<DrawerCloseButton
size="lg"
zIndex="banner"
color="lilac-0"
position="relative"
top="0px"
/>
</Flex>

<Box
mt={12}
px={8}
position="relative"
mt={8}
px={6}
>
<DAOSearch closeDrawer={onClose} />
</Box>
<Flex
alignItems="center"
direction="column"
justifyContent={showDAOLinks ? 'space-evenly' : 'flex-start'}
flexGrow={1}
overflowY="auto"
px={8}
<Box
px={6}
pt={8}
>
<Divider />
<NavigationLinks
showDAOLinks={showDAOLinks}
address={daoAddress}
closeDrawer={onClose}
/>
</Flex>
</Box>
</DrawerContent>
</Drawer>
</>
Expand Down
21 changes: 15 additions & 6 deletions src/components/ui/page/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Box, Container, Grid, GridItem } from '@chakra-ui/react';
import { Box, Container, Grid, GridItem, Show } from '@chakra-ui/react';
import { Outlet } from 'react-router-dom';
import { CONTENT_HEIGHT, HEADER_HEIGHT } from '../../../../constants/common';
import { useFractal } from '../../../../providers/App/AppProvider';
import Header from '../Header';
import Navigation from '../Navigation';
import { NavigationLinks } from '../Navigation/NavigationLinks';

export default function Layout() {
const {
node: { daoAddress },
} = useFractal();

return (
<Grid
templateAreas={{
Expand Down Expand Up @@ -47,12 +52,16 @@ export default function Layout() {
area={'nav'}
display="flex"
flexDirection="column"
flexGrow="1"
position="fixed"
w="4.25rem"
minHeight={{ base: undefined, md: '100vh' }}
ml={6}
minHeight={{ base: undefined, md: `calc(100vh - ${HEADER_HEIGHT})` }}
>
<Navigation />
<Show above="md">
<NavigationLinks
showDAOLinks={!!daoAddress}
address={daoAddress}
/>
</Show>
</GridItem>
</Grid>
);
Expand Down
51 changes: 0 additions & 51 deletions src/components/ui/page/Navigation/NavigationExternalLink.tsx

This file was deleted.

130 changes: 77 additions & 53 deletions src/components/ui/page/Navigation/NavigationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,98 @@
import { Box, ComponentWithAs, Hide, IconProps, Text } from '@chakra-ui/react';
import { useCallback } from 'react';
import { Box, Flex } from '@chakra-ui/react';
import { Icon } from '@phosphor-icons/react';
import { TFunction } from 'i18next';
import { useTranslation } from 'react-i18next';
import { Link, useMatch } from 'react-router-dom';
import { NavigationTooltip } from './NavigationTooltip';

interface INavigationLink {
href: string;
function LinkContent({
labelKey,
NavigationIcon,
t,
isActive,
}: {
labelKey: string;
tooltipKey?: string;
testId: string;
Icon: ComponentWithAs<'svg', IconProps>;
target?: string;
rel?: string;
closeDrawer?: () => void;
NavigationIcon: Icon;
t: TFunction;
isActive: boolean;
}) {
return (
<Flex
py={3}
pl="11px"
borderRadius={{ md: 8 }}
_hover={{ bgColor: 'neutral-3' }}
borderWidth={isActive ? '1px' : '0px'}
borderColor="neutral-4"
bgColor={isActive ? 'neutral-3' : 'auto'}
>
<Box w={6}>{<NavigationIcon size={24} />}</Box>
<Box
mx={3}
whiteSpace="nowrap"
>
{t(labelKey)}
</Box>
</Flex>
);
}

export function NavigationLink({
href,
labelKey,
testId,
Icon,
tooltipKey,
NavigationIcon,
scope,
closeDrawer,
href,
...rest
}: INavigationLink) {
const tooltipTranslationKey = tooltipKey || labelKey;

}: {
href: string;
labelKey: string;
testId: string;
NavigationIcon: Icon;
scope: 'internal' | 'external';
closeDrawer?: () => void;
}) {
const { t } = useTranslation('navigation');
const isActive = useMatch(href);
const isActive = useMatch(href.substring(0, href.indexOf('?')));

const activeColors = useCallback(() => {
return {
color: isActive ? 'gold.500' : 'inherit',
_hover: {
color: 'gold.500-hover',
},
};
}, [isActive]);
const linkContent = (
<LinkContent
labelKey={labelKey}
NavigationIcon={NavigationIcon}
t={t}
isActive={!!isActive}
/>
);

return (
<NavigationTooltip label={t(tooltipTranslationKey)}>
if (scope === 'internal') {
return (
<Link
data-testid={testId}
aria-label={t(tooltipTranslationKey)}
aria-label={t(labelKey)}
to={href}
{...rest}
onClick={closeDrawer}
{...rest}
>
<Box
display={{ base: 'flex', md: undefined }}
gap={8}
justifyContent="space-between"
alignItems="center"
{...activeColors()}
>
<Icon
boxSize="1.5rem"
sx={{
'g path': {
transitionProperty: 'all',
transitionDuration: '300ms',
transitionTimingFunction: 'ease-out',
},
}}
/>
<Hide above="md">
<Text textStyle="text-md-mono-medium">{t(labelKey)}</Text>
</Hide>
</Box>
{linkContent}
</Link>
</NavigationTooltip>
);
);
}

if (scope === 'external') {
return (
<a
data-testid={testId}
aria-label={t(labelKey)}
href={href}
onClick={closeDrawer}
{...rest}
target="_blank"
rel="noreferrer noopener"
>
{linkContent}
</a>
);
}

return null;
}
Loading

0 comments on commit 1eb53e7

Please sign in to comment.