-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1605 from decentdao/reskin/sidebar
Reskin/sidebar
- Loading branch information
Showing
13 changed files
with
318 additions
and
290 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
src/components/ui/page/Navigation/NavigationExternalLink.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.