Skip to content

Commit 7c71d17

Browse files
committed
Add code-snippet story
1 parent 79497f8 commit 7c71d17

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { storiesOf, moduleMetadata } from "@storybook/angular";
2+
import { withKnobs } from "@storybook/addon-knobs/angular";
3+
4+
import { CodeSnippetModule } from "..";
5+
6+
7+
const code = `import { storiesOf, moduleMetadata } from "@storybook/angular";
8+
import { withKnobs, boolean } from "@storybook/addon-knobs/angular";
9+
10+
import { CodeSnippetModule } from "..";
11+
12+
storiesOf("CodeSnippet", module).addDecorator(
13+
moduleMetadata({
14+
imports: [CodeSnippetModule]
15+
})
16+
)
17+
.addDecorator(withKnobs)
18+
.add("Basic", () => ({
19+
template: \`<ibm-code-snippet>code</ibm-code-snippet>\`,
20+
props: { // there's more
21+
// disabled: boolean("disabled", false)
22+
}
23+
}));`;
24+
25+
const lessCode = `import { storiesOf, moduleMetadata } from "@storybook/angular";
26+
import { withKnobs, boolean } from "@storybook/addon-knobs/angular";
27+
28+
import { CodeSnippetModule } from "..";
29+
30+
storiesOf("CodeSnippet", module).addDecorator(
31+
moduleMetadata({
32+
imports: [CodeSnippetModule]
33+
})
34+
) // that's it, no more after this line
35+
`;
36+
37+
const inlineCode = "<inline code>";
38+
39+
storiesOf("CodeSnippet", module).addDecorator(
40+
moduleMetadata({
41+
imports: [CodeSnippetModule]
42+
})
43+
)
44+
.addDecorator(withKnobs)
45+
.add("Basic", () => ({
46+
template: `<ibm-code-snippet display="single">{{code}}</ibm-code-snippet>`,
47+
props: {
48+
code
49+
}
50+
}))
51+
.add("Multi", () => ({
52+
template: `
53+
<h2>With a lot of code</h2>
54+
<ibm-code-snippet display="multi">{{code}}</ibm-code-snippet>
55+
56+
<h2 style="margin-top: 60px">With less code</h2>
57+
<ibm-code-snippet display="multi">{{lessCode}}</ibm-code-snippet>
58+
`,
59+
props: {
60+
code,
61+
lessCode
62+
}
63+
}))
64+
.add("Inline", () => ({
65+
template: `Here is some <ibm-code-snippet display="inline">{{inlineCode}}</ibm-code-snippet> for you.`,
66+
props: {
67+
inlineCode
68+
}
69+
}));

0 commit comments

Comments
 (0)