Skip to content

Commit

Permalink
Dao 717 Implemented gradient (#246)
Browse files Browse the repository at this point in the history
* DAO-710 feat: added HeaderTitle.tsx which is the typography that will be used for section titles.
BREAKING CHANGE: changed background color and foreground color
fix: removed plus icon from create proposal button.
fix: will now use HeaderTitle in the HeaderSection for proposals page
fix: will use HeaderTitle in the proposals page where latest proposals is
fix: edited columns name
fix: edited date output format
feat: edited MetricsCard.tsx to account for new style changes.
fix: My voting power in proposals is not a metric card anymore; this component was created there.
fix: adjusted width of metrics card of proposals created to 272 pixels
fix: camel case my voting power
fix: proposal name column will not wrap, and the text will be white due to new changes in the table design.
BREAKING CHANGE: table header will now contain new style changes.
BREAKING CHANGE: the table will have no rounded borders anymore due to design change.
BREAKING CHANGE: table head color has changed to the foreground per new design changes
fix: exported Typography type so it can be used.

* fix: will now use variant light for span

* DAO-715 fix: metrics card will now use span instead of paragraph to better reflect its purpose for the fiatAmount.
fix: the contractAddress link will have a margin top
fix: MetricsSection.tsx will now use HeaderTitle
fix: TotalTokenHoldingsSection.tsx will now use HeaderTitle
fix: TreasurySection.tsx will use HeaderTitle. The metrics card will be borderless to reflect new design changes.

* DAO-717
feat: added new button variant (sidebar-active)
feat: added new component DivWithGradient.tsx
feat: added gradient classes in the globals.css
feat: added GradientHeader.tsx
fix: removed classes from Header as design changes required it.
fix: the sidebar will now have the ConnectedComponent prop which will be used to render that component.
feat: added gradient header to sidebar
feat: added gradient border to sidebar buttons
fix: useful links added padding left
feat: created SidebarButton component to implement DRY.
  • Loading branch information
Freshenext authored Oct 7, 2024
1 parent 9ebd6a8 commit 9e98ebe
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 98 deletions.
21 changes: 21 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
.underline-thick {
text-decoration-thickness: 0.5px;
}

div.div-with-gradient::after {
background: linear-gradient(270deg, #FFFEE3 -30.96%, #F9E1FF 43.65%, #BE5B0F 77.22%, #932309 110.79%, #010101 155.56%);
content: "";
width: 100%;
height: 1px;
display: block;
position: absolute;
top: 0;
left: 0;
}

.gradient-header {
background: linear-gradient(270deg, #FFFEE3 -30.96%, #F9E1FF 43.65%, #BE5B0F 77.22%, #932309 110.79%, #010101 155.56%);
width: 100%;
height: 48px;
display: flex;
align-items: center;
padding-left: 25px;
}

}

* {
Expand Down
4 changes: 2 additions & 2 deletions src/app/treasury/MetricsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Paragraph } from '@/components/Typography'
import { HeaderTitle } from '@/components/Typography'
import { Table } from '@/components/Table'
import { TokenHoldingsStRIF } from '@/app/treasury/TokenHoldingsStRIF'

Expand All @@ -12,7 +12,7 @@ const tableData = [
]
export const MetricsSection = () => (
<div>
<Paragraph className="font-semibold text-[18px] mb-[17px]">Metrics</Paragraph>
<HeaderTitle className="mb-4">Metrics</HeaderTitle>
<Table data={tableData} />
</div>
)
4 changes: 2 additions & 2 deletions src/app/treasury/TotalTokenHoldingsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Paragraph } from '@/components/Typography'
import { HeaderTitle } from '@/components/Typography'
import { Table } from '@/components/Table'
import { RenderTokenPrice } from '@/app/user/Balances/RenderTokenPrice'
import { TokenHoldings } from '@/app/treasury/TokenHoldings'
Expand All @@ -20,7 +20,7 @@ const tableData = [

export const TotalTokenHoldingsSection = () => (
<div>
<Paragraph className="font-semibold text-[18px] mb-[17px]">Total token holdings</Paragraph>
<HeaderTitle className="mb-4">Total token holdings</HeaderTitle>
<Table data={tableData} />
</div>
)
8 changes: 5 additions & 3 deletions src/app/treasury/TreasurySection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTreasuryContext } from '@/app/treasury/TreasuryContext'
import { Paragraph } from '@/components/Typography'
import { HeaderTitle } from '@/components/Typography'
import { MetricsCard } from '@/components/MetricsCard'
import { toFixed } from '@/lib/utils'
import { treasuryContracts } from '@/lib/contracts'
Expand All @@ -8,17 +8,18 @@ export const TreasurySection = () => {
const { buckets } = useTreasuryContext()
return (
<div>
<Paragraph className="font-semibold text-[18px] mb-[17px]">Treasury</Paragraph>
<HeaderTitle className="mb-4">Treasury</HeaderTitle>
<div className="grid grid-cols-2 xl:grid-cols-4 gap-[24px]">
{/* RIF Holdings */}
{treasuryContracts.map((contract, index) => (
<MetricsCard
key={`${contract.name}-RIF`}
title={`${contract.name} RIF Holdings`}
amount={toFixed(buckets[index].RIF.amount)}
amount={`${toFixed(buckets[index].RIF.amount)} RIF`}
fiatAmount={`= USD ${buckets[index].RIF.fiatAmount}`}
contractAddress={contract.address}
data-testid={`${contract.name}-RIF`}
borderless
/>
))}
{/* RBTC Holdings */}
Expand All @@ -29,6 +30,7 @@ export const TreasurySection = () => {
amount={toFixed(buckets[index].RBTC.amount)}
fiatAmount={`= USD ${buckets[index].RBTC.fiatAmount}`}
data-testid={`${contract.name}-RBTC`}
borderless
/>
))}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { cn } from '@/lib/utils'
import { FC, JSX, MouseEvent, ReactNode } from 'react'
import { FaSpinner } from 'react-icons/fa6'
import { Span } from '../Typography'
import { DivWithGradient } from '@/components/Button/DivWithGradient'

export const BUTTON_DEFAULT_CLASSES = 'px-[24px] py-[12px] flex gap-x-1 items-center relative'

Expand Down Expand Up @@ -78,6 +79,7 @@ export const Button: FC<Props> = ({
<span className={cn('absolute left-[-20px] top-[4px]', startIconClasses)}>{startIcon}</span>
<Span>{text}</Span>
</span>
{variant === 'sidebar-active' && <DivWithGradient />}
</button>
)
}
3 changes: 3 additions & 0 deletions src/components/Button/DivWithGradient.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const DivWithGradient = () => (
<div className="div-with-gradient" style={{ width: '100%', position: 'absolute', bottom: 0, left: 0 }} />
)
9 changes: 8 additions & 1 deletion src/components/Button/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export type ButtonVariants = 'primary' | 'secondary' | 'secondary-full' | 'borderless' | 'outlined' | 'white'
export type ButtonVariants =
| 'primary'
| 'secondary'
| 'secondary-full'
| 'borderless'
| 'outlined'
| 'white'
| 'sidebar-active'
7 changes: 7 additions & 0 deletions src/components/GradientHeader/GradientHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Logo } from '@/components/Header/Logo'

export const GradientHeader = () => (
<div className="gradient-header">
<Logo />
</div>
)
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
export const Header = ({ children }: Props) => {
return (
<header className="container my-8">
<div className="flex justify-end">{children}</div>
<div className="flex">{children}</div>
</header>
)
}
15 changes: 8 additions & 7 deletions src/components/LeftSidebar/LeftSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Logo } from '@/components/Header/Logo'
import { SidebarButtons } from '@/components/LeftSidebar/SidebarButtons'
import { UsefulLinks } from '@/components/LeftSidebar/UsefulLinks'
import { LeftSidebarProps } from '@/components/LeftSidebar/types'
import { CopyrightInfo } from './CopyrightInfo'

export const LeftSidebar = ({ activeButton = 'communities', onSidebarButtonClick }: LeftSidebarProps) => {
export const LeftSidebar = ({
activeButton = 'communities',
onSidebarButtonClick,
ConnectedComponent,
}: LeftSidebarProps) => {
return (
<aside className="min-h-screen w-[327px] border border-input-bg px-8 border-b-0 flex flex-col justify-between whitespace-nowrap">
<div>
<Logo className="mb-[56px] mt-[47px]" />
<aside className="min-h-screen w-[300px] border border-input-bg px-6 border-b-0 flex flex-col justify-between whitespace-nowrap bg-foreground">
<div className="mt-[42px]">
<SidebarButtons onClick={onSidebarButtonClick} activeButton={activeButton} />
</div>
<div className="mb-4">
<UsefulLinks />
<CopyrightInfo />
{ConnectedComponent && ConnectedComponent}
</div>
</aside>
)
Expand Down
83 changes: 38 additions & 45 deletions src/components/LeftSidebar/SidebarButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,57 @@
import { Button } from '@/components/Button'
import { SidebarButtonsProps } from '@/components/LeftSidebar/types'
import Image from 'next/image'

const ImageAsIcon = ({ src, alt }: { src: string; alt: string }) => (
<Image src={src} alt={alt} width={20} height={20} />
)

const DEFAULT_BUTTON_CLASSNAME = 'mb-[32px] pl-11'

const START_ICON_CLASSES = 'left-[-28px] top-[2px]'

interface SidebarButtonProps {
text: string
isActive: boolean
onClick?: () => void
buttonProps: {
id: string
name: string
}
}
const SidebarButton = ({ text, onClick, isActive, buttonProps }: SidebarButtonProps) => (
<Button
fullWidth
centerContent={false}
startIconClasses={START_ICON_CLASSES}
onClick={onClick}
className={DEFAULT_BUTTON_CLASSNAME}
variant={isActive ? 'sidebar-active' : 'borderless'}
buttonProps={buttonProps}
>
{text}
</Button>
)
export const SidebarButtons = ({ onClick, activeButton = 'communities' }: SidebarButtonsProps) => (
<>
<Button
startIcon={<ImageAsIcon src="/images/sidemenu/user.svg" alt="User" />}
<SidebarButton
onClick={() => onClick?.('user')}
fullWidth
variant={!activeButton || activeButton.startsWith('user') ? 'primary' : 'borderless'}
centerContent={false}
className={DEFAULT_BUTTON_CLASSNAME}
isActive={!activeButton || activeButton.startsWith('user')}
buttonProps={{ id: 'Button_User', name: 'user' }}
startIconClasses={START_ICON_CLASSES}
>
My Collective
</Button>
<Button
startIcon={<ImageAsIcon src="/images/sidemenu/treasury.svg" alt="Treasury" />}
text="My Collective"
/>
<SidebarButton
onClick={() => onClick?.('treasury')}
fullWidth
variant={activeButton.startsWith('treasury') ? 'primary' : 'borderless'}
centerContent={false}
className={DEFAULT_BUTTON_CLASSNAME}
isActive={activeButton.startsWith('treasury')}
buttonProps={{ id: 'Button_Treasury', name: 'treasury' }}
startIconClasses={START_ICON_CLASSES}
>
Treasury
</Button>
<Button
startIcon={<ImageAsIcon src="/images/sidemenu/proposals.svg" alt="Proposals" />}
text="Treasury"
/>
<SidebarButton
onClick={() => onClick?.('proposals')}
fullWidth
variant={activeButton.startsWith('proposals') ? 'primary' : 'borderless'}
centerContent={false}
className={DEFAULT_BUTTON_CLASSNAME}
isActive={activeButton.startsWith('proposals')}
buttonProps={{ id: 'Button_Proposals', name: 'proposals' }}
startIconClasses={START_ICON_CLASSES}
>
Proposals
</Button>
<Button
startIcon={<ImageAsIcon src="/images/sidemenu/communities.svg" alt="Communities" />}
text="Proposals"
/>
<SidebarButton
onClick={() => onClick?.('communities')}
fullWidth
centerContent={false}
className={DEFAULT_BUTTON_CLASSNAME}
isActive={activeButton.startsWith('communities')}
buttonProps={{ id: 'Button_Communities', name: 'communities' }}
variant={activeButton.startsWith('communities') ? 'primary' : 'borderless'}
startIconClasses={START_ICON_CLASSES}
>
Communities
</Button>
text="Communities"
/>
</>
)
2 changes: 1 addition & 1 deletion src/components/LeftSidebar/UsefulLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { currentLinks } from '@/components/LeftSidebar/links'
export const UsefulLinks = () => (
<div className="mt-[4rem]">
<Paragraph className="mb-[24px] text-[16px]">Useful links</Paragraph>
<div className="flex flex-col">
<div className="flex flex-col pl-[16px]">
<Link href={currentLinks.rif} variant="menu" className="mb-[16px] text-[16px]" target="_blank">
RIF
</Link>
Expand Down
3 changes: 3 additions & 0 deletions src/components/LeftSidebar/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ReactNode } from 'react'

export type SidebarButtonType = 'communities' | 'treasury' | 'proposals' | 'user'

export interface SidebarButtonsProps {
Expand All @@ -8,4 +10,5 @@ export interface SidebarButtonsProps {
export interface LeftSidebarProps {
activeButton?: SidebarButtonType
onSidebarButtonClick?: (activeButton: SidebarButtonType) => void
ConnectedComponent?: ReactNode
}
59 changes: 32 additions & 27 deletions src/components/MainContainer/MainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { Footer } from '@/components/Footer'
import { ConnectButton, Header } from '@/components/Header'
import { StatefulSidebar } from '@/components/MainContainer/StatefulSidebar'
import { shortAddress } from '@/lib/utils'
import { usePathname, useRouter } from 'next/navigation'
import { useRouter } from 'next/navigation'
import { FC, ReactNode, useEffect, useState } from 'react'
import { useAccount, useDisconnect } from 'wagmi'
import { Alert } from '../Alert'
import { AccountAddress } from '../Header/AccountAddress'
import { DisconnectWalletModal } from '../Modal/DisconnectWalletModal'
import { ProtectedContent } from '../ProtectedContent/ProtectedContent'
import { MainContainerContent } from './MainContainerContent'
import { GradientHeader } from '@/components/GradientHeader/GradientHeader'

interface Props {
children: ReactNode
Expand All @@ -39,35 +39,40 @@ export const MainContainer: FC<Props> = ({ children, notProtected = false }) =>
setHasMounted(true)
}, [])

const ConnectedComponent = () => (
<>
{hasMounted && (
<>
<Header>
{isConnected ? (
<AccountAddress
address={address}
shortAddress={shortAddress(address)}
onLogoutClick={modal.openModal}
/>
) : (
<ConnectButton />
)}
</Header>
{modal.isModalOpened && (
<DisconnectWalletModal
onClose={modal.closeModal}
onConfirm={handleDisconnect}
onCancel={modal.closeModal}
address={address}
/>
)}
</>
)}
</>
)
return (
<>
<GradientHeader />
<div className="flex">
<StatefulSidebar />
<StatefulSidebar ConnectedComponent={<ConnectedComponent />} />
<div className="flex flex-1 flex-col justify-between">
<main className="px-[24px] mb-[100px]">
{hasMounted && (
<>
<Header>
{isConnected ? (
<AccountAddress
address={address}
shortAddress={shortAddress(address)}
onLogoutClick={modal.openModal}
/>
) : (
<ConnectButton />
)}
</Header>
{modal.isModalOpened && (
<DisconnectWalletModal
onClose={modal.closeModal}
onConfirm={handleDisconnect}
onCancel={modal.closeModal}
address={address}
/>
)}
</>
)}
<main className="px-[32px] py-[34px] mb-[100px]">
{message && (
<Alert {...message} onDismiss={message.onDismiss === null ? null : () => setMessage(null)} />
)}
Expand Down
Loading

0 comments on commit 9e98ebe

Please sign in to comment.