Skip to content

Commit

Permalink
Add initialRule arg for stories
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Oct 16, 2023
1 parent b84284e commit 39cd54c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/stories/VtlEditor.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ export default {
tags: ["autodocs"]
};

export const Default = {};
export const Default = {
args: { initialRule: "start" },
argTypes: {
initialRule: { control: "select", options: ["start", "expr"] }
}
};

export const Styled = {
args: {
initialRule: "start",
theme: "vs-dark",
height: "50vh",
width: "80%",
options: { lineNumbers: true, minimap: { enabled: true }, readOnly: false }
},
argTypes: {
initialRule: { control: "select", options: ["start", "expr"] },
theme: { control: "select", options: ["vs-dark", "vs-light"] },
options: { control: "object" }
}
Expand All @@ -41,13 +48,15 @@ const variables = {

export const Enriched = {
args: {
initialRule: "start",
variables,
variablesInputURLs: [
"https://raw.githubusercontent.com/Making-Sense-Info/ANTLR-Editor/gh-pages/samples/variablesInputFile1.json",
"https://raw.githubusercontent.com/Making-Sense-Info/ANTLR-Editor/gh-pages/samples/variablesInputFile2.json"
]
},
argTypes: {
initialRule: { control: "select", options: ["start", "expr"] },
variables: { control: "object" },
variablesInputURLs: { control: "object" }
}
Expand Down
6 changes: 5 additions & 1 deletion src/stories/VtlEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { getSuggestionsFromRange, monarchDefinition } from "./vtl-monaco";

const customTools = { ...tools, getSuggestionsFromRange, monarchDefinition };

const EditorForStories = (props: any) => <Editor {...props} tools={customTools} />;
const EditorForStories = (props: any) => {
const { initialRule = "start" } = props;
console.log(initialRule);
return <Editor {...props} tools={{ ...customTools, initialRule }} />;
};

export default EditorForStories;

0 comments on commit 39cd54c

Please sign in to comment.