Skip to content

Commit

Permalink
Merge branch 'dev' into feat/responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtiti authored Aug 9, 2024
2 parents d85ca13 + ae0b469 commit 7f9ebd4
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"subtitle": "Ecosystem",
"gasPrice": "L1 Gas Price",
"transfer": "ERC-20 Transfer",
"home": "Home",
"LOCKEDASSETS": {
"lockedAssets": "Locked assets",
"lockedAssetsDescription": "Locked assets in Elastic Chain Ecosystem",
Expand Down
1 change: 1 addition & 0 deletions public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"subtitle": "Ecosistema",
"gasPrice": "Precio del gas L1",
"transfer": "Transferencia ERC-20",
"home": "Inicio",
"LOCKEDASSETS": {
"lockedAssets": "Activos bloqueados",
"lockedAssetsDescription": "Activos bloqueados en el ecosistema de Elastic Chain",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/icons/smallArrowDark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/smallArrowLight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions src/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { usePathname } from 'next/navigation';
import { Link, Typography, styled } from '@mui/material';
import { useTranslation } from 'next-i18next';
import Image from 'next/image';

import { useData, useCustomTheme } from '~/hooks';
import SmallArrowDark from '~/assets/icons/smallArrowDark.svg';
import SmallArrowLight from '~/assets/icons/smallArrowLight.svg';

interface BreadcrumbProps {
isChain: boolean;
}

export const Breadcrumb = ({ isChain }: BreadcrumbProps) => {
const pathname = usePathname();
const { chainData } = useData();
const { theme } = useCustomTheme();
const { t } = useTranslation();

const pathNames = pathname ? pathname.split('/').filter((path) => path) : [];

const breadcrumbItems = pathNames.map((path, index) => {
const isLast = index === pathNames.length - 1;
const displayName = isChain && isLast ? chainData?.metadata?.chainName || path : path;
const href = `/${pathNames.slice(0, index + 1).join('/')}`;

return {
key: index,
isLast,
displayName,
href,
};
});

return (
<BreadcrumbNav aria-label='breadcrumb'>
<BreadcrumbLink href='/'>{t('HOME.home')}</BreadcrumbLink>

{breadcrumbItems.map(({ key, isLast, displayName, href }) => (
<BreadcrumbItem key={key}>
<ArrowIcon src={theme === 'dark' ? SmallArrowDark : SmallArrowLight} alt='arrow' />
{isLast ? (
<BreadcrumbCurrent aria-current='page'>{displayName}</BreadcrumbCurrent>
) : (
<BreadcrumbLink href={href}>{displayName}</BreadcrumbLink>
)}
</BreadcrumbItem>
))}
</BreadcrumbNav>
);
};

const BreadcrumbNav = styled('nav')({
display: 'flex',
alignItems: 'center',
});

const BreadcrumbLink = styled(Link)(() => {
const { currentTheme } = useCustomTheme();
return {
display: 'flex',
alignItems: 'center',
color: currentTheme.textPrimary,
textDecoration: 'none',
fontSize: '0.875rem',
lineHeight: '1.25rem',
};
});

const BreadcrumbItem = styled('span')({
display: 'flex',
alignItems: 'center',
});

const ArrowIcon = styled(Image)({
width: '1.25rem',
});

const BreadcrumbCurrent = styled(Typography)(() => {
const { currentTheme } = useCustomTheme();
return {
fontSize: '0.875rem',
color: currentTheme.textSecondary,
lineHeight: '1.25rem',
};
});
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export * from './BasicSelect';
export * from './NotFound';
export * from './Gas';
export * from './TvlContentBox';
export * from './Breadcrumb';
export * from './Icon';
2 changes: 2 additions & 0 deletions src/containers/ChainDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { useMediaQuery } from '@mui/material';

import { ChainMetadata } from './ChainMetadata';
import { ChainDescription } from './ChainDescription';
import { Breadcrumb } from '~/components';

export const ChainDetail = () => {
return (
<ChainContainer>
<Breadcrumb isChain={true} />
<ChainMetadata />
<ChainDescription />
</ChainContainer>
Expand Down

0 comments on commit 7f9ebd4

Please sign in to comment.