Skip to content

Commit

Permalink
Added BarChartCompact stories for client-participation, with controls.
Browse files Browse the repository at this point in the history
  • Loading branch information
patcon committed Sep 23, 2024
1 parent a12ca6f commit c43ed40
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions stories/client-participation/BarChartCompact.stories.js
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)',
}
}

0 comments on commit c43ed40

Please sign in to comment.