Skip to content

Commit 5b16a33

Browse files
committed
🪂 Revenue share participation widget (#5003)
* Make sure widget do not show unnecessary gap when there is no button * Create new widget for revenue share participation * Use widget on view * Minor fix on router
1 parent 25aff1a commit 5b16a33

File tree

4 files changed

+139
-48
lines changed

4 files changed

+139
-48
lines changed

packages/atlas/src/components/WidgetTile/WidgetTile.styles.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export const Wrapper = styled.div`
1919
padding: ${sizes(6)};
2020
}
2121
`
22-
export const Content = styled.div`
22+
export const Content = styled.div<{ withButton?: boolean }>`
2323
display: grid;
2424
align-self: flex-end;
2525
gap: ${sizes(4)};
2626
padding-right: ${sizes(2)};
2727
2828
${media.md} {
2929
gap: ${sizes(6)};
30-
grid-template-columns: 1fr auto;
3130
align-items: center;
31+
${(props) => (props.withButton ? 'grid-template-columns: 1fr auto;' : '')}
3232
}
3333
${media.lg} {
3434
gap: 0;

packages/atlas/src/components/WidgetTile/WidgetTile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const WidgetTile: FC<WidgetTileProps> = ({
6767
{withTooltip && <Information {...tooltip} />}
6868
{withCustomTopRightNode && customTopRightNode}
6969
</Title>
70-
<Content>
70+
<Content withButton={!!button}>
7171
{withCustomNode && customNode}
7272
{loading && (
7373
<>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import styled from '@emotion/styled'
2+
3+
import { SvgActionCheck, SvgJoyTokenMonochrome16 } from '@/assets/icons'
4+
import { FlexBox } from '@/components/FlexBox'
5+
import { Pill } from '@/components/Pill'
6+
import { Text } from '@/components/Text'
7+
import { Tooltip } from '@/components/Tooltip'
8+
import { WidgetTile } from '@/components/WidgetTile'
9+
import { Button } from '@/components/_buttons/Button'
10+
import { cVar } from '@/styles'
11+
12+
const data = {
13+
userTokensToUnlock: 20,
14+
tokensUnlocked: 120,
15+
totalTokensToUnlock: 200,
16+
holders: 5,
17+
holdersUnlocked: 3,
18+
}
19+
export const RevenueShareParticipationWidget = () => {
20+
const { userTokensToUnlock, totalTokensToUnlock, tokensUnlocked, holdersUnlocked, holders } = data
21+
return (
22+
<WidgetTile
23+
title="Revenue share participation"
24+
titleVariant="h400"
25+
customTopRightNode={
26+
userTokensToUnlock ? (
27+
<Button size="small">Unlock your tokens</Button>
28+
) : (
29+
<Tooltip
30+
placement="top-end"
31+
text="You already unlocked all of your previously staked tokens. All of your tokens can be found in my portfolio page."
32+
>
33+
<StyledPill icon={<SvgActionCheck />} size="large" label="Unlocked your tokens" />
34+
</Tooltip>
35+
)
36+
}
37+
customNode={
38+
<FlexBox flow="column" gap={6} width="100%">
39+
<FlexBox justifyContent="space-between">
40+
<FlexBox flow="column">
41+
<Text variant="h100" as="h1" color="colorTextMuted">
42+
HOLDERS EARNINGS
43+
</Text>
44+
<FlexBox alignItems="center">
45+
<SvgJoyTokenMonochrome16 />
46+
<Text variant="h400" as="h4">
47+
{tokensUnlocked}/{totalTokensToUnlock}
48+
</Text>
49+
</FlexBox>
50+
51+
<Text variant="t100" as="p" color="colorText">
52+
${tokensUnlocked}/{totalTokensToUnlock}
53+
</Text>
54+
</FlexBox>
55+
56+
<FlexBox flow="column" alignItems="end">
57+
<Text variant="h100" as="h1" color="colorTextMuted">
58+
ENDED ON
59+
</Text>
60+
<Text variant="h400" as="h4">
61+
{holdersUnlocked}/{holders}
62+
</Text>
63+
<Text variant="t100" as="p" color="colorText">
64+
{Math.round((holdersUnlocked / holders) * 100)}% holders
65+
</Text>
66+
</FlexBox>
67+
</FlexBox>
68+
69+
<ProgressBar progress={Math.round((holdersUnlocked / holders) * 100)} />
70+
</FlexBox>
71+
}
72+
/>
73+
)
74+
}
75+
76+
const ProgressBar = styled.div<{ progress: number }>`
77+
height: 12px;
78+
width: 100%;
79+
overflow: hidden;
80+
border-radius: ${cVar('radiusLarge')};
81+
background-color: ${cVar('colorCoreNeutral700')};
82+
position: relative;
83+
84+
::after {
85+
height: 12px;
86+
position: absolute;
87+
left: 0;
88+
border-radius: ${cVar('radiusLarge')};
89+
width: ${(props) => `${props.progress}%`};
90+
content: ' ';
91+
background-color: ${cVar('colorCoreNeutral700Lighten')};
92+
}
93+
`
94+
95+
const StyledPill = styled(Pill)`
96+
border-radius: 999px;
97+
98+
path {
99+
fill: ${cVar('colorTextSuccess')};
100+
}
101+
`
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,50 @@
1-
import styled from '@emotion/styled'
2-
31
import { SvgJoyTokenMonochrome24 } from '@/assets/icons'
2+
import { GridItem, LayoutGrid } from '@/components/LayoutGrid'
43
import { NumberFormat } from '@/components/NumberFormat'
54
import { RatioPreview } from '@/components/RatioPreview/RatioPreview'
65
import { WidgetTile } from '@/components/WidgetTile'
6+
import { RevenueShareParticipationWidget } from '@/components/_crt/RevenueShareParticipationWidget'
77
import { RevenueShareStateWidget } from '@/components/_crt/RevenueShareStateWidget'
8-
import { media, sizes } from '@/styles'
98

109
const DATA = {
1110
revenueShare: {
1211
endDate: new Date(Date.now() + 1000000),
1312
},
1413
}
14+
1515
export const CrtRevenueTab = () => {
1616
return (
17-
<WidgetContainer>
18-
<RevenueShareStateWidget end={DATA.revenueShare.endDate} />
19-
<WidgetTile
20-
title="CHANNEL BALANCE"
21-
customNode={
22-
<NumberFormat value={200} icon={<SvgJoyTokenMonochrome24 />} variant="h500" as="p" withDenomination />
23-
}
24-
tooltip={{
25-
text: 'Lorem ipsum',
26-
}}
27-
/>
28-
<WidgetTile
29-
title="REVENUE SHARE RATIO"
30-
customNode={
31-
<RatioPreview
32-
ratios={[
33-
[20, 'Holders'],
34-
[80, 'Channel'],
35-
]}
36-
/>
37-
}
38-
/>
39-
</WidgetContainer>
17+
<LayoutGrid>
18+
<GridItem colSpan={{ base: 12, sm: 4 }}>
19+
<RevenueShareStateWidget end={DATA.revenueShare.endDate} />
20+
</GridItem>
21+
<GridItem colSpan={{ base: 12, sm: 4 }}>
22+
<WidgetTile
23+
title="CHANNEL BALANCE"
24+
customNode={
25+
<NumberFormat value={200} icon={<SvgJoyTokenMonochrome24 />} variant="h500" as="p" withDenomination />
26+
}
27+
tooltip={{
28+
text: 'Lorem ipsum',
29+
}}
30+
/>
31+
</GridItem>
32+
<GridItem colSpan={{ base: 12, sm: 4 }}>
33+
<WidgetTile
34+
title="REVENUE SHARE RATIO"
35+
customNode={
36+
<RatioPreview
37+
ratios={[
38+
[20, 'Holders'],
39+
[80, 'Channel'],
40+
]}
41+
/>
42+
}
43+
/>
44+
</GridItem>
45+
<GridItem colSpan={{ base: 12 }}>
46+
<RevenueShareParticipationWidget />
47+
</GridItem>
48+
</LayoutGrid>
4049
)
4150
}
42-
43-
const WidgetContainer = styled.div`
44-
display: flex;
45-
gap: ${sizes(4)};
46-
flex-wrap: wrap;
47-
48-
> * {
49-
min-width: 320px;
50-
flex: 1;
51-
}
52-
53-
${media.md} {
54-
gap: ${sizes(6)};
55-
56-
> * {
57-
min-width: 400px;
58-
}
59-
}
60-
`

0 commit comments

Comments
 (0)