Skip to content

Commit 33484c6

Browse files
authored
fix: storysort (#677)
* first attempt to use sort stories * fix: use compose config to get parameters * fix: test fail * v8.5.4-alpha.0 * fix: update story syntax in examples * fix: some adjustment * fix
1 parent ca7e167 commit 33484c6

File tree

56 files changed

+276
-294
lines changed

Some content is hidden

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

56 files changed

+276
-294
lines changed

examples/expo-example/.storybook/main.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ import { StorybookConfig } from '@storybook/react-native';
33
const main: StorybookConfig = {
44
stories: [
55
'../components/**/*.stories.?(ts|tsx|js|jsx)',
6-
'../../../packages/react-native-ui/**/*.stories.?(ts|tsx|js|jsx)',
6+
'../other_components/**/*.stories.?(ts|tsx|js|jsx)',
77
{
8-
directory: '../other_components',
8+
directory: '../../../packages/react-native-ui',
9+
titlePrefix: 'react-native-ui',
910
files: '**/*.stories.?(ts|tsx|js|jsx)',
10-
titlePrefix: 'OtherComponents',
1111
},
12-
// {
13-
// directory: '../other_components',
14-
// files: '**/*.storiesof.?(ts|tsx|js|jsx)',
15-
// titlePrefix: 'OtherComponents',
16-
// },
17-
// '../components/**/*.storiesof.?(ts|tsx|js|jsx)',
1812
],
1913
addons: [
2014
{ name: '@storybook/addon-ondevice-controls' },

examples/expo-example/.storybook/preview.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const preview: Preview = {
1919
date: /Date$/,
2020
},
2121
},
22+
options: {
23+
storySort: {
24+
method: 'alphabetical',
25+
includeNames: true,
26+
order: ['ControlExamples', ['ControlExample'], 'InteractionExample', 'DeepControls'],
27+
},
28+
},
2229
hideFullScreenButton: false,
2330
noSafeArea: false,
2431
my_param: 'anything',

examples/expo-example/.storybook/storybook.requires.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ const normalizedStories = [
2525
},
2626
{
2727
titlePrefix: "",
28-
directory: "../../packages/react-native-ui",
28+
directory: "./other_components",
2929
files: "**/*.stories.?(ts|tsx|js|jsx)",
3030
importPathMatcher:
3131
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
3232
// @ts-ignore
3333
req: require.context(
34-
"../../../packages/react-native-ui",
34+
"../other_components",
3535
true,
3636
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/
3737
),
3838
},
3939
{
40-
titlePrefix: "OtherComponents",
41-
directory: "./other_components",
40+
titlePrefix: "react-native-ui",
41+
directory: "../../packages/react-native-ui",
4242
files: "**/*.stories.?(ts|tsx|js|jsx)",
4343
importPathMatcher:
4444
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
4545
// @ts-ignore
4646
req: require.context(
47-
"../other_components",
47+
"../../../packages/react-native-ui",
4848
true,
4949
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/
5050
),

examples/expo-example/components/ActionExample/Actions.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { Meta, StoryObj } from '@storybook/react';
33
import { ActionButton } from './Actions';
44

55
const meta = {
6-
title: 'ActionButton',
76
component: ActionButton,
87
argTypes: {
98
onPress: { action: 'pressed' },

examples/expo-example/components/BackgroundExample/BackgroundCsf.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const styles = StyleSheet.create({
1010
});
1111

1212
const meta = {
13-
title: 'BackgroundExample/Background CSF',
1413
component: Background,
1514
parameters: {
1615
backgrounds: {

examples/expo-example/components/ControlExamples/Array/Array.stories.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@ import type { StoryObj, Meta } from '@storybook/react';
22
import { Array } from './Array';
33

44
const meta = {
5-
title: 'ControlExamples/Array control',
65
component: Array,
76
args: {
87
list: ['a', 'b', 'c'],
98
},
109
argTypes: {
1110
list: {
1211
separator: ',',
12+
// @ts-expect-error
1313
control: { type: 'array' },
1414
},
1515
},
1616
parameters: {
17-
notes:
18-
'Seems like the array type is not distinguishable from object so you should provide the arg type in this case',
17+
notes: `
18+
This is actually not a proper control type and should be inferred from the object type but is currently an inconsistency in the rn addon.
19+
`,
1920
},
2021
} satisfies Meta<typeof Array>;
2122

examples/expo-example/components/ControlExamples/Array/Array.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Text, View, StyleSheet } from 'react-native';
32

43
interface ArrayProps {
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import { Switch } from './Boolean';
33

4-
const BooleanExample: Meta<typeof Switch> = {
5-
title: 'ControlExamples/Boolean Control',
4+
const meta = {
65
component: Switch,
7-
};
6+
} satisfies Meta<typeof Switch>;
87

9-
export default BooleanExample;
8+
export default meta;
109

11-
type BooleanStory = StoryObj<typeof Switch>;
10+
type BooleanStory = StoryObj<typeof meta>;
1211

13-
export const Basic: BooleanStory = {};
12+
export const Basic: BooleanStory = {
13+
args: {
14+
on: false,
15+
},
16+
};
1417

1518
export const On: BooleanStory = { args: { on: true } };

examples/expo-example/components/ControlExamples/Color/Color.stories.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import type { StoryObj, Meta } from '@storybook/react';
22
import { Color } from './Color';
33

4-
const ColorMeta: Meta<typeof Color> = {
5-
title: 'ControlExamples/Color control',
4+
const meta = {
65
parameters: { notes: '- test' },
76
argTypes: {
87
color: {
98
control: { type: 'color' },
109
},
1110
},
1211
component: Color,
13-
};
12+
} satisfies Meta<typeof Color>;
1413

15-
export default ColorMeta;
14+
export default meta;
1615

17-
type ColorStory = StoryObj<typeof Color>;
16+
type ColorStory = StoryObj<typeof meta>;
1817

1918
export const ColorExample: ColorStory = {
2019
args: {

examples/expo-example/components/ControlExamples/Color/Color.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { StyleSheet, Text, View } from 'react-native';
32

43
interface ButtonProps {

0 commit comments

Comments
 (0)