Skip to content

Commit

Permalink
Set body background based on DAO metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrila committed Nov 30, 2023
1 parent 73a6304 commit 4b6272b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
30 changes: 28 additions & 2 deletions app/daos/[daoAddress]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use client';

import { ChakraProvider, extendTheme } from '@chakra-ui/react';
import { theme } from '@decent-org/fractal-ui';
import { useMemo } from 'react';
import { Activities } from '../../../src/components/pages/DaoDashboard/Activities';
import { ERCO20Claim } from '../../../src/components/pages/DaoDashboard/ERC20Claim';
import { Info } from '../../../src/components/pages/DaoDashboard/Info';
Expand All @@ -9,14 +12,37 @@ import useDAOMetadata from '../../../src/hooks/DAO/useDAOMetadata';

export default function DaoDashboardPage() {
const daoMetadata = useDAOMetadata();
const activeTheme = useMemo(() => {
if (daoMetadata && daoMetadata.bodyBackground) {
return extendTheme({
...theme,
styles: {
...theme.styles,
global: {
...theme.styles.global,
html: {
...theme.styles.global.html,
background: daoMetadata.bodyBackground,
},
body: {
...theme.styles.global.body,
background: daoMetadata.bodyBackground,
},
},
},
});
}
return theme;
}, [daoMetadata]);

return (
<>
<ChakraProvider theme={activeTheme}>
<InfoHeader />
<ClientOnly mt={!!daoMetadata ? 8 : 12}>
<Info />
<ERCO20Claim />
<Activities />
</ClientOnly>
</>
</ChakraProvider>
);
}
7 changes: 6 additions & 1 deletion src/components/pages/DaoDashboard/Info/InfoHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ export default function InfoHeader() {
</Text>
{daoMetadata.links.map(link => (
<Box key={link.url}>
<ExternalLink href={link.url}>{link.title}</ExternalLink>
<ExternalLink
href={link.url}
color="grayscale.100"
>
{link.title}
</ExternalLink>
</Box>
))}
</MenuList>
Expand Down
19 changes: 10 additions & 9 deletions src/hooks/DAO/useDAOMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import lizzardsDAOMetadata from '../../metadata/lizzardsDAO';
import { useFractal } from '../../providers/App/AppProvider';

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

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

return daoMetadata;
}
1 change: 1 addition & 0 deletions src/metadata/lizzardsDAO/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const LIZZARDS_DAO_METADATA: DAOMetadata = {
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',
bodyBackground: 'linear-gradient(180deg, #2A2F33 0%, #101212 100%)',
links: [
{
title: 'Eth Lizards White Paper',
Expand Down
1 change: 1 addition & 0 deletions src/types/daoGeneral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type DAOMetadata = {
address: string;
logo: string;
headerBackground: string;
bodyBackground?: string;
links: {
title: string;
url: string;
Expand Down

0 comments on commit 4b6272b

Please sign in to comment.