-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BarChartCompact stories for client-participation, with controls.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 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,43 @@ | ||
import React from 'react' | ||
import BarChartCompact from '../../polis/client-participation/vis2/components/barChartCompact' | ||
import { getMath } from '../../.storybook/utils' | ||
import { svgDecorator } from '../../.storybook/decorators' | ||
import * as globals from '../../polis/client-participation/vis2/components/globals' | ||
|
||
const mathResults = getMath() | ||
|
||
const groupIndexFromName = (groupName) => globals.groupLabels.indexOf(groupName) | ||
|
||
export default { | ||
title: 'Client-Participation/BarChartCompact', | ||
component: BarChartCompact, | ||
decorators: [svgDecorator], | ||
argTypes: { | ||
statement: { | ||
options: ['1: Foo bar', '2: Foo baz'], | ||
control: { type: 'select' }, | ||
}, | ||
group: { | ||
options: ['A', 'B', 'C', 'D'], | ||
control: { type: 'inline-radio' }, | ||
}, | ||
}, | ||
render: ({ statement, group, ...args }) => { | ||
const groupIndex = groupIndexFromName(group) | ||
|
||
Object.assign(args.groupVotes, mathResults['group-votes'][groupIndex]) | ||
return <BarChartCompact {...args} /> | ||
}, | ||
} | ||
|
||
const initialGroup = 'A' | ||
const initialStatement = 4 | ||
export const Default = { | ||
args: { | ||
group: initialGroup, | ||
statement: initialStatement, | ||
selectedComment: { tid: initialStatement }, | ||
groupVotes: mathResults['group-votes'][groupIndexFromName(initialGroup)], | ||
translate: 'translate(0,0)', | ||
} | ||
} |