Skip to content

Commit

Permalink
Am/wip treasury (#450)
Browse files Browse the repository at this point in the history
* feat: new treasury upload

* feat: update

* feat: last chart

* fix visual details

* fix: small fixes

* fix: new icons

* fix: default coin icon

* fix: smaller icons

* fix: hide pagination

* fix: remove old icons

* fix: remove filter button

Co-authored-by: Alexis Munoz <alexismn86@gmail.com>
  • Loading branch information
AlexisZero and EZAMN authored Oct 17, 2022
1 parent 188b62c commit 8c46139
Show file tree
Hide file tree
Showing 24 changed files with 1,074 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ yarn-error.log*
.vercel

**/sitemap.xml
.vscode/settings.json
24 changes: 24 additions & 0 deletions pkg/app/public/svg/coins/ausd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/btc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions pkg/app/public/svg/coins/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/eth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions pkg/app/public/svg/coins/game.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/kusama.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 pkg/app/public/svg/coins/play.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/usdc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pkg/app/public/svg/coins/usdt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions pkg/app/public/svg/coins/zero.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 44 additions & 42 deletions pkg/app/src/components/Charts/areaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,62 @@ interface ComponentProps {
series: any
height: number
width?: number
options?: any
}

export function AreaChart({ categories, series, height }: ComponentProps) {
export function AreaChart({ categories, series, height, options = null }: ComponentProps) {
const theme = useTheme()

const chartOptions: ApexOptions = useMemo(
() => ({
chart: {
background: 'transparent',
stacked: false,
toolbar: {
show: false,
() =>
options || {
chart: {
background: 'transparent',
stacked: false,
toolbar: {
show: false,
},
},
},
colors: [theme.palette.primary.main],
dataLabels: {
enabled: false,
},
fill: {
colors: [alpha(theme.palette.primary.main, 0.2)],
},
grid: {
borderColor: 'transparent',
strokeDashArray: 0,
},
stroke: {
curve: 'smooth',
},
theme: {
mode: theme.palette.mode,
},
xaxis: {
type: 'datetime',
axisBorder: {
show: false,
colors: [theme.palette.primary.main],
dataLabels: {
enabled: false,
},
axisTicks: {
show: false,
fill: {
colors: [alpha(theme.palette.primary.main, 0.2)],
},
categories: categories,
grid: {
borderColor: 'transparent',
strokeDashArray: 0,
},
stroke: {
curve: 'smooth',
},
theme: {
mode: theme.palette.mode,
},
xaxis: {
type: 'datetime',
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
categories: categories,

labels: {
show: false,
labels: {
show: false,
},
},
},
tooltip: {
x: {
format: 'dd/MM/yy',
tooltip: {
x: {
format: 'dd/MM/yy',
},
},
yaxis: {
show: false,
},
},
yaxis: {
show: false,
},
}),
[categories],
)

Expand Down
16 changes: 11 additions & 5 deletions pkg/app/src/components/Charts/radialBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import type { ApexOptions } from 'apexcharts'
import { Chart } from './chart'

interface ComponentProps {
color: string
colors: string[]
labels?: string[]
series: any
height?: number
plotOptions?: any
stroke?: any
}

export function RadialChart({ color, series }: ComponentProps) {
export function RadialChart({ colors, series, labels, height = 160, plotOptions = {}, stroke = {} }: ComponentProps) {
const theme = useTheme()

const chartOptions: ApexOptions = {
Expand All @@ -19,11 +23,12 @@ export function RadialChart({ color, series }: ComponentProps) {
show: false,
},
},
colors: [color],
colors: colors,
fill: {
opacity: 1,
},
labels: [],
stroke: stroke,
labels: labels || [],
plotOptions: {
radialBar: {
dataLabels: {
Expand All @@ -43,11 +48,12 @@ export function RadialChart({ color, series }: ComponentProps) {
background: theme.palette.background.default,
},
},
...plotOptions,
},
theme: {
mode: theme.palette.mode,
},
}

return <Chart height={160} options={chartOptions} series={series} type="radialBar" />
return <Chart height={height} options={chartOptions} series={series} type="radialBar" />
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function RadialChartContainer({ color, series, type, count }: ComponentPr
left={{ md: 20 }}
bottom={{ xs: 15, md: 0 }}
>
<RadialChart color={color} series={series} />
<RadialChart colors={[color]} series={series} />
</Stack>
<Stack
direction="column"
Expand Down
29 changes: 29 additions & 0 deletions pkg/app/src/components/TabPanels/Treasury/modules/asset.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// libs
import { Stack, Paper, Box, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'

interface ComponentProps {
name: string
quantity: number
image: string
}

export function Asset({ name, quantity, image }: ComponentProps) {
const theme = useTheme()

return (
<Stack component={Paper} padding={4} spacing={6} sx={{ boxShadow: 'none', textAlign: 'center' }}>
<Box mb={2}>
<img src={`/svg/coins/${image}.svg`} style={{ margin: 'auto', height: '40px' }} />
</Box>
<Box style={{ marginTop: 0 }}>
<Typography variant="h6">{quantity.toLocaleString()}</Typography>
</Box>
<Box style={{ marginTop: 0 }}>
<Typography variant="caption" sx={{ fontWeight: 'bold', color: theme.palette.text.primary }}>
{name}
</Typography>
</Box>
</Stack>
)
}
40 changes: 40 additions & 0 deletions pkg/app/src/components/TabPanels/Treasury/modules/assets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// libs
import { Grid, Box, Typography } from '@mui/material'
import { useTranslation } from 'react-i18next'
import React, { useState, useMemo, useEffect } from 'react'

// Subscriptions
import { getAssetsSubscription, TreasuryAsset } from '../modules/mock-data'

// modules
import { Asset } from './asset'

interface ComponentProps {
address: string
}

export function Assets({ address }: ComponentProps) {
const { t } = useTranslation()

const [assetsData, setAssetsData] = useState<TreasuryAsset[]>([])

useEffect(() => {
const data = getAssetsSubscription()
setAssetsData(data)
}, [])

return (
<>
<Box py={3}>
<Typography variant="h5">{t('page:organisations:treasury:assets')}</Typography>
</Box>
<Grid container spacing={3}>
{assetsData.map(({ name, quantity, image }) => (
<Grid item xs={3} key={name}>
<Asset name={name} quantity={quantity} image={image}></Asset>
</Grid>
))}
</Grid>
</>
)
}
35 changes: 35 additions & 0 deletions pkg/app/src/components/TabPanels/Treasury/modules/chartLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// libs
import { Grid, Typography, Box } from '@mui/material'
import React from 'react'
import { useTheme } from '@mui/material/styles'

interface ComponentProps {
name: string
color: string
}

export function ChartLabel({ name, color }: ComponentProps) {
const theme = useTheme()

return (
<Grid container>
<Grid item xs={3}>
<Box
sx={{
marginTop: '4px',
backgroundColor: color,
borderRadius: '50%',
width: '15px',
height: '15px',
marginRight: 0,
}}
/>
</Grid>
<Grid item xs={9}>
<Typography variant="caption" sx={{ fontWeight: 'bold', color: theme.palette.text.primary }}>
{name}
</Typography>
</Grid>
</Grid>
)
}
Loading

0 comments on commit 8c46139

Please sign in to comment.