diff --git a/package-lock.json b/package-lock.json index bf2f523e0c..677fc6ac54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,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", @@ -3428,9 +3428,9 @@ } }, "node_modules/@decent-org/fractal-ui": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/@decent-org/fractal-ui/-/fractal-ui-0.2.5.tgz", - "integrity": "sha512-yZ36jooF79NH9moBQCZG7S1VdToCLVk7tL9V/nFDJXBrAcRSK0jeHsuzzFwPZLsmyRfRiBYegnmciiEC7CD6tg==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@decent-org/fractal-ui/-/fractal-ui-0.3.0.tgz", + "integrity": "sha512-FBzepg8+ykXdTI9K8lTbdj1l5IuxplSetKECErlCuBdyU4ZLV04gVMKVfD7X8/FLCP+UzpBtf2XXF+cePpyUTA==", "peerDependencies": { "@chakra-ui/react": "^2.3.4", "@phosphor-icons/react": "^2.1.4", diff --git a/package.json b/package.json index ef86591c06..bd4c5b3a7c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/ui/menus/OptionMenu/index.tsx b/src/components/ui/menus/OptionMenu/index.tsx index ebc030a2e3..3a5862e431 100644 --- a/src/components/ui/menus/OptionMenu/index.tsx +++ b/src/components/ui/menus/OptionMenu/index.tsx @@ -41,7 +41,6 @@ export function OptionMenu({ > ) => { event.stopPropagation(); }} diff --git a/src/components/ui/page/Header/index.tsx b/src/components/ui/page/Header/index.tsx index 1d07eaf4cb..ac92f0645a 100644 --- a/src/components/ui/page/Header/index.tsx +++ b/src/components/ui/page/Header/index.tsx @@ -3,7 +3,6 @@ import { Drawer, DrawerCloseButton, DrawerContent, - DrawerOverlay, Flex, Hide, IconButton, @@ -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() { @@ -66,39 +64,54 @@ function HeaderLogo() { size="full" isFullHeight > - - + + + + + + - - - + diff --git a/src/components/ui/page/Layout/index.tsx b/src/components/ui/page/Layout/index.tsx index 1098e8ac30..48686fbb0e 100644 --- a/src/components/ui/page/Layout/index.tsx +++ b/src/components/ui/page/Layout/index.tsx @@ -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 ( - + + + ); diff --git a/src/components/ui/page/Navigation/NavigationExternalLink.tsx b/src/components/ui/page/Navigation/NavigationExternalLink.tsx deleted file mode 100644 index 18e115bc99..0000000000 --- a/src/components/ui/page/Navigation/NavigationExternalLink.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { Box, ComponentWithAs, Hide, IconProps, Text } from '@chakra-ui/react'; -import { useTranslation } from 'react-i18next'; -import { NavigationTooltip } from './NavigationTooltip'; - -interface INavigationLink { - tooltipKey: string; - ariaLabelKey: string; - href: string; - testId: string; - routeKey?: string; - Icon: ComponentWithAs<'svg', IconProps>; - closeDrawer?: () => void; -} - -export function NavigationExternalLink({ - tooltipKey, - ariaLabelKey, - testId, - Icon, - routeKey, - closeDrawer, - ...rest -}: INavigationLink) { - const { t } = useTranslation('navigation'); - - return ( - - - - - - {t(tooltipKey)} - - - - - ); -} diff --git a/src/components/ui/page/Navigation/NavigationLink.tsx b/src/components/ui/page/Navigation/NavigationLink.tsx index 9818af6f66..fe4862dcf6 100644 --- a/src/components/ui/page/Navigation/NavigationLink.tsx +++ b/src/components/ui/page/Navigation/NavigationLink.tsx @@ -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 ( + + {} + + {t(labelKey)} + + + ); } 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 = ( + + ); - return ( - + if (scope === 'internal') { + return ( - - - - {t(labelKey)} - - + {linkContent} - - ); + ); + } + + if (scope === 'external') { + return ( + + {linkContent} + + ); + } + + return null; } diff --git a/src/components/ui/page/Navigation/NavigationLinks.tsx b/src/components/ui/page/Navigation/NavigationLinks.tsx index 10729233bc..34bbea4009 100644 --- a/src/components/ui/page/Navigation/NavigationLinks.tsx +++ b/src/components/ui/page/Navigation/NavigationLinks.tsx @@ -1,118 +1,194 @@ -import { Flex } from '@chakra-ui/react'; +import { Box, Flex, Hide } from '@chakra-ui/react'; import { - Home, - Tree, - Proposals, - Treasury, - SupportQuestion, - Discord, - Documents, - Templates, -} from '@decent-org/fractal-ui'; + House, + GitFork, + Scroll, + Coins, + SquaresFour, + Question, + DiscordLogo, + BookOpen, +} from '@phosphor-icons/react'; import { DAO_ROUTES } from '../../../../constants/routes'; import { URL_FAQ, URL_DISCORD, URL_DOCS } from '../../../../constants/url'; import { LanguageSwitcher } from '../../../../i18n/LanguageSwitcher'; import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider'; -import Divider from '../../utils/Divider'; -import { NavigationExternalLink } from './NavigationExternalLink'; import { NavigationLink } from './NavigationLink'; -export function NavigationLinks({ +function ExternalLinks({ closeDrawer }: { closeDrawer?: () => void }) { + return ( + + + + + + + + + + + + + + ); +} + +function InternalLinks({ address, showDAOLinks, closeDrawer, }: { - showDAOLinks: boolean; address: string | null; + showDAOLinks: boolean; closeDrawer?: () => void; }) { const { addressPrefix } = useNetworkConfig(); + + if (!showDAOLinks || !address) { + return null; + } + return ( - <> - {showDAOLinks && address && ( - <> - - - - - - - - - )} - + - - - - + + + + + + + + ); +} - - - - +export function NavigationLinks({ + address, + showDAOLinks, + closeDrawer, +}: { + showDAOLinks: boolean; + address: string | null; + closeDrawer?: () => void; +}) { + return ( + + + + ); } diff --git a/src/components/ui/page/Navigation/index.tsx b/src/components/ui/page/Navigation/index.tsx deleted file mode 100644 index 13ff4898ef..0000000000 --- a/src/components/ui/page/Navigation/index.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Flex, Show } from '@chakra-ui/react'; -import { useFractal } from '../../../../providers/App/AppProvider'; -import { NavigationLinks } from './NavigationLinks'; - -function Navigation() { - const { - node: { daoAddress }, - } = useFractal(); - - const showDAOLinks = !!daoAddress; - return ( - - - - - - ); -} - -export default Navigation; diff --git a/src/i18n/LanguageSwitcher.tsx b/src/i18n/LanguageSwitcher.tsx index 4dccc5922d..f4684de75e 100644 --- a/src/i18n/LanguageSwitcher.tsx +++ b/src/i18n/LanguageSwitcher.tsx @@ -1,5 +1,5 @@ -import { Box, Center, Hide, Text } from '@chakra-ui/react'; -import { Globe } from '@decent-org/fractal-ui'; +import { Box, Flex } from '@chakra-ui/react'; +import { GlobeSimple } from '@phosphor-icons/react'; import { useTranslation } from 'react-i18next'; import { OptionMenu } from '../components/ui/menus/OptionMenu'; import { supportedLanguages } from '.'; @@ -14,29 +14,21 @@ export function LanguageSwitcher() { }; }); return ( -
- - - - {t(i18n.language.slice(0, 2))} - + + + - } - options={supported} - namespace="languages" - tooltipKey="tooltipTitle" - /> -
+ {t('tooltipTitle')} + + } + options={supported} + namespace="languages" + buttonProps={{ + width: 'full', + }} + /> ); } diff --git a/src/i18n/locales/en/dashboard.json b/src/i18n/locales/en/dashboard.json index 91b5e919ec..d5bbeef126 100644 --- a/src/i18n/locales/en/dashboard.json +++ b/src/i18n/locales/en/dashboard.json @@ -3,7 +3,7 @@ "emptyFavorites": "No favorites", "errorInvalidSearch": "This is not a valid Ethereum address", "errorFailedSearch": "Sorry, this address is not a Fractal or Safe{WALLET} on {{chain}}", - "searchDAOPlaceholder": "Enter any existing Safe address", + "searchDAOPlaceholder": "Search for a Safe by address or ENS", "titleGovernance": "Governance", "titleType": "Type", "titleVotingPeriod": "Voting Period", diff --git a/src/i18n/locales/en/navigation.json b/src/i18n/locales/en/navigation.json index 9a8f2c0b73..abfbc55ea1 100644 --- a/src/i18n/locales/en/navigation.json +++ b/src/i18n/locales/en/navigation.json @@ -11,8 +11,5 @@ "ariaLabelHome": "Navigate Safe Home", "ariaLabelProposals": "Navigate Safe Proposals", "ariaLabelActivities": "Navigate Safe Activities", - "ariaLabelTreasury": "Navigate Safe Treasury", - "ariaLabelFAQ": "Link to FAQ", - "ariaLabelDiscord": "Link to Discord", - "ariaLabelDocumentation": "Link to documentation" + "ariaLabelTreasury": "Navigate Safe Treasury" } diff --git a/src/i18n/locales/uk/navigation.json b/src/i18n/locales/uk/navigation.json index 8d5d9cc54b..fe42ec7144 100644 --- a/src/i18n/locales/uk/navigation.json +++ b/src/i18n/locales/uk/navigation.json @@ -4,8 +4,5 @@ "treasury": "Скарбниця", "faq": "FAQ", "documentation": "Документація", - "ariaLabelFractalBrand": "Перейти до Головної", - "ariaLabelFAQ": "Посилання на FAQ", - "ariaLabelDiscord": "Посилання на Discord", - "ariaLabelDocumentation": "Посилання на документацію" + "ariaLabelFractalBrand": "Перейти до Головної" }