Skip to content

Commit

Permalink
fix statitics
Browse files Browse the repository at this point in the history
  • Loading branch information
eshark9312 committed Nov 21, 2023
1 parent 9312382 commit 7682aeb
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 24 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/accounts/components/AccountInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import { Account } from '../types'
interface AccountInfoProps {
account: Account
locked?: boolean
variant?: 's' | 'm' | 'l'
}

export const AccountInfo = React.memo(({ account, locked }: AccountInfoProps) => {
export const AccountInfo = React.memo(({ account, locked, variant }: AccountInfoProps) => {
const { active } = useMyMemberships()

return (
<AccountInfoWrap>
<PhotoWrapper>
<AccountPhoto>
<Identicon size={40} theme={'beachball'} value={account.address} />
<Identicon size={variant === 's' || variant === 'm' ? 28 : 40} theme={'beachball'} value={account.address} />
</AccountPhoto>
{locked && (
<LockIconWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { Colors } from '@/common/constants'
interface Props {
option: AccountOption
isForStaking?: boolean
variant?: 's' | 'm' | 'l'
}

export const OptionAccount = ({ option, isForStaking }: Props) => {
export const OptionAccount = ({ option, isForStaking, variant }: Props) => {
const balances = useBalance(option.address)
const balance = isForStaking ? balances?.total : balances?.transferable
const balanceType = isForStaking ? 'Total' : 'Transferable'
Expand All @@ -23,7 +24,7 @@ export const OptionAccount = ({ option, isForStaking }: Props) => {

return (
<>
<AccountInfo account={option} locked={isLocked} />
<AccountInfo account={option} locked={isLocked} variant={variant} />
<BalanceInfoNarrow>
<InfoTitle>{balanceType} balance</InfoTitle>
<InfoValueWithLocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const OptionListAccount = React.memo(({ options, onChange, className, isF
<OptionsListComponent className={className}>
{freeAccounts.map((option) => (
<Option key={option.address} onClick={() => onChange && onChange(option)} variant={variant}>
<OptionAccount option={option} isForStaking={isForStaking} />
<OptionAccount option={option} isForStaking={isForStaking} variant={variant} />
</Option>
))}
{lockedAccounts.map((option) => (
Expand Down
13 changes: 11 additions & 2 deletions packages/ui/src/app/pages/Council/Council.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useMemo, useState } from 'react'
import styled from 'styled-components'

import { PageHeaderWithHint } from '@/app/components/PageHeaderWithHint'
import { PageLayout } from '@/app/components/PageLayout'
Expand Down Expand Up @@ -43,7 +44,7 @@ export const Council = () => {
const rewardPerDay = useMemo(() => reward?.period?.mul(reward?.amount ?? asBN(0)) ?? asBN(0), [reward])
const main = (
<MainPanel>
<Statistics>
<StatisticsStyle>
{electionStage === 'inactive' ? (
<BlockDurationStatistics title="Normal period remaining length" value={idlePeriodRemaining} />
) : (
Expand All @@ -64,7 +65,7 @@ export const Council = () => {
{ label: 'Per Week', value: rewardPerDay.mul(asBN(7)) },
]}
/>
</Statistics>
</StatisticsStyle>

{!isCouncilorLoading && sortedCouncilors.length === 0 ? (
<NotFoundText>There is no council member at the moment</NotFoundText>
Expand Down Expand Up @@ -92,3 +93,11 @@ const sortBy = ({ key, isDescending }: CouncilOrder): ((a: Councilor, b: Council
return (a, b) => (asBN(a[key] ?? 0).gte(asBN(b[key] ?? 0)) ? 1 : -1) * direction
}
}

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
`
16 changes: 14 additions & 2 deletions packages/ui/src/app/pages/WorkingGroups/MyRoles/MyRole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export const MyRole = () => {
</BadgeStatus>
)}
</BadgesRow>
<Statistics>
<StatisticsStyle>
<MyEarningsStat />
<StakeStat value={worker.stake} minStake={worker.minStake} />
<TokenValueStat title="Owed reward" value={worker.owedReward} />
<NextPayoutStat workers={[worker]} />
</Statistics>
</StatisticsStyle>
</RowGapBlock>
</PageHeaderWrapper>
}
Expand Down Expand Up @@ -256,3 +256,15 @@ export const PageHeaderWithButtons = styled(PageHeaderRow)`
}
}
`

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
@media (min-width: 1440px) {
grid-template-columns: repeat(4, 1fr);
}
`
17 changes: 15 additions & 2 deletions packages/ui/src/app/pages/WorkingGroups/MyRoles/MyRoles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BN from 'bn.js'
import React from 'react'
import styled from 'styled-components'

import { PageLayout, PageHeaderWrapper } from '@/app/components/PageLayout'
import { Loading } from '@/common/components/Loading'
Expand Down Expand Up @@ -58,15 +59,27 @@ export const MyRoles = () => {
}
main={
<MainPanel>
<Statistics>
<StatisticsStyle>
<MyEarningsStat />
<MyStakeStat />
<TokenValueStat title="Total owed reward" value={owedReward} />
<NextPayoutStat workers={workers} />
</Statistics>
</StatisticsStyle>
{displayRoles()}
</MainPanel>
}
/>
)
}

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
@media (min-width: 1440px) {
grid-template-columns: repeat(4, 1fr);
}
`
17 changes: 14 additions & 3 deletions packages/ui/src/app/pages/WorkingGroups/WorkingGroupsOpening.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const WorkingGroupOpening = () => {
</BadgeStatus>
<StatusBadge />
</BadgesRow>
<Statistics>
<StatisticsStyle>
<DurationStatistics title="Time Left" value={opening.expectedEnding} />
<TokenValueStat
title={`Reward per ${rewardPeriod?.toString()} blocks`}
Expand All @@ -166,7 +166,7 @@ export const WorkingGroupOpening = () => {
hiring={opening.hiring}
status={opening.status}
/>
</Statistics>
</StatisticsStyle>
</RowGapBlock>
</PageHeaderWrapper>
}
Expand Down Expand Up @@ -226,7 +226,6 @@ const ApplicationStatsStyles = styled(StatsBlock).attrs({ centered: true })`
justify-content: start;
`


const ResponsiveStyle = css`
aside {
> div {
Expand Down Expand Up @@ -255,3 +254,15 @@ const ResponsiveStyle = css`
}
}
`

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
@media (min-width: 1440px) {
grid-template-columns: repeat(4, 1fr);
}
`
13 changes: 11 additions & 2 deletions packages/ui/src/app/pages/WorkingGroups/WorkingGroupsOpenings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react'
import styled from 'styled-components'

import { PageHeaderWrapper, PageLayout } from '@/app/components/PageLayout'
import { ActivitiesBlock } from '@/common/components/Activities/ActivitiesBlock'
Expand Down Expand Up @@ -60,11 +61,11 @@ export const WorkingGroupsOpenings = () => {
}
main={
<MainPanel>
<Statistics>
<StatisticsStyle>
<MyRolesStat />
<MyStakeStat />
<MyEarningsStat />
</Statistics>
</StatisticsStyle>
<ContentWithTabs>
<Tabs tabsSize="xs" tabs={openingsTabs} />
{activeTab === 'OPENINGS' && (
Expand All @@ -84,3 +85,11 @@ export const WorkingGroupsOpenings = () => {
/>
)
}

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const CandidateCardStakeAndControls = styled.div`
width: fit-content;
column-gap: 32px;
margin-top: auto;
flex-wrap: wrap;
`

const CandidateCardStatistics = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ const HeaderImage = styled(UserImage)`
width: 100%;
`

const Title = styled.h4`
`
const Title = styled.h4``
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const RestoreVotesModal = () => {
}, [value, votingAttempts, setVotingAttempts])

return (
<Modal modalSize="s" modalHeight="s" onClose={hideModal}>
<Modal modalSize="m" modalHeight="s" onClose={hideModal}>
<ModalHeader title="Restore Votes" onClick={hideModal} />

<ModalBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ProposalList = ({ proposals, getSortProps, isPast, isLoading }: Pro
}

const ProposalListWarpper = styled(List)`
media (max-width: 1439px) {
@media (max-width: 1439px) {
row-gap: 16px;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const VoteForProposalModalForm = ({ proposal, send, context }: Props) =>
</RowGapBlock>
</Row>
<Row>
<ButtonsGroup>
<ResponsiveButtonsGroup>
<ButtonPrimary
size="medium"
onClick={() => send('SET_VOTE_STATUS', { status: 'Approve' })}
Expand All @@ -87,7 +87,7 @@ export const VoteForProposalModalForm = ({ proposal, send, context }: Props) =>
<CrossIcon />
Abstain
</ButtonPrimary>
</ButtonsGroup>
</ResponsiveButtonsGroup>
</Row>
{isRejected && (
<InlineToggleWrap>
Expand Down Expand Up @@ -136,3 +136,19 @@ const ProposalPreviewColumn = styled(ScrollableModalColumn)`
flex-direction: column;
gap: 24px;
`

const ResponsiveButtonsGroup = styled(ButtonsGroup)`
@media(max-width: 1023px){
grid-auto-flow: row;
grid-row-gap: 8px;
width: 100%;
button, a {
width: 100%;
display: flex;
justify-content: center;
align-items: center:
gap: 4px;
}
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const OpeningDetails = ({ opening, onClick, past }: OpeningListItemProps)
<OpenedItemTitle>{opening.title}</OpenedItemTitle>
</OpenedTop>
<TextBig light>{opening.shortDescription}</TextBig>
<Statistics withMargin gapSize="s">
<StatisticsStyle withMargin>
<StatsBlock size="m" centered>
<TextBig>
<TokenValue value={rewardPeriod?.mul(opening.rewardPerBlock)} />
Expand Down Expand Up @@ -79,7 +79,7 @@ export const OpeningDetails = ({ opening, onClick, past }: OpeningListItemProps)
</Tooltip>
</MinStake>
</StatsBlock>
</Statistics>
</StatisticsStyle>
<ButtonsGroup align="right">
<LinkButtonGhost to={openingRoute} size="medium">
Learn more
Expand All @@ -104,3 +104,11 @@ const MinStake = styled(Subscription)`
align-items: center;
gap: 8px;
`

const StatisticsStyle = styled(Statistics)`
grid-template-columns: 1fr;
@media (min-width: 768px) {
grid-template-columns: 1fr 1fr;
}
`

0 comments on commit 7682aeb

Please sign in to comment.