Skip to content

Commit 1779421

Browse files
committed
refactor: use consistent pattern to write component stories
1 parent 8b48b51 commit 1779421

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+350
-819
lines changed

.github/workflows/chromatic.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Chromatic
1+
name: 'Chromatic'
22

33
on: workflow_call
44

@@ -13,7 +13,6 @@ permissions:
1313
jobs:
1414
ui:
1515
name: Build UI Library
16-
needs: [changed-files]
1716
environment: 'test'
1817
runs-on: ubuntu-latest
1918
defaults:

packages/go-ui-storybook/eslint.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const appConfigs = compat.config({
2121
'airbnb/hooks',
2222
'plugin:@typescript-eslint/recommended',
2323
'plugin:react-hooks/recommended',
24-
'plugin:import/recommended',
25-
'plugin:storybook/recommended',
2624
],
2725
parser: '@typescript-eslint/parser',
2826
parserOptions: {
@@ -41,7 +39,9 @@ const appConfigs = compat.config({
4139
},
4240
'import/resolver': {
4341
typescript: {
44-
project: './tsconfig.json'
42+
project: [
43+
'./tsconfig.json',
44+
],
4545
},
4646
},
4747
},
@@ -90,7 +90,7 @@ const appConfigs = compat.config({
9090
'react/require-default-props': ['warn', { ignoreFunctionalComponents: true }],
9191
'simple-import-sort/imports': 'warn',
9292
'simple-import-sort/exports': 'warn',
93-
'import-newlines/enforce': ['warn', 1],
93+
'import-newlines/enforce': ['warn', 1]
9494
},
9595
overrides: [
9696
{

packages/go-ui-storybook/src/stories/BlockLoading.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import {
22
BlockLoading as PureBlockLoading,
3-
BlockLoadingProps as PureBlockLoadingProps,
3+
BlockLoadingProps,
44
} from '@ifrc-go/ui';
55

6-
interface BlockloadingProps extends PureBlockLoadingProps {}
7-
8-
function Blockloading(props: BlockloadingProps) {
6+
function Blockloading(props: BlockLoadingProps) {
97
return (
108
// eslint-disable-next-line react/jsx-props-no-spreading
119
<PureBlockLoading {...props} />

packages/go-ui-storybook/src/stories/Blockloading.stories.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const meta = {
2121
} satisfies Meta<typeof BlockLoading>;
2222

2323
export default meta;
24-
type Story = StoryObj<typeof meta>;
24+
type Story = StoryObj<typeof BlockLoading>;
2525

2626
export const Default : Story = {
2727
args: {
@@ -31,14 +31,14 @@ export const Default : Story = {
3131

3232
export const Compact : Story = {
3333
args: {
34-
message: 'Loading...',
34+
...Default.args,
3535
compact: true,
3636
},
3737
};
3838

3939
export const WithoutBorder : Story = {
4040
args: {
41-
message: 'Loading...',
41+
...Default.args,
4242
withoutBorder: true,
4343
},
4444
};

packages/go-ui-storybook/src/stories/BodyOverlay.stories.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/go-ui-storybook/src/stories/BodyOverlay.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/go-ui-storybook/src/stories/BooleanInput.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { BooleanInput } from '@ifrc-go/ui';
21
import { useArgs } from '@storybook/preview-api';
32
import type {
43
Args,
@@ -7,6 +6,8 @@ import type {
76
} from '@storybook/react';
87
import { fn } from '@storybook/test';
98

9+
import BooleanInput from './BooleanInput';
10+
1011
type Story = StoryObj<typeof BooleanInput>;
1112

1213
const meta: Meta<typeof BooleanInput> = {
@@ -57,6 +58,9 @@ function Template(args: Args) {
5758

5859
export const Default: Story = {
5960
render: Template,
61+
args: {
62+
name: 'booleanInput',
63+
},
6064
};
6165

6266
export const Disabled: Story = {

packages/go-ui-storybook/src/stories/BooleanOutput.stories.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import type {
66

77
import BooleanOutput from './BooleanOutput';
88

9-
type BooleanOutputSpecificProps = BooleanOutputProps;
10-
11-
type Story = StoryObj<BooleanOutputSpecificProps>;
9+
type Story = StoryObj<BooleanOutputProps>;
1210

1311
const meta: Meta<typeof BooleanOutput> = {
1412
title: 'Components/BooleanOutput',
@@ -21,47 +19,34 @@ const meta: Meta<typeof BooleanOutput> = {
2119
},
2220
},
2321
tags: ['autodocs'],
24-
decorators: [
25-
function Component(_, ctx) {
26-
const componentArgs = ctx.args as BooleanOutputSpecificProps;
27-
return (
28-
<BooleanOutput
29-
// eslint-disable-next-line react/jsx-props-no-spreading
30-
{...componentArgs}
31-
32-
/>
33-
);
34-
},
35-
],
3622
};
3723

3824
export default meta;
3925

4026
export const Default: Story = {
4127
args: {
42-
className: 'BooleanOutput',
4328
value: true,
4429
},
4530
};
4631

4732
export const TrueValue : Story = {
4833
args: {
49-
className: 'BooleanOutput',
34+
...Default.args,
5035
value: true,
5136
},
5237
};
5338

5439
export const FalseValue :Story = {
5540
args: {
56-
className: 'booleanOutput',
41+
...Default.args,
5742
value: false,
5843
},
5944

6045
};
6146

6247
export const InvalidText: Story = {
6348
args: {
64-
className: 'BooleanOutput',
49+
...Default.args,
6550
invalidText: 'Invalid value',
6651
},
6752
};

packages/go-ui-storybook/src/stories/BooleanOutput.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import {
22
BooleanOutput as PureBooleanOutput,
3-
BooleanOutputProps as PureBooleanOutputProps,
3+
BooleanOutputProps,
44
} from '@ifrc-go/ui';
55

6-
interface BooleanOutputProps extends PureBooleanOutputProps{}
7-
86
function BooleanOutput(props: BooleanOutputProps) {
97
return (
108
<PureBooleanOutput {...props} />// eslint-disable-line react/jsx-props-no-spreading

packages/go-ui-storybook/src/stories/Breadcrumbs.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ export const Default: Story = {
2828
children: ['Home', 'Africa', 'Angola'],
2929
},
3030
};
31+
32+
export const WithSlashSeparator: Story = {
33+
args: {
34+
...Default.args,
35+
separator: '/',
36+
},
37+
};

0 commit comments

Comments
 (0)