-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from the-deep/feature/configurable-barchart
Add more configuration options to the bar charts
- Loading branch information
Showing
15 changed files
with
311 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable react/require-default-props */ | ||
import React from 'react'; | ||
import { _cs, isDefined } from '@togglecorp/fujs'; | ||
|
||
import TextNode, { type Props as DefaultTextNodeProps } from '../TextNode'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
type TextNodeProps = Omit<DefaultTextNodeProps, 'as'>; | ||
|
||
export interface Props { | ||
className?: string; | ||
title?: TextNodeProps; | ||
subTitle?: TextNodeProps; | ||
children: React.ReactNode; | ||
chartHeight?: number; | ||
svgClassName?: string; | ||
containerRef?: React.RefObject<HTMLDivElement>; | ||
} | ||
|
||
function BarChartContainer(props: Props) { | ||
const { | ||
className, | ||
title, | ||
subTitle, | ||
children, | ||
chartHeight, | ||
svgClassName, | ||
containerRef, | ||
} = props; | ||
|
||
return ( | ||
<div className={_cs(styles.barChartContainer, className)}> | ||
{isDefined(title) && ( | ||
<TextNode | ||
as="h2" | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...title} | ||
/> | ||
)} | ||
{isDefined(subTitle) && ( | ||
<TextNode | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...subTitle} | ||
/> | ||
)} | ||
<div ref={containerRef}> | ||
<svg | ||
className={_cs(styles.svg, svgClassName)} | ||
style={isDefined(chartHeight) ? { height: `${chartHeight}px}` } : undefined} | ||
> | ||
{children} | ||
</svg> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default BarChartContainer; |
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,6 @@ | ||
.bar-chart-container { | ||
.svg { | ||
width: 100%; | ||
height: 20rem; | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.