From c43ed40b8951713ed94370cf49bd41a7adeefff9 Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Mon, 23 Sep 2024 17:53:28 -0400 Subject: [PATCH] Added BarChartCompact stories for client-participation, with controls. --- .../BarChartCompact.stories.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 stories/client-participation/BarChartCompact.stories.js diff --git a/stories/client-participation/BarChartCompact.stories.js b/stories/client-participation/BarChartCompact.stories.js new file mode 100644 index 0000000..678ad1c --- /dev/null +++ b/stories/client-participation/BarChartCompact.stories.js @@ -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 + }, +} + +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)', + } +}