Skip to content

Commit

Permalink
Implement DAO metadata - showing banner, meta links, logo in DAO dash…
Browse files Browse the repository at this point in the history
…board header and additional sections
  • Loading branch information
mudrila committed Nov 30, 2023
1 parent 7bfd64e commit 73a6304
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 47 deletions.
16 changes: 11 additions & 5 deletions app/daos/[daoAddress]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import { Activities } from '../../../src/components/pages/DaoDashboard/Activities';
import { ERCO20Claim } from '../../../src/components/pages/DaoDashboard/ERC20Claim';
import { Info } from '../../../src/components/pages/DaoDashboard/Info';
import InfoHeader from '../../../src/components/pages/DaoDashboard/Info/InfoHeader';
import ClientOnly from '../../../src/components/ui/utils/ClientOnly';
import useDAOMetadata from '../../../src/hooks/DAO/useDAOMetadata';

export default function DaoDashboardPage() {
const daoMetadata = useDAOMetadata();
return (
<ClientOnly mt={12}>
<Info />
<ERCO20Claim />
<Activities />
</ClientOnly>
<>
<InfoHeader />
<ClientOnly mt={!!daoMetadata ? 8 : 12}>
<Info />
<ERCO20Claim />
<Activities />
</ClientOnly>
</>
);
}
77 changes: 77 additions & 0 deletions src/components/pages/DaoDashboard/Info/InfoHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Box, Flex, Image, Menu, MenuButton, MenuList, Text } from '@chakra-ui/react';
import { FractalBrandBurger } from '@decent-org/fractal-ui';
import { useTranslation } from 'react-i18next';
import useDAOMetadata from '../../../../hooks/DAO/useDAOMetadata';
import { useFractal } from '../../../../providers/App/AppProvider';
import ExternalLink from '../../../ui/links/ExternalLink';

export default function InfoHeader() {
const {
node: { daoName },
} = useFractal();
const daoMetadata = useDAOMetadata();
const { t } = useTranslation();

if (!daoMetadata) {
return null;
}

return (
<Flex
bg={daoMetadata.headerBackground}
justifyContent="center"
alignItems="center"
marginLeft="-3rem"
marginRight="-3rem"
width="calc(100% + 6rem)"
paddingTop={2}
paddingBottom={2}
flexDirection="column"
>
<Image
src={daoMetadata.logo}
alt={`${daoName} logo`}
width="60px"
height="60px"
/>
<Box marginTop={2}>
<Menu>
<MenuButton>
<Flex>
{/* TODO: Replace with regular burger icon once added to @decent-org/fractal-ui */}
<FractalBrandBurger boxSize="2rem" />
<Text
textStyle="text-lg-mono-regular"
ml={4}
>
{daoName}
</Text>
</Flex>
</MenuButton>
<MenuList
rounded="lg"
shadow="menu-gold"
mr={['auto', '1rem']}
bg="grayscale.black"
border="none"
padding="1rem"
zIndex={1000}
>
<Text
textStyle="text-sm-sans-regular"
color="chocolate.200"
marginBottom="0.5rem"
>
{t('goTo')}
</Text>
{daoMetadata.links.map(link => (
<Box key={link.url}>
<ExternalLink href={link.url}>{link.title}</ExternalLink>
</Box>
))}
</MenuList>
</Menu>
</Box>
</Flex>
);
}
130 changes: 98 additions & 32 deletions src/components/pages/DaoDashboard/Info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client';

import { Box, Flex } from '@chakra-ui/react';
import { Box, Flex, Text } from '@chakra-ui/react';
import { DAO_ROUTES } from '../../../../constants/routes';
import useDAOMetadata from '../../../../hooks/DAO/useDAOMetadata';
import { useFractal } from '../../../../providers/App/AppProvider';
import { InfoBox } from '../../../ui/containers/InfoBox';
import { InfoDAO } from './InfoDAO';
Expand All @@ -14,6 +15,7 @@ export function Info() {
const {
node: { daoAddress },
} = useFractal();
const daoMetadata = useDAOMetadata();

// using this gap method instead of 'gap' to make width percentages more precise, since they
// can now add up to 100%, as well as prevent variable gap space as you widen the screen
Expand All @@ -40,37 +42,101 @@ export function Info() {
<InfoDAO />
</InfoBox>
</Box>
<Box
width={{ base: '100%', md: '33.3%', lg: '25%', xl: '20%' }}
ps={{ base: NONE, lg: PAD }}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox>
<InfoGovernance />
</InfoBox>
</Box>
<Box
width={{ base: '100%', md: '33.3%', lg: '19%', xl: '20%' }}
ps={{ base: NONE, md: PAD }}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.proposals.relative(daoAddress)}>
<InfoProposals />
</InfoBox>
</Box>
<Box
width={{ base: '100%', md: '33.3%', lg: '23%', xl: '20%' }}
ps={{ base: NONE, md: PAD }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.treasury.relative(daoAddress)}>
<InfoTreasury />
</InfoBox>
</Box>
{daoMetadata ? (
<>
<Box
width={{ base: '100%', md: '100%', lg: '67%', xl: '60%' }}
ps={{ base: NONE, lg: PAD }}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox
display="flex"
justifyContent="space-between"
>
<Box width="25%">
<InfoGovernance />
</Box>
<Box width="25%">
<InfoProposals />
</Box>
<Box width="25%">
<InfoTreasury />
</Box>
</InfoBox>
</Box>
<Flex
gap={6}
mt={8}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
{daoMetadata.sections.map((section, index) => (
<InfoBox
overflow="hidden"
position="relative"
minWidth="auto"
width="50%"
key={index}
>
{section.background && (
<Box
left="0"
top="-150%"
width="47.2vw"
height="47.2vw"
position="absolute"
zIndex="-1"
background={`url(${section.background})`}
backgroundSize="cover"
backgroundRepeat="no-repeat"
backgroundColor="lightgray"
backgroundPosition="50%"
/>
)}
<Text textStyle="text-lg-mono-regular">{section.title}</Text>
<Text textStyle="text-base-mono-regular">{section.content}</Text>
</InfoBox>
))}
</Flex>
</>
) : (
<>
<Box
width={{ base: '100%', md: '33.3%', lg: '25%', xl: '20%' }}
ps={{ base: NONE, lg: PAD }}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox>
<InfoGovernance />
</InfoBox>
</Box>
<Box
width={{ base: '100%', md: '33.3%', lg: '19%', xl: '20%' }}
ps={{ base: NONE, md: PAD }}
pe={{ base: NONE, md: PAD }}
pb={{ sm: PAD, md: NONE }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.proposals.relative(daoAddress)}>
<InfoProposals />
</InfoBox>
</Box>
<Box
width={{ base: '100%', md: '33.3%', lg: '23%', xl: '20%' }}
ps={{ base: NONE, md: PAD }}
pt={{ sm: PAD, lg: NONE }}
>
<InfoBox to={DAO_ROUTES.treasury.relative(daoAddress)}>
<InfoTreasury />
</InfoBox>
</Box>
</>
)}
</Flex>
</Flex>
);
Expand Down
22 changes: 13 additions & 9 deletions src/components/ui/containers/InfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { Box } from '@chakra-ui/react';
import { Box, BoxProps } from '@chakra-ui/react';
import { useRouter } from 'next/navigation';
import { ReactNode } from 'react';
import { BACKGROUND_SEMI_TRANSPARENT } from '../../../constants/common';

type InfoBoxProps = {
minHeight?: string;
minWidth?: { [key: string]: string } | string;
m?: string | number;
to?: string;
background?: string;
children: ReactNode;
} & BoxProps;

export function InfoBox({
minWidth = '100%',
minHeight = '10.6rem',
children,
to,
background,
...rest
}: {
minHeight?: string;
minWidth?: { [key: string]: string } | string;
m?: string | number;
to?: string;
children: ReactNode;
}) {
}: InfoBoxProps) {
const { push } = useRouter();
return (
<Box
Expand All @@ -30,7 +34,7 @@ export function InfoBox({
minWidth={minWidth}
h="100%"
minHeight={minHeight}
bg={BACKGROUND_SEMI_TRANSPARENT}
bg={background || BACKGROUND_SEMI_TRANSPARENT}
p="1rem"
borderRadius="0.5rem"
{...rest}
Expand Down
7 changes: 7 additions & 0 deletions src/hooks/DAO/loaders/snapshot/useSnapshotProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ export default function useSnapshotProposal(proposal: FractalProposal | null | u
}`,
})
.then(({ data: { vp } }) => {
if (!vp) {
return {
votingWeight: 0,
votingWeightByStrategy: [0],
votingState: 'final',
};
}
return {
votingWeight: vp.vp,
votingWeightByStrategy: vp.vp_by_strategy,
Expand Down
20 changes: 20 additions & 0 deletions src/hooks/DAO/useDAOMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useMemo } from 'react';
import lizzardsDAOMetadata from '../../metadata/lizzardsDAO';
import { useFractal } from '../../providers/App/AppProvider';

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

const daoMetadata = useMemo(() => {
switch (daoAddress) {
case lizzardsDAOMetadata.address:
return lizzardsDAOMetadata;
default:
return undefined;
}
}, [daoAddress]);

return daoMetadata;
}
3 changes: 2 additions & 1 deletion src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,6 @@
"invalidChain": "Your currently connected chain is not supported.",
"showMore": "Show More",
"showLess": "Show Less",
"poweredBy": "Powered by"
"poweredBy": "Powered by",
"goTo": "Go to"
}
Binary file added src/metadata/lizzardsDAO/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/metadata/lizzardsDAO/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { DAOMetadata } from '../../types';
import logo from './assets/logo.png';
import metaSectionBackground1 from './assets/meta-section-background-1.png';

const LIZZARDS_DAO_METADATA: DAOMetadata = {
address: '0x27feCf4E8A4394B1daC54541414b607f88c451F1',
logo: logo.src,
headerBackground:
'linear-gradient(269deg, rgba(110, 97, 240, 0.35) 3.2%, rgba(74, 163, 183, 0.35) 51.2%, rgba(101, 211, 138, 0.35) 98.2%), #000',
links: [
{
title: 'Eth Lizards White Paper',
url: 'https://ethlizards.gitbook.io/ethlizards-white-paper/',
},
{
title: 'Eth Lizards Docs',
url: 'https://ethlizards.io/',
},
{
title: 'Eth Lizards on Discord',
url: 'https://discord.com/invite/ethlizards',
},
],
sections: [
{
title: 'Description',
content:
'Vote here for this proposal or just click on the link to learn more about the proposal',
background: undefined,
},
{
title: 'Elemental Lizards coming soon',
content:
'Designed by gamers for Web3 Gamers, Guild Leaders, and Content Creators. The Elemental Lizards provide battle passes for all Ethlizards gaming experiences, customizable avatars, and exclusive community access for the Community Sub-DAO. Learn more ',
background: metaSectionBackground1.src,
},
],
};

export default LIZZARDS_DAO_METADATA;
Loading

0 comments on commit 73a6304

Please sign in to comment.