Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pat/revamp stacking page #2959

Merged
merged 36 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bbad657
fix tab layout and add reward history ui
paulclindo Dec 22, 2021
d41e64b
unify getAvatarFromPoolId fn
paulclindo Dec 22, 2021
f0d43a8
add reward history ui with placeholders
paulclindo Dec 22, 2021
830595b
add dates and refactor components
paulclindo Dec 28, 2021
c378cd7
fix i18n en-us
paulclindo Dec 28, 2021
3de0ecb
Merge remote-tracking branch 'origin/develop' into add-reward-history
vsubhuman Mar 10, 2022
a63e390
merge fixes
vsubhuman Mar 10, 2022
3f4d712
Merge branch 'add-epoch-history' of github.com:Emurgo/yoroi-frontend …
Jun 28, 2022
cbede72
Merge branch 'add-epoch-history' of github.com:Emurgo/yoroi-frontend …
nistadev Jul 7, 2022
dfcfde6
Redo of rewards history modal styles
nistadev Jul 7, 2022
57ca0d6
Add en-US literal
nistadev Jul 12, 2022
dcac9c7
Merge branch 'add-epoch-history' of github.com:Emurgo/yoroi-frontend …
nistadev Jul 12, 2022
de1a73b
Removed mock data
nistadev Jul 12, 2022
83b6d57
Lint changes
nistadev Jul 12, 2022
f675212
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into add-e…
nistadev Jul 18, 2022
caf8338
Merge branch 'add-epoch-history' into add-reward-history
nistadev Jul 18, 2022
8070e00
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into add-e…
nistadev Jul 21, 2022
bbeea06
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into add-r…
nistadev Jul 21, 2022
00b2021
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into add-e…
nistadev Jul 26, 2022
95d77a8
Merge branch 'add-epoch-history' into add-reward-history
nistadev Jul 26, 2022
f6fe81d
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into pat/r…
nistadev Aug 1, 2022
ec3fe2f
Show Summary of Staking Dashboard
nistadev Aug 1, 2022
9c53bb9
removed duplicated keys
nistadev Aug 1, 2022
ea1a85b
Merge branch 'add-epoch-history' of github.com:Emurgo/yoroi-frontend …
nistadev Aug 1, 2022
66df850
Merge branch 'add-epoch-history' into pat/revamp-stacking-page
nistadev Aug 1, 2022
d3a95f9
Stake Pool Delegated with placeholders
nistadev Aug 5, 2022
212cae2
fix styles
nistadev Aug 11, 2022
756efe6
Merge branch 'develop' into pat/revamp-stacking-page
nistadev Aug 11, 2022
7e74d0b
Initialize time store requests
neuodev Sep 14, 2022
c264b93
Merge branch 'develop' of github.com:Emurgo/yoroi-frontend into pat/r…
nistadev Sep 14, 2022
5da695d
fixed ticker render if empty
nistadev Sep 14, 2022
69c766c
fix flow errors
nistadev Sep 15, 2022
233655d
Merge branch 'develop' into pat/revamp-stacking-page
vsubhuman Sep 15, 2022
915e00f
flow fixes
vsubhuman Sep 16, 2022
3cde7f0
lint fixes
vsubhuman Sep 16, 2022
cdf2287
lint fixes
vsubhuman Sep 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import type { ComponentType, Node } from 'react';
import { Box, styled } from '@mui/system';
import { Button, Typography } from '@mui/material';
import { toSvg } from 'jdenticon';
import { injectIntl } from 'react-intl';
import { observer } from 'mobx-react';
import type { $npm$ReactIntl$IntlShape } from 'react-intl';
import globalMessages from '../../../../i18n/global-messages';
import { HelperTooltip, SocialMediaStakePool } from './StakePool/StakePool';
import { SocialMediaStakePool } from './StakePool/StakePool';
import type { PoolData } from '../../../../containers/wallet/staking/SeizaFetcher';
import { getAvatarFromPoolId } from '../utils';

type Props = {|
delegatedPool: PoolData,
Expand All @@ -20,57 +20,102 @@ type Intl = {|
|};

function DelegatedStakePoolCard({ delegatedPool, undelegate, intl }: Props & Intl): Node {
const { id, name, ticker, avatar, roa, socialLinks, websiteUrl } = delegatedPool || {};
const avatarSource = toSvg(id, 36, { padding: 0 });
const avatarGenerated = `data:image/svg+xml;utf8,${encodeURIComponent(avatarSource)}`;
const { id, name, ticker, poolSize, share, avatar, roa, socialLinks, websiteUrl } =
delegatedPool || {};
const avatarGenerated = getAvatarFromPoolId(id);

return (
<Wrapper>
<AvatarWrapper>
{avatar != null ? (
<AvatarImg src={avatar} alt="stake pool logo" />
) : (
<AvatarImg src={avatarGenerated} alt="stake pool logo" />
)}
</AvatarWrapper>
<Box width="180px" overflow="hidden" paddingLeft="4px">
<Typography color="var(--yoroi-palette-gray-900)" variant="body1" mb="3px">
[{ticker}] {name}
<Card>
<Box
sx={{
padding: '15px 24px',
borderBottom: '1px solid var(--yoroi-palette-gray-200)',
}}
>
<Typography variant="h5" color="var(--yoroi-palette-gray-900)">
{intl.formatMessage(globalMessages.stakePoolDelegated)}
</Typography>
<SocialMediaStakePool
color="var(--yoroi-palette-gray-600)"
websiteUrl={websiteUrl}
socialLinks={socialLinks}
/>
</Box>
<Box display="flex" alignItems="center" flex="1">
{roa !== undefined && (
<>
<Typography variant="body1" color="var(--yoroi-palette-gray-600)">
<Wrapper sx={{ paddingBottom: 0 }}>
<AvatarWrapper>
{avatar != null ? (
<AvatarImg src={avatar} alt="stake pool logo" />
) : (
<AvatarImg src={avatarGenerated} alt="stake pool logo" />
)}
</AvatarWrapper>
<Box marginLeft="16px" sx={{ display: 'flex', alignItems: 'flex-start', gap: '10px' }}>
<Typography color="black" variant="body1" fontWeight="medium" mb="3px">
{ticker !== undefined ? `[${ticker}]` : ''} {name}
</Typography>
<SocialMediaStakePool
color="var(--yoroi-palette-gray-500)"
websiteUrl={websiteUrl}
socialLinks={socialLinks}
/>
</Box>
</Wrapper>
<Wrapper justifyContent="space-between" sx={{ paddingBottom: 0 }}>
{roa != null ? (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography variant="caption" fontWeight="500" color="var(--yoroi-palette-gray-500)">
{intl.formatMessage(globalMessages.roa30d)}
<Typography ml="8px" as="span" color="var(--yoroi-palette-gray-900)">
{roa}
</Typography>
</Typography>
<HelperTooltip message={intl.formatMessage(globalMessages.roaHelperMessage)} />
</>
<Typography as="span" color="black" variant="h2">
{roa} %
</Typography>
</Box>
) : null}
{poolSize != null && (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography variant="caption" fontWeight="500" color="var(--yoroi-palette-gray-500)">
Pool Size
</Typography>
<Typography as="span" color="black" variant="h2">
{poolSize}
</Typography>
</Box>
)}
</Box>
{share != null && (
<Box sx={{ display: 'flex', flexFlow: 'column' }}>
<Typography variant="caption" fontWeight="500" color="var(--yoroi-palette-gray-500)">
Share
</Typography>
<Typography as="span" color="black" variant="h2">
{share} %
</Typography>
</Box>
)}
</Wrapper>
{undelegate && (
<UndelegateButton color="secondary" onClick={undelegate}>
{intl.formatMessage(globalMessages.undelegateLabel)}
</UndelegateButton>
<Wrapper>
<UndelegateButton
sx={{ border: '2px solid #17D1AA', width: '50%' }}
color="secondary"
onClick={undelegate}
>
{intl.formatMessage(globalMessages.undelegateLabel)}
</UndelegateButton>
</Wrapper>
)}
</Wrapper>
</Card>
);
}
export default (injectIntl(observer(DelegatedStakePoolCard)): ComponentType<Props>);

const Card = styled(Box)({
backgroundColor: 'var(--yoroi-palette-common-white)',
borderRadius: '8px',
flex: '1 1 100%',
display: 'flex',
flexDirection: 'column',
});

const Wrapper: any = styled(Box)({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-start',
padding: 24,
});

const AvatarWrapper: any = styled(Box)({
width: '40px',
height: '40px',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @flow
import type { ComponentType, Node } from 'react';
import { Box, styled } from '@mui/system';
import { Typography } from '@mui/material';
import { observer } from 'mobx-react';
import { injectIntl } from 'react-intl';
import type { $npm$ReactIntl$IntlShape } from 'react-intl';
import globalMessages from '../../../../i18n/global-messages';
import { EpochProgressCard } from './EpochProgressCard';
import moment from 'moment';

type Props = {|
epochProgress: {|
currentEpoch: number,
startEpochDate: string,
endEpochDate: string,
percentage: number,
|},
|};

type Intl = {|
intl: $npm$ReactIntl$IntlShape,
|};

function EpochProgressWrapper({ epochProgress, intl }: Props & Intl): Node {
return (
<Card>
<Box
sx={{
padding: '15px 24px',
borderBottom: '1px solid var(--yoroi-palette-gray-200)',
}}
>
<Typography variant="h5" color="var(--yoroi-palette-gray-900)">
{intl.formatMessage(globalMessages.epochProgress)}
</Typography>
</Box>
<Box sx={{ padding: '24px' }}>
<EpochProgressCard
percentage={epochProgress.percentage}
days={moment(epochProgress.endEpochDate).diff(moment(), 'days')}
currentEpoch={epochProgress.currentEpoch}
startEpochDate={epochProgress.startEpochDate}
endEpochDate={epochProgress.endEpochDate}
/>
</Box>
</Card>
);
}

export default (injectIntl(observer(EpochProgressWrapper)): ComponentType<Props>);

const Card = styled(Box)({
backgroundColor: 'var(--yoroi-palette-common-white)',
borderRadius: '8px',
flex: '1 1 100%',
display: 'flex',
flexDirection: 'column',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// @flow
import { Component } from 'react';
import type { Node } from 'react';
import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts';
import { Box } from '@mui/system';
import type { GraphItems } from '../dashboard/GraphWrapper';

const graphVars = {
barWidth: 10,
fontSize: '14px',
lineHeight: 16,
};

type Props = {|
data: Array<GraphItems>,
epochTitle: string,
stakepoolNameTitle: string,
xAxisLabel: string,
yAxisLabel: string,
primaryBarLabel: string,
hideYAxis: boolean,
|};

export default class RewardGraphClean extends Component<Props> {
render(): Node {
const {
hideYAxis,
data,
xAxisLabel,
yAxisLabel,
primaryBarLabel,
epochTitle,
stakepoolNameTitle,
} = this.props;

const formatYAxis = value => (!hideYAxis ? value : '∗∗∗ ');
const GraphTooltip = ({
active,
payload,
label,
}: {|
active: boolean,
payload: ?[any],
label: string,
|}) => {
if (active && payload != null) {
const { poolName } = payload[0].payload;
return (
<Box
sx={{
padding: '8px 12px 8px 8px',
backgroundColor: '#242838',
color: 'var(--yoroi-dashboard-graph-tooltip-text-color)',
fontSize: '0.75rem',
lineHeight: '14px',
borderRadius: '4px',
}}
>
<p>
<span>{epochTitle}:</span>&nbsp;
<span>{label}</span>
</p>
<p>
<span>{primaryBarLabel}:</span>&nbsp;
<span>{payload[0].value}</span>
</p>
{poolName && (
<p>
<span>{stakepoolNameTitle}:</span>&nbsp;
<span>{payload[0].payload.poolName}</span>
</p>
)}
</Box>
);
}
return null;
};

// $FlowExpectedError[prop-missing] props are passed implicitly which causes a flow error
const graphTooltip = <GraphTooltip />;
return (
<ResponsiveContainer width="100%" height={210}>
<BarChart
data={data.slice(-10)}
height={200}
margin={{ top: 0, right: 0, left: 30, bottom: 0 }}
>
<XAxis
tick={{
fill: '#6B7384',
fontSize: graphVars.fontSize,
lineHeight: graphVars.lineHeight,
}}
dataKey="name"
height={50}
label={{
value: xAxisLabel,
position: 'insideBottom',
fontSize: graphVars.fontSize,
fill: '#6B7384',
}}
padding={{ left: 24, right: 24 }}
stroke="#DCE0E9"
tickLine={false}
/>
<YAxis
tickFormatter={formatYAxis}
padding={{ top: 12 }}
tick={{
fill: '#6B7384',
fontSize: graphVars.fontSize,
lineHeight: graphVars.lineHeight,
}}
stroke="#DCE0E9"
tickLine={false}
label={{
value: yAxisLabel,
position: 'insideLeft',
offset: -20,
dy: 50,
angle: -90,
fill: '#6B7384',
textAnchor: 'middle',
}}
/>

<Tooltip content={graphTooltip} cursor={false} />

<Bar
name={primaryBarLabel}
maxBarSize={graphVars.barWidth}
radius={[4, 4, 0, 0]}
dataKey="primary"
stackId="a"
fill="#3154CB"
/>
</BarChart>
</ResponsiveContainer>
);
}
}
Loading