-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mobile responsive, how-to-human, add more charts, add tooltip icons
- Loading branch information
Showing
23 changed files
with
600 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
packages/apps/escrow-dashboard/src/components/HumanAppData/chart/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { Box, Typography } from '@mui/material'; | ||
import dayjs from 'dayjs'; | ||
import numeral from 'numeral'; | ||
import React from 'react'; | ||
import { | ||
Area, | ||
AreaChart, | ||
CartesianGrid, | ||
ResponsiveContainer, | ||
Tooltip, | ||
XAxis, | ||
YAxis, | ||
} from 'recharts'; | ||
|
||
const CustomTooltip = ({ active, payload, label }: any) => { | ||
if (active && payload && payload.length) { | ||
return ( | ||
<Box | ||
sx={{ | ||
background: '#fff', | ||
border: '1px solid #CBCFE6', | ||
borderRadius: '10px', | ||
padding: '30px', | ||
}} | ||
> | ||
<Typography | ||
color="text.primary" | ||
variant="body2" | ||
fontWeight={600} | ||
mb={2} | ||
> | ||
{dayjs(label).format('MMM D, YYYY')} | ||
</Typography> | ||
{/* <Typography color="text.primary" variant="caption"> | ||
{tab Value} Tasks | ||
</Typography> */} | ||
<Typography color="text.primary" variant="h6" fontWeight={500}> | ||
{numeral(payload[0].value).format('0a').toUpperCase()} | ||
</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const HumanAppDataChart = ({ | ||
data, | ||
minWidth, | ||
minHeight, | ||
}: { | ||
data: any; | ||
minWidth?: number; | ||
minHeight?: number; | ||
}) => { | ||
return ( | ||
<ResponsiveContainer | ||
width="100%" | ||
height="100%" | ||
minWidth={minWidth} | ||
minHeight={minHeight} | ||
> | ||
<AreaChart data={data}> | ||
<defs> | ||
<linearGradient | ||
id="paint0_linear_4037_63345" | ||
x1="257" | ||
y1="0" | ||
x2="257" | ||
y2="276.5" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop offset="0.290598" stopColor="#CACFE8" stopOpacity="0.3" /> | ||
<stop offset="1" stopColor="#E9ECFF" stopOpacity="0" /> | ||
</linearGradient> | ||
</defs> | ||
<CartesianGrid vertical={false} strokeDasharray={3} /> | ||
<XAxis | ||
dataKey="date" | ||
axisLine={false} | ||
tickLine={false} | ||
tick={{ | ||
fill: '#320A8D', | ||
fontSize: '14px', | ||
fontFamily: 'Inter', | ||
fontWeight: 500, | ||
}} | ||
tickFormatter={(value: any) => dayjs(value).format('MMM D')} | ||
tickMargin={12} | ||
padding={{ left: 10, right: 10 }} | ||
/> | ||
<YAxis | ||
axisLine={false} | ||
tickLine={false} | ||
tick={{ | ||
fill: '#320A8D', | ||
fontSize: '14px', | ||
fontFamily: 'Inter', | ||
fontWeight: 500, | ||
}} | ||
tickFormatter={(value: any) => | ||
numeral(value).format('0a').toUpperCase() | ||
} | ||
width={40} | ||
/> | ||
<Tooltip cursor={{ fill: '#dadef0' }} content={<CustomTooltip />} /> | ||
<Area | ||
type="monotone" | ||
dataKey="value" | ||
stroke="#320A8D" | ||
fill="url(#paint0_linear_4037_63345)" | ||
/> | ||
</AreaChart> | ||
</ResponsiveContainer> | ||
); | ||
}; |
150 changes: 150 additions & 0 deletions
150
packages/apps/escrow-dashboard/src/components/HumanAppData/views/Container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; | ||
import { | ||
Box, | ||
Button, | ||
Menu, | ||
MenuItem, | ||
Tab, | ||
Tabs, | ||
Typography, | ||
useMediaQuery, | ||
useTheme, | ||
} from '@mui/material'; | ||
import React, { useState } from 'react'; | ||
|
||
import { HumanAppDataChart } from '../chart'; | ||
|
||
type ChartContainerProps = { | ||
data: any; | ||
title: string; | ||
items: Array<{ label: string; value: any }>; | ||
onChange: (value: any) => void; | ||
}; | ||
|
||
export const ChartContainer = ({ | ||
data, | ||
title, | ||
items, | ||
onChange, | ||
}: ChartContainerProps) => { | ||
const theme = useTheme(); | ||
const isMobile = useMediaQuery(theme.breakpoints.down(600)); | ||
const [tabValue, setTabValue] = useState(items[0].value); | ||
const [menuValue, setMenuValue] = useState(0); | ||
|
||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
const open = Boolean(anchorEl); | ||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
if (isMobile) { | ||
return ( | ||
<Box | ||
sx={{ | ||
borderRadius: '16px', | ||
background: '#FFF', | ||
boxShadow: | ||
'0px 1px 5px 0px rgba(233, 235, 250, 0.20), 0px 2px 2px 0px rgba(233, 235, 250, 0.50), 0px 3px 1px -2px #E9EBFA;', | ||
p: 4, | ||
}} | ||
> | ||
<Typography fontSize={24} color="primary"> | ||
{title} | ||
</Typography> | ||
<Button | ||
color="primary" | ||
size="large" | ||
variant="contained" | ||
endIcon={<KeyboardArrowDownIcon />} | ||
fullWidth | ||
sx={{ my: 3 }} | ||
onClick={handleClick} | ||
> | ||
{items[menuValue].label} | ||
</Button> | ||
<Menu | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'left', | ||
}} | ||
MenuListProps={{ | ||
sx: { width: anchorEl && anchorEl.offsetWidth }, | ||
}} | ||
> | ||
{items.map((item, index) => ( | ||
<MenuItem | ||
key={item.value} | ||
onClick={() => { | ||
setMenuValue(index); | ||
onChange(items[index].value); | ||
handleClose(); | ||
}} | ||
> | ||
{item.label} | ||
</MenuItem> | ||
))} | ||
</Menu> | ||
{data && <HumanAppDataChart data={data} minHeight={250} />} | ||
</Box> | ||
); | ||
} | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
width: '100%', | ||
bgcolor: 'background.paper', | ||
display: 'flex', | ||
}} | ||
> | ||
<Tabs | ||
orientation="vertical" | ||
value={tabValue} | ||
onChange={(e, newValue) => { | ||
setTabValue(newValue); | ||
onChange(newValue); | ||
}} | ||
sx={{ | ||
'& .MuiTabs-indicator': { | ||
width: '100%', | ||
left: 0, | ||
height: '2px !important', | ||
marginTop: '46px', | ||
}, | ||
}} | ||
> | ||
{items.map((item) => ( | ||
<Tab | ||
key={item.value} | ||
label={item.label} | ||
value={item.value} | ||
sx={{ alignItems: 'flex-start' }} | ||
/> | ||
))} | ||
</Tabs> | ||
<Box | ||
sx={{ | ||
flex: 1, | ||
borderRadius: '8px', | ||
background: '#F6F7FE', | ||
py: { xs: 5, md: 10 }, | ||
px: { xs: 2, md: 5 }, | ||
ml: { xs: 4, md: 6, xl: 12 }, | ||
minHeight: 400, | ||
overflowX: 'auto', | ||
}} | ||
> | ||
{data && ( | ||
<HumanAppDataChart data={data} minHeight={300} minWidth={800} /> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.