Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reskin | sidebar #1605

Merged
merged 41 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3a11ed9
Update bottom and left spacing of navigation items
adamgall Apr 24, 2024
9bfc108
Update container for the second set of navigation items
adamgall Apr 24, 2024
bb3b95b
Reskin the top navigation group, make it show up in the correct position
adamgall Apr 24, 2024
81bf40d
Update icons to phospher icons
adamgall Apr 24, 2024
4be70c0
Tweak bottom margin of button groups to match left/right margin
adamgall Apr 24, 2024
8293218
Fix misspelling
adamgall Apr 24, 2024
294d3b2
Allow for more granular stroke/fill customization per icon in nav men…
adamgall Apr 24, 2024
b1ce44f
Inline showing all of the various links, or not
adamgall Apr 25, 2024
22400fc
Make the "external links" navigation group icons slide open all prett…
adamgall Apr 25, 2024
efbbc2e
Auto show the external links navigation button set on 2xl screen size
adamgall Apr 25, 2024
27ccdb1
Make the buttons autoexpand at a fresh new 3xl breakpoint
adamgall Apr 25, 2024
be78bb4
Remove redundant code
adamgall Apr 25, 2024
c026a15
Fix location of first set of navigation icons
adamgall Apr 25, 2024
841f063
Fix the location and expand behavior for real this time I hope
adamgall Apr 25, 2024
9cc40e5
More tweaking
adamgall Apr 25, 2024
88539a0
Clean up top set of navigation items
adamgall Apr 26, 2024
64fd191
Fix spacing around top nav group
adamgall Apr 26, 2024
948a85d
Remove seemingly unnecessary css property
adamgall Apr 26, 2024
ab0301c
Fix location where hover expansion happens
adamgall Apr 26, 2024
d896364
Fix icon type, set size in shared component
adamgall Apr 26, 2024
b9ce277
Remove unneeded brackets
adamgall Apr 26, 2024
ece2b36
Fix small spacing issue
adamgall Apr 26, 2024
a13cb0c
Do Icon cleanup and property consolidation with External links too
adamgall Apr 26, 2024
95e0488
DRY up the NavigationLink and NavigationExternalLink into one component
adamgall Apr 26, 2024
521cdde
Faster drawers
adamgall Apr 26, 2024
dd906c7
Update search bar placeholder text
adamgall Apr 26, 2024
f418ccb
Delete "Navigation index" component
adamgall Apr 29, 2024
991812a
Copy and separate Navigation Links mobile menu from sidebar menu
adamgall Apr 29, 2024
b457f0c
Delete drawer overlay, don't need it because drawer is full width
adamgall Apr 29, 2024
df152ae
Remove some unnecessary elements
adamgall Apr 29, 2024
5cccce2
Make the mobile menu look pretty
adamgall Apr 29, 2024
c33a820
Recombine NavigationLinks into one component
adamgall Apr 29, 2024
177f502
Make link click/tap areas in nav take full heigh
adamgall Apr 29, 2024
6576f08
Add TODO comment to fix color
adamgall Apr 30, 2024
6551748
Make a type more generic
adamgall Apr 30, 2024
ae2481a
Merge branch 'reskin/refactor-root-reskin' into reskin/sidebar
adamgall Apr 30, 2024
e621c79
Move padding out of inline style
adamgall Apr 30, 2024
c63a468
Move padding out of parent and into child
adamgall Apr 30, 2024
5e69ee8
Move more css properties out of parent and into child
adamgall Apr 30, 2024
e80e17d
Put em back, it messed up the rounded corners
adamgall Apr 30, 2024
48561aa
Add active and hover states to navigation menu items
adamgall Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
mudrila marked this conversation as resolved.
Show resolved Hide resolved
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.

122 changes: 68 additions & 54 deletions src/components/ui/page/Navigation/NavigationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,88 @@
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';
import { Link } from 'react-router-dom';

interface INavigationLink {
href: string;
function LinkContent({
labelKey,
NavigationIcon,
t,
}: {
labelKey: string;
tooltipKey?: string;
testId: string;
Icon: ComponentWithAs<'svg', IconProps>;
target?: string;
rel?: string;
closeDrawer?: () => void;
NavigationIcon: Icon;
t: TFunction<'navigation', undefined>;
mudrila marked this conversation as resolved.
Show resolved Hide resolved
}) {
return (
<Flex>
<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 activeColors = useCallback(() => {
return {
color: isActive ? 'gold.500' : 'inherit',
_hover: {
color: 'gold.500-hover',
},
};
}, [isActive]);
const linkContent = (
<LinkContent
labelKey={labelKey}
NavigationIcon={NavigationIcon}
t={t}
/>
);

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}
style={{ display: 'block', paddingTop: '0.75rem', paddingBottom: '0.75rem' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we omit using inline styles? Or it was too complex to get it styled right without inline styling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might need your help with this one... The Link component here is from react-router-dom, not chakra-ui, and so doesn't have any paddingTop etc properties on it. I don't really know how else to add styles to this (I want to literally make the rendered anchor tag bigger) without either doing these inline styles, or defining a CSS class somewhere.

{...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"
style={{ display: 'block', paddingTop: '0.75rem', paddingBottom: '0.75rem' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag should have display block by default, unless there's some weird global style override. Also, we can avoid using inline styling if we'll use plain Chakra UI link and will pass these styles as props

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anchor tags seem to not be block by default.


style={{ display: 'block', paddingTop: '0.75rem', paddingBottom: '0.75rem' }}
Screenshot 2024-04-30 at 9 19 45 AM
style={{ paddingTop: '0.75rem', paddingBottom: '0.75rem' }}
Screenshot 2024-04-30 at 9 20 19 AM

And can you help me with whatever it is you're suggesting to not use inline styles? I guess I'm not sure what approach you're suggesting.

>
{linkContent}
</a>
);
}

return null;
}
Loading