Skip to content

Commit

Permalink
[Fix #209] Global decorators for stories fixed. Answer stories transf…
Browse files Browse the repository at this point in the history
…ormed to new standard of storybook (CSF3).
  • Loading branch information
VojtechLunak committed Jul 3, 2023
1 parent 2656432 commit 73c4d70
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 39 deletions.
1 change: 0 additions & 1 deletion .storybook/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@luigiminardim/storybook-addon-globals-controls",
"@storybook/addon-a11y",
],
framework: "@storybook/react-webpack5",
Expand Down
4 changes: 3 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const fetchTypeAheadValues = () => {
);
};

export const preview = {
const preview = {
decorators: [
(Story, context) => (
<ConfigurationContextProvider options={options}>
Expand All @@ -128,3 +128,5 @@ export const preview = {
),
],
};

export default preview;
97 changes: 60 additions & 37 deletions src/stories/Answer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import Answer from "../components/Answer";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { preview } from "../../.storybook/preview";
import { Meta, StoryObj } from "@storybook/react";

import question from "./assets/question/questionWithMedia.json";
import questionTypeHead from "./assets/question/questionTypeHead.json";
Expand All @@ -11,57 +10,81 @@ import questionMaskedInput from "./assets/question/questionMaskedInput.json";
import questionSparqlInput from "./assets/question/questionSparqlInput.json";
import questionTurtleInput from "./assets/question/questionTurtleInput.json";

export default {
title: "Components/Answer",
const meta: Meta<typeof Answer> = {
component: Answer,
decorators: preview.decorators,
argTypes: {
onChange: {
table: {
disable: true,
},
},
onCommentChange: {
table: {
disable: true,
},
},
},
};
export default meta;

type Story = StoryObj<typeof Answer>;

const Template: ComponentStory<typeof Answer> = (args) => {
return (
<Answer
{...args}
answer={{}}
onChange={() => {}}
onCommentChange={() => {}}
/>
);
const Template: Story = {
args: {
answer: {},
onChange: () => {},
onCommentChange: () => {},
},
};

export const RegularInput = Template.bind({});
RegularInput.args = {
answer: {
"http://onto.fel.cvut.cz/ontologies/documentation/has_data_value": "",
export const RegularInput: Story = {
args: {
...Template.args,
answer: {
"http://onto.fel.cvut.cz/ontologies/documentation/has_data_value": "",
},
question: question,
},
question: question,
};

export const TypeHead = Template.bind({});
TypeHead.args = {
question: questionTypeHead,
export const TypeHead: Story = {
args: {
...Template.args,
question: questionTypeHead,
},
};

export const DateTimePicker = Template.bind({});
DateTimePicker.args = {
question: questionDate,
export const DateTimePicker: Story = {
args: {
...Template.args,
question: questionDate,
},
};

export const CheckBox = Template.bind({});
CheckBox.args = {
question: questionCheckBox,
export const CheckBox: Story = {
args: {
...Template.args,
question: questionCheckBox,
},
};

export const MaskedInput = Template.bind({});
MaskedInput.args = {
question: questionMaskedInput,
export const MaskedInput: Story = {
args: {
...Template.args,
question: questionMaskedInput,
},
};

export const SparqlInput = Template.bind({});
SparqlInput.args = {
question: questionSparqlInput,
export const SparqlInput: Story = {
args: {
...Template.args,
question: questionSparqlInput,
},
};

export const TurtleInput = Template.bind({});
TurtleInput.args = {
question: questionTurtleInput,
export const TurtleInput: Story = {
args: {
...Template.args,
question: questionTurtleInput,
},
};

0 comments on commit 73c4d70

Please sign in to comment.