Skip to content

Commit d846200

Browse files
committed
chore: improve arguments passing
1 parent f2e3cb7 commit d846200

4 files changed

Lines changed: 104 additions & 87 deletions

File tree

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
11
import React from "react";
22
import { Pattern } from "storybook-django/src/react";
33

4-
const categoryOptions = [
5-
{ label: "All", value: "all" },
6-
{ label: "News", value: "news" },
7-
{ label: "Releases", value: "releases" },
8-
{ label: "Community", value: "community" },
9-
{ label: "Events", value: "events" },
10-
];
11-
124
export default {
135
title: "Components/Post Filter",
146
};
157

16-
export const Default = () => (
8+
export const Default = (args) => (
179
<Pattern
1810
template="v3/includes/_post_filter.html"
19-
context={{
20-
options: categoryOptions,
21-
filter_name: "category",
22-
default: "all",
23-
}}
11+
context={args}
2412
/>
2513
);
14+
Default.args = {
15+
options: [
16+
{ label: "All", value: "all" },
17+
{ label: "News", value: "news" },
18+
{ label: "Releases", value: "releases" },
19+
{ label: "Community", value: "community" },
20+
{ label: "Events", value: "events" },
21+
],
22+
filter_name: "category",
23+
default: "all",
24+
};
2625

27-
export const WithPreselection = () => (
26+
export const WithPreselection = (args) => (
2827
<Pattern
2928
template="v3/includes/_post_filter.html"
30-
context={{
31-
options: categoryOptions,
32-
filter_name: "category",
33-
default: "releases",
34-
}}
29+
context={args}
3530
/>
3631
);
3732
WithPreselection.storyName = "With Pre-selected Option";
33+
WithPreselection.args = {
34+
options: [
35+
{ label: "All", value: "all" },
36+
{ label: "News", value: "news" },
37+
{ label: "Releases", value: "releases" },
38+
{ label: "Community", value: "community" },
39+
{ label: "Events", value: "events" },
40+
],
41+
filter_name: "category",
42+
default: "releases",
43+
};

storybook/components/SearchCard.stories.jsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,27 @@ export default {
1313
export const Default = (args) => (
1414
<Pattern
1515
template="v3/includes/_search_card.html"
16-
context={{
17-
heading: args.heading,
18-
action_url: args.action_url,
19-
placeholder: args.placeholder,
20-
popular_terms: [
21-
{ label: "Networking" },
22-
{ label: "Math" },
23-
{ label: "Data processing" },
24-
{ label: "Concurrency" },
25-
{ label: "File systems" },
26-
{ label: "Testing" },
27-
],
28-
}}
16+
context={args}
2917
/>
3018
);
3119
Default.args = {
3220
heading: "What are you trying to find?",
3321
action_url: "#",
3422
placeholder: "Search libraries, docs, examples",
23+
popular_terms: [
24+
{ label: "Networking" },
25+
{ label: "Math" },
26+
{ label: "Data processing" },
27+
{ label: "Concurrency" },
28+
{ label: "File systems" },
29+
{ label: "Testing" },
30+
],
3531
};
3632

3733
export const WithoutPopularTerms = (args) => (
3834
<Pattern
3935
template="v3/includes/_search_card.html"
40-
context={{
41-
heading: args.heading,
42-
action_url: args.action_url,
43-
}}
36+
context={args}
4437
/>
4538
);
4639
WithoutPopularTerms.args = {

storybook/components/StatsBenchmarks.stories.jsx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,47 @@ export default {
3535
export const Default = (args) => (
3636
<Pattern
3737
template="v3/includes/_stats_benchmarks.html"
38-
context={{
39-
heading: "Performance benchmarks",
40-
sets: sampleSets,
41-
theme: args.theme,
42-
}}
38+
context={args}
4339
/>
4440
);
45-
Default.args = { theme: "default" };
41+
Default.args = {
42+
heading: "Performance benchmarks",
43+
sets: sampleSets,
44+
theme: "default",
45+
};
4646

47-
export const Yellow = () => (
47+
export const Yellow = (args) => (
4848
<Pattern
4949
template="v3/includes/_stats_benchmarks.html"
50-
context={{ heading: "Performance benchmarks", sets: sampleSets, theme: "yellow" }}
50+
context={args}
5151
/>
5252
);
53+
Yellow.args = {
54+
heading: "Performance benchmarks",
55+
sets: sampleSets,
56+
theme: "yellow",
57+
};
5358

54-
export const Green = () => (
59+
export const Green = (args) => (
5560
<Pattern
5661
template="v3/includes/_stats_benchmarks.html"
57-
context={{ heading: "Performance benchmarks", sets: sampleSets, theme: "green" }}
62+
context={args}
5863
/>
5964
);
65+
Green.args = {
66+
heading: "Performance benchmarks",
67+
sets: sampleSets,
68+
theme: "green",
69+
};
6070

61-
export const Teal = () => (
71+
export const Teal = (args) => (
6272
<Pattern
6373
template="v3/includes/_stats_benchmarks.html"
64-
context={{ heading: "Performance benchmarks", sets: sampleSets, theme: "teal" }}
74+
context={args}
6575
/>
6676
);
77+
Teal.args = {
78+
heading: "Performance benchmarks",
79+
sets: sampleSets,
80+
theme: "teal",
81+
};

storybook/components/StatsInNumbers.stories.jsx

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,61 @@ export default {
2727
export const Default = (args) => (
2828
<Pattern
2929
template="v3/includes/_stats_in_numbers.html"
30-
context={{
31-
heading: "Commits per release",
32-
description: "Commit count by Boost release for this library.",
33-
bars: sampleBars,
34-
theme: args.theme,
35-
primary_cta_label: "View library",
36-
primary_cta_url: "#",
37-
}}
30+
context={args}
3831
/>
3932
);
40-
Default.args = { theme: "default" };
33+
Default.args = {
34+
heading: "Commits per release",
35+
description: "Commit count by Boost release for this library.",
36+
theme: "default",
37+
primary_cta_label: "View library",
38+
primary_cta_url: "#",
39+
bars: sampleBars
40+
};
4141

42-
export const Yellow = () => (
42+
export const Yellow = (args) => (
4343
<Pattern
4444
template="v3/includes/_stats_in_numbers.html"
45-
context={{
46-
heading: "Commits per release",
47-
description: "Commit count by Boost release for this library.",
48-
bars: sampleBars,
49-
theme: "yellow",
50-
primary_cta_label: "View library",
51-
primary_cta_url: "#",
52-
}}
45+
context={args}
5346
/>
5447
);
48+
Yellow.args = {
49+
heading: "Commits per release",
50+
description: "Commit count by Boost release for this library.",
51+
theme: "yellow",
52+
primary_cta_label: "View library",
53+
primary_cta_url: "#",
54+
bars: sampleBars
55+
};
5556

56-
export const Green = () => (
57+
export const Green = (args) => (
5758
<Pattern
5859
template="v3/includes/_stats_in_numbers.html"
59-
context={{
60-
heading: "Commits per release",
61-
description: "Commit count by Boost release for this library.",
62-
bars: sampleBars,
63-
theme: "green",
64-
primary_cta_label: "View library",
65-
primary_cta_url: "#",
66-
secondary_cta_label: "View all libraries",
67-
secondary_cta_url: "#",
68-
}}
60+
context={args}
6961
/>
7062
);
63+
Green.args = {
64+
heading: "Commits per release",
65+
description: "Commit count by Boost release for this library.",
66+
theme: "green",
67+
primary_cta_label: "View library",
68+
primary_cta_url: "#",
69+
secondary_cta_label: "View all libraries",
70+
secondary_cta_url: "#",
71+
bars: sampleBars
72+
};
7173

72-
export const Teal = () => (
74+
export const Teal = (args) => (
7375
<Pattern
7476
template="v3/includes/_stats_in_numbers.html"
75-
context={{
76-
heading: "Commits per release",
77-
description: "Commit count by Boost release for this library.",
78-
bars: sampleBars,
79-
theme: "teal",
80-
primary_cta_label: "View library",
81-
primary_cta_url: "#",
82-
}}
77+
context={args}
8378
/>
8479
);
80+
Teal.args = {
81+
heading: "Commits per release",
82+
description: "Commit count by Boost release for this library.",
83+
theme: "teal",
84+
primary_cta_label: "View library",
85+
primary_cta_url: "#",
86+
bars: sampleBars
87+
};

0 commit comments

Comments
 (0)