Skip to content

Commit

Permalink
Merge pull request #522 from forbole/dev
Browse files Browse the repository at this point in the history
v0.16.1
  • Loading branch information
calvinkei authored Dec 15, 2021
2 parents a6ba035 + 31d47d5 commit c53f800
Show file tree
Hide file tree
Showing 16 changed files with 206 additions and 46 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/images/icons/icon_tick.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions assets/images/icons/icon_warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions components/AssetDistributionChart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ const Chart: React.FC<ChartProp> = ({ data: rawData, setPopoverIndex, setAnchorP
const [activeIndex, setActiveIndex] = React.useState(0)
const theme: CustomTheme = useTheme()

const activeData = data[activeIndex] || data[0]

// todo: how to override light mode color of the pie? it shows black when it is activeIndex

const { top, left } = React.useMemo(() => {
const midAngle =
(((data[activeIndex].startAngle + data[activeIndex].endAngle) / 2) * Math.PI) / 180
const radius = (1.27 * Number(data[activeIndex].outerRadius.replace('%', ''))) / 2
const midAngle = (((activeData.startAngle + activeData.endAngle) / 2) * Math.PI) / 180
const radius = (1.27 * Number(activeData.outerRadius.replace('%', ''))) / 2
return {
top: `calc(50% - ${Math.sin(midAngle) * radius}px)`,
left: `calc(30% + ${Math.cos(midAngle) * radius}px)`,
}
}, [activeIndex, data])
}, [activeData])

return (
<Box position="relative" height={theme.spacing(33.5)} maxWidth={theme.spacing(64)} mx="auto">
Expand Down Expand Up @@ -82,11 +83,11 @@ const Chart: React.FC<ChartProp> = ({ data: rawData, setPopoverIndex, setAnchorP
</ResponsiveContainer>
<Box className={classes.divider} style={{ top, left }}>
<Typography className={classes.percentText} variant="h2" gutterBottom>
{formatPercentage(data[activeIndex].value, lang)}
{formatPercentage(activeData.value, lang)}
</Typography>
<Box display="flex" alignItems="center">
<Avatar className={classes.avatar} src={data[activeIndex].image} />
<Typography>{data[activeIndex].name}</Typography>
<Avatar className={classes.avatar} src={activeData.image} />
<Typography>{activeData.name}</Typography>
</Box>
</Box>
</Box>
Expand Down
28 changes: 15 additions & 13 deletions components/AssetDistributionChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,25 @@ const AssetDistributionChart: React.FC = () => {
Object.keys(balancesByValidator).forEach((moniker) => {
rawData.push({
name: moniker,
value: getTokenAmountBalance(balancesByValidator[moniker].amount),
// TODO: uncomment the line below when DSM has value > 0
// value: getTokenAmountBalance(balancesByValidator[moniker].amount),
value: Object.values(balancesByValidator[moniker].amount)
.map((a: any) => a.amount)
.reduce((a, b) => a + b, 0),
})
})
const total = rawData.map((d) => d.value).reduce((a, b) => a + b, 0)
setData(
rawData.map((d) => ({
name: d.name,
image: balancesByValidator[d.name].avatar,
value:
// eslint-disable-next-line no-nested-ternary
total === 0
? 1 / rawData.length
: d.value === total
? 1
: Math.round(d.value / total),
extraData: balancesByValidator[d.name],
}))
rawData
.filter((d) => d.value > 0)
.map((d) => ({
name: d.name,
image: balancesByValidator[d.name].avatar,
value:
// eslint-disable-next-line no-nested-ternary
total === 0 ? 1 / rawData.length : d.value === total ? 1 : d.value / total,
extraData: balancesByValidator[d.name],
}))
)
}
} catch (err) {
Expand Down
9 changes: 6 additions & 3 deletions components/Banner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link'
import { Card, CardMedia, alpha, useTheme } from '@material-ui/core'
import { Box, Card, CardMedia, alpha, useTheme } from '@material-ui/core'
import Carousel from 'react-material-ui-carousel'
import useStyles from './style'

Expand All @@ -23,14 +23,17 @@ const Banner: React.FC = () => {
}}
activeIndicatorIconButtonProps={{
style: {
color: theme.palette.primary.main,
backgroundColor: theme.palette.primary.main,
margin: theme.spacing(0.5, 0.5, 0),
},
}}
indicatorIconButtonProps={{
style: {
color: alpha(theme.palette.primary.main, 0.6),
backgroundColor: alpha(theme.palette.primary.main, 0.6),
margin: theme.spacing(0.5, 0.5, 0),
},
}}
IndicatorIcon={<Box p={0.5} borderRadius="50%" />}
>
{banners.map((banner) => (
<Link href="/dsm-airdrop" key={banner}>
Expand Down
8 changes: 5 additions & 3 deletions components/ConnectChainDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ConnectChainDialogProps {
onClose(event?: unknown, reason?: string): void
connections: ChainConnection[]
account: Account
shouldConnect?: boolean
}

interface Content {
Expand All @@ -51,6 +52,7 @@ const ConnectChainDialog: React.FC<ConnectChainDialogProps> = ({
onClose,
connections,
account,
shouldConnect,
}) => {
const { t } = useTranslation('common')
const classes = useStyles()
Expand All @@ -59,7 +61,7 @@ const ConnectChainDialog: React.FC<ConnectChainDialogProps> = ({
const sendTransaction = useSendTransaction()
const { password } = useWalletsContext()
const [stage, setStage, toPrevStage, isPrevStageAvailable] = useStateHistory<Stage>(
Stage.StartStage
shouldConnect ? Stage.SelectChainStage : Stage.StartStage
)

const [mnemonic, setMnemonic] = React.useState('')
Expand All @@ -80,9 +82,9 @@ const ConnectChainDialog: React.FC<ConnectChainDialogProps> = ({
setChain('')
setLedgerApp('')
setError('')
setStage(Stage.StartStage, true)
setStage(shouldConnect ? Stage.SelectChainStage : Stage.StartStage, true)
}
}, [open])
}, [open, shouldConnect])

React.useEffect(() => {
setError('')
Expand Down
Loading

0 comments on commit c53f800

Please sign in to comment.