All files / Bar Bar.stories.tsx

100% Statements 15/15
100% Branches 0/0
100% Functions 4/4
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144                                        1x 1x         1x             1x                       1x     1x 1x         1x             1x                           1x 1x         1x             1x                                                                                         1x     42x              
import _ from 'lodash';
import React from 'react';
import { Story, Meta } from '@storybook/react';
 
import * as chartConstants from '../../constants/charts';
import Bar, { IBarProps } from '../Bar/Bar';
 
export default {
	title: 'Visualizations/Bar',
	component: Bar,
	parameters: {
		docs: {
			description: {
				component: Bar.peek.description,
			},
		},
	},
} as Meta;
 
/* Custom Colors */
export const CustomColors: Story<IBarProps> = (args) => {
	const svgProps = {
		width: 20,
		height: 100,
	};
 
	const pointProps = {
		x: 5,
		y: 0,
		width: 10,
		height: 100,
	};
 
	return (
		<div>
			<svg {...svgProps}>
				<Bar {...args} {...pointProps} color='#f80' />
			</svg>
 
			<svg {...svgProps}>
				<Bar {...args} {...pointProps} color='#abc123' />
			</svg>
		</div>
	);
};
CustomColors.storyName = 'CustomColors';
 
/* Custom Dimension Units */
export const CustomDimensionUnits: Story<IBarProps> = (args) => {
	const svgProps = {
		width: 20,
		height: 100,
	};
 
	const pointProps = {
		x: 5,
		y: 0,
		width: '10%',
		height: '100%',
	};
 
	return (
		<div>
			<svg {...svgProps}>
				<Bar {...args} {...pointProps} color='#f80' />
			</svg>
 
			<svg {...svgProps}>
				<Bar {...args} {...pointProps} color='#abc123' />
			</svg>
		</div>
	);
};
 
/* Regular Colors */
export const RegularColors: Story<IBarProps> = (args) => {
	const svgProps = {
		width: 20,
		height: 100,
	};
 
	const barProps = {
		x: 5,
		y: 0,
		width: 10,
		height: 100,
	};
 
	const colors = [
		chartConstants.COLOR_0_LIGHTEST,
		chartConstants.COLOR_0_LIGHT,
		chartConstants.COLOR_0,
		chartConstants.COLOR_0_DARK,
		chartConstants.COLOR_0_DARKEST,
		chartConstants.COLOR_1_LIGHTEST,
		chartConstants.COLOR_1_LIGHT,
		chartConstants.COLOR_1,
		chartConstants.COLOR_1_DARK,
		chartConstants.COLOR_1_DARKEST,
		chartConstants.COLOR_2_LIGHTEST,
		chartConstants.COLOR_2_LIGHT,
		chartConstants.COLOR_2,
		chartConstants.COLOR_2_DARK,
		chartConstants.COLOR_2_DARKEST,
		chartConstants.COLOR_3_LIGHTEST,
		chartConstants.COLOR_3_LIGHT,
		chartConstants.COLOR_3,
		chartConstants.COLOR_3_DARK,
		chartConstants.COLOR_3_DARKEST,
		chartConstants.COLOR_4_LIGHTEST,
		chartConstants.COLOR_4_LIGHT,
		chartConstants.COLOR_4,
		chartConstants.COLOR_4_DARK,
		chartConstants.COLOR_4_DARKEST,
		chartConstants.COLOR_5_LIGHTEST,
		chartConstants.COLOR_5_LIGHT,
		chartConstants.COLOR_5,
		chartConstants.COLOR_5_DARK,
		chartConstants.COLOR_5_DARKEST,
		chartConstants.COLOR_6_LIGHTEST,
		chartConstants.COLOR_6_LIGHT,
		chartConstants.COLOR_6,
		chartConstants.COLOR_6_DARK,
		chartConstants.COLOR_6_DARKEST,
		chartConstants.COLOR_GOOD_LIGHT,
		chartConstants.COLOR_GOOD,
		chartConstants.COLOR_GOOD_DARK,
		chartConstants.COLOR_BAD_LIGHT,
		chartConstants.COLOR_BAD,
		chartConstants.COLOR_BAD_DARK,
		chartConstants.COLOR_NEUTRAL,
	];
 
	return (
		<div>
			{_.map(colors, (color) => (
				<svg key={color} {...svgProps}>
					<Bar {...args} {...barProps} color={color} />
				</svg>
			))}
		</div>
	);
};