-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Develop bar graph in Dashboard (#157)
- Loading branch information
Showing
8 changed files
with
181 additions
and
4 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/web/src/components/dashboard/volume-chart-graph/VolumeChartGraph.spec.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,21 @@ | ||
import { render } from "@testing-library/react"; | ||
import { Provider as JotaiProvider } from "jotai"; | ||
import GnoswapThemeProvider from "@providers/gnoswap-theme-provider/GnoswapThemeProvider"; | ||
import VolumeChartGraph, { VolumeChartGraphProps } from "./VolumeChartGraph"; | ||
|
||
describe('VolumeChartGraph Component', () => { | ||
it('VolumeChartGraph render', () => { | ||
const args: VolumeChartGraphProps = { | ||
datas: [], | ||
xAxisLabels: [], | ||
}; | ||
|
||
render( | ||
<JotaiProvider> | ||
<GnoswapThemeProvider> | ||
<VolumeChartGraph {...args} /> | ||
</GnoswapThemeProvider> | ||
</JotaiProvider>, | ||
); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/web/src/components/dashboard/volume-chart-graph/VolumeChartGraph.stories.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,14 @@ | ||
import VolumeChartGraph, { type VolumeChartGraphProps } from "./VolumeChartGraph"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
export default { | ||
title: "dashboard/VolumeChartGraph", | ||
component: VolumeChartGraph, | ||
} as Meta<typeof VolumeChartGraph>; | ||
|
||
export const Default: StoryObj<VolumeChartGraphProps> = { | ||
args: { | ||
datas: Array.from({ length: 24 }, (_, index) => `${index + 1}`), | ||
xAxisLabels: ["09:00", "12:00", "15:00", "18:00", "21:00", "24:00"], | ||
}, | ||
}; |
40 changes: 40 additions & 0 deletions
40
packages/web/src/components/dashboard/volume-chart-graph/VolumeChartGraph.styles.ts
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,40 @@ | ||
import styled from "@emotion/styled"; | ||
import { fonts } from "@constants/font.constant"; | ||
|
||
export const VolumeChartGraphWrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
width: 100%; | ||
height: 100%; | ||
background-color: ${({ theme }) => theme.color.background01}; | ||
border-radius: 8px; | ||
justify-content: space-between; | ||
padding: 24px 24px 23px 24px; | ||
.data-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
max-width: 755px; | ||
.graph { | ||
border: 1px solid ${({ theme }) => theme.color.border02}; | ||
} | ||
.xaxis-wrapper { | ||
display: flex; | ||
flex-direction: row; | ||
width: 100%; | ||
height: 17px; | ||
margin-top: 16px; | ||
justify-content: space-between; | ||
${fonts.body12}; | ||
color: ${({ theme }) => theme.color.text04}; | ||
span { | ||
${fonts.body12}; | ||
color: ${({ theme }) => theme.color.text04}; | ||
} | ||
} | ||
} | ||
`; |
38 changes: 38 additions & 0 deletions
38
packages/web/src/components/dashboard/volume-chart-graph/VolumeChartGraph.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,38 @@ | ||
import BarGraph from "@components/common/bar-graph/BarGraph"; | ||
import { useTheme } from "@emotion/react"; | ||
import React from "react"; | ||
import { VolumeChartGraphWrapper } from "./VolumeChartGraph.styles"; | ||
|
||
export interface VolumeChartGraphProps { | ||
datas: string[]; | ||
xAxisLabels: string[]; | ||
} | ||
|
||
const VolumeChartGraph: React.FC<VolumeChartGraphProps> = ({ | ||
datas, | ||
xAxisLabels | ||
}) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<VolumeChartGraphWrapper> | ||
<div className="data-wrapper"> | ||
<BarGraph | ||
className="graph" | ||
width={570} | ||
height={180} | ||
color={theme.color.background04Hover} | ||
hoverColor={theme.color.point} | ||
strokeWidth={12.5} | ||
datas={datas} | ||
/> | ||
<div className="xaxis-wrapper"> | ||
{xAxisLabels.map((label, index) => | ||
<span key={index} className="label">{label}</span>)} | ||
</div> | ||
</div> | ||
</VolumeChartGraphWrapper> | ||
); | ||
}; | ||
|
||
export default VolumeChartGraph; |
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
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