Skip to content

Commit

Permalink
[New #170] Add wizard story
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Dec 13, 2022
1 parent 86a275f commit 27089a0
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
94 changes: 94 additions & 0 deletions src/stories/Wizard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React from "react";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import DefaultInput from "../components/DefaultInput";
import Wizard from "../components/wizard/Wizard";
import { FormQuestionsContext } from "../contexts/FormQuestionsContext";
import { ConfigurationContext } from "../contexts/ConfigurationContext";

import wizardForm from "./assets/form/wizardForm.json";
import Constants from "../constants/Constants";

export default {
title: "Components/Wizard",
component: Wizard,
} as ComponentMeta<typeof Wizard>;

const Template: ComponentStory<typeof Wizard> = (
args,
{ globals: { iconBehavior, locale, debugMode, horizontalNavBar } }
) => {
const inputComponent = DefaultInput;
const componentsOptions = {
readOnly: false,
dateTimeAnswer: {
dateFormat: "yyyy-MM-dd",
timeFormat: "HH:mm:ss",
dateTimeFormat: "yyyy-MM-dd HH:mm:ss",
},
};
const options = {
i18n: {
"wizard.next": "Next",
"wizard.previous": "Previous",
"section.expand": "Expand",
"section.collapse": "Collapse",
},
intl: {
locale: locale,
},
modalView: false,
horizontalWizardNav: horizontalNavBar,
wizardStepButtons: true,
enableForwardSkip: true,
startingStep: 1,
debugMode: debugMode,
users: [
{ id: "http://fel.cvut.cz/people/max-chopart", label: "Max Chopart" },
{
id: "http://fel.cvut.cz/people/miroslav-blasko",
label: "Miroslav Blasko",
},
],
currentUser: "http://fel.cvut.cz/people/max-chopart",
icons: [
{
id: Constants.ICONS.QUESTION_HELP,
behavior: iconBehavior,
},
{
id: Constants.ICONS.QUESTION_LINK,
behavior: iconBehavior,
},
{
id: Constants.ICONS.QUESTION_COMMENTS,
behavior: iconBehavior,
},
],
};

const getFormQuestionsData = () => {
return wizardForm;
};
const _getComponentMappingFunction = () => {
return (question: any, defaultComponent: any) => {
return defaultComponent;
};
};
const mapComponent = _getComponentMappingFunction();
return (
<ConfigurationContext.Provider
value={{
componentsOptions,
inputComponent,
mapComponent,
options,
}}
>
<FormQuestionsContext.Provider value={{ getFormQuestionsData }}>
<Wizard />
</FormQuestionsContext.Provider>
</ConfigurationContext.Provider>
);
};

export const Default = Template.bind({});
1 change: 1 addition & 0 deletions src/stories/assets/form/wizardForm.json

Large diffs are not rendered by default.

0 comments on commit 27089a0

Please sign in to comment.