Skip to content

Commit

Permalink
feat: nested grouping of stories with "group/story" syntax (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhw committed Jul 14, 2023
1 parent fb0a470 commit ea718f7
Show file tree
Hide file tree
Showing 35 changed files with 1,071 additions and 345 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ built-storybooks
.yarn
!.remarkrc.js
!.babelrc.js
!.eslintrc.js
!.eslintrc-markdown.js
.eslintrc.js
!.jest.config.js
!.storybook
examples/expo-example/metro.config.js
Expand Down
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
root: true,
extends: '@react-native',

// overrides: [...conf.overrides, { files: ['*.ts', '*.tsx'], rules: { 'no-undef': 'off' } }],
rules: {
'react-native/no-inline-styles': 'off',
},
};
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ node_modules
*.log
.idea
*.iml
.vscode/*
!.vscode/launch.json
*.sw*
npm-shrinkwrap.json
dist
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/expo-example/App.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './.storybook/Storybook';
export { default } from './.storybook';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Text } from 'react-native';
// Remember to also include '@storybook/addon-ondevice-backgrounds' in your addons config: see /examples/expo-example/.storybook/main.js
addDecorator(withBackgrounds);

storiesOf('Background StoriesOf', module)
storiesOf('BackgroundExample/Background StoriesOf', module)
.addParameters({
backgrounds: {
default: 'warm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const styles = StyleSheet.create({
});

const BackgroundMeta: ComponentMeta<typeof Background> = {
title: 'Background CSF',
title: 'BackgroundExample/Background CSF',
component: Background,
decorators: [withBackgrounds],
parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { Array } from './Array';
const ArrayMeta: ComponentMeta<typeof Array> = {
title: 'Array control',
title: 'ControlExamples/Array control',
component: Array,
args: {
list: ['a', 'b', 'c'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Switch } from './Boolean';

const BooleanExample: ComponentMeta<typeof Switch> = {
title: 'Boolean Control',
title: 'ControlExamples/Boolean Control',
component: Switch,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { Color } from './Color';

const ColorMeta: ComponentMeta<typeof Color> = {
title: 'Color control',
title: 'ControlExamples/Color control',
parameters: { notes: '- test' },
argTypes: {
color: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentMeta, ComponentStory } from '@storybook/react-native';
import { ControlExample } from './ControlExample';

export default {
title: 'Control Example',
title: 'ControlExamples/Control Example',
component: ControlExample,
args: {
name: 'Storyteller',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DateString } from './Date';
const date = new Date(1983, 1, 25);

const DateMeta: ComponentMeta<typeof DateString> = {
title: 'Date',
title: 'ControlExamples/Date',
component: DateString,
args: { date: date },
argTypes: { date: { control: { type: 'date' } } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { Movie } from './Object';

const ObjectMeta: ComponentMeta<typeof Movie> = {
title: 'Object control',
title: 'ControlExamples/Object control',
component: Movie,
args: {
filmInfo: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Radio } from './Radio';
const radio_stations = ['104.8MHz', '909 kHz', '90FM'];

const RadioMeta: ComponentMeta<typeof Radio> = {
title: 'Radio control',
title: 'ControlExamples/Radio control',
component: Radio,
args: {
selection: radio_stations[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentMeta, ComponentStoryObj } from '@storybook/react';
import { MyButton } from './SelectWithNumber';

export default {
title: 'SelectWithNumber',
title: 'ControlExamples/SelectWithNumber',
component: MyButton,
} as ComponentMeta<typeof MyButton>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SelectExample } from './Select';
const arrows = { ArrowUp: '⬆', ArrowDown: '⬇', ArrowLeft: '⬅️', ArrowRight: '➡️' };

const SelectExampleMeta: ComponentMeta<typeof SelectExample> = {
title: 'Select control',
title: 'ControlExamples/Select control',
component: SelectExample,
argTypes: {
arrow: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { Heading } from './Text';

const TextMeta: ComponentMeta<typeof Heading> = {
title: 'Text control',
title: 'ControlExamples/Text control',
component: Heading,
args: { text: 'Hello world!' },
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Text } from 'react-native';
import React from 'react';

const MyComponent = ({ text }) => <Text>{text}</Text>;

export default {
title: 'NestingExample/Message',
component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

export const MessageFirst: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'Hello',
},
};

export const MessageSecond: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'Message two',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Text } from 'react-native';
import React from 'react';

const MyComponent = ({ text }) => <Text>{text}</Text>;

export default {
title: 'NestingExample/Message/bubble',
component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

export const First: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'First',
},
};

export const Second: ComponentStoryObj<typeof MyComponent> = {
storyName: 'Second Story',
args: {
text: 'Second',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Text } from 'react-native';
import React from 'react';

const MyComponent = ({ text }) => <Text>{text}</Text>;

export default {
title:
'NestingExample/Message/bubble/a very long name for a title that just keeps going and going',
component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

export const First: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'First',
},
};

export const Second: ComponentStoryObj<typeof MyComponent> = {
storyName: 'Second Story',
args: {
text: 'Second',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Text } from 'react-native';
import React from 'react';

const MyComponent = ({ text }) => <Text>{text}</Text>;

export default {
title: 'NestingExample/MessageInput',
component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

export const Basic: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'Hello',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { ComponentMeta, ComponentStoryObj } from '@storybook/react-native';
import { Text } from 'react-native';
import React from 'react';

const MyComponent = ({ text }) => <Text>{text}</Text>;

export default {
title: 'NestingExample/Message/Reactions',
component: MyComponent,
} as ComponentMeta<typeof MyComponent>;

export const MessageOne: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'Hello',
},
};

export const MessageTwo: ComponentStoryObj<typeof MyComponent> = {
args: {
text: 'Message two',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { ComponentMeta, ComponentStoryObj } from '@storybook/react';
import StoryListView from '@storybook/react-native/dist/preview/components/StoryListView/StoryListView';

export default {
title: 'StoryListView',
component: StoryListView,
} as ComponentMeta<typeof StoryListView>;

export const Basic: ComponentStoryObj<typeof StoryListView> = {
args: {
storyIndex: {
stories: {
'chat-message--message-first': {
id: 'chat-message--message-first',
importPath: './components/NestingExample/ChatMessage.stories.tsx',
name: 'Message First',
title: 'Chat/Message',
},
'chat-message--message-second': {
id: 'chat-message--message-second',
importPath: './components/NestingExample/ChatMessage.stories.tsx',
name: 'Message Second',
title: 'Chat/Message',
},
'chat-message-bubble--first': {
id: 'chat-message-bubble--first',
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
name: 'First',
title: 'Chat/Message/bubble',
},
'chat-message-bubble--second': {
id: 'chat-message-bubble--second',
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
name: 'Second Story',
title: 'Chat/Message/bubble',
},
'chat-message-reactions--message-one': {
id: 'chat-message-reactions--message-one',
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
name: 'Message One',
title: 'Chat/Message/Reactions',
},
'chat-message-reactions--message-two': {
id: 'chat-message-reactions--message-two',
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
name: 'Message Two',
title: 'Chat/Message/Reactions',
},
'chat-messageinput--basic': {
id: 'chat-messageinput--basic',
importPath: './components/NestingExample/ChatMessageMessageInput.stories.tsx',
name: 'Basic',
title: 'Chat/MessageInput',
},
'storylistview--basic': {
id: 'storylistview--basic',
importPath: './components/NestingExample/StoryList.stories.tsx',
name: 'Basic',
title: 'StoryListView',
},
'text-control--basic': {
id: 'text-control--basic',
importPath: './components/ControlExamples/Text/Text.stories.tsx',
name: 'Basic',
title: 'Text control',
},
},
v: 3,
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AButton } from './AButton';
import { ScrollView } from 'react-native';

const SafeAreaInsideMeta: ComponentMeta<typeof AButton> = {
title: 'SafeArea Inside',
title: 'SafeAreaExamples/SafeArea Inside',
component: AButton,
argTypes: {
onPress: { action: 'pressed the button' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AButton } from './AButton';
import { ScrollView } from 'react-native';

const SafeAreaOutsideMeta: ComponentMeta<typeof AButton> = {
title: 'SafeArea Outside',
title: 'SafeAreaExamples/SafeArea Outside',
component: AButton,
parameters: { noSafeArea: true },
argTypes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react-native';
import { View, StyleSheet, Text } from 'react-native';

const UsableAreaMeta: ComponentMeta<any> = {
title: 'Usable Area',
title: 'SafeAreaExamples/Usable Area',
};
export default UsableAreaMeta;

Expand Down
2 changes: 1 addition & 1 deletion examples/expo-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"expo": "^48.0.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.3",
"react-native": "0.71.8",
"react-native-safe-area-context": "4.5.0",
"react-native-web": "~0.18.10"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"test": "jest"
},
"jest": {
"modulePathIgnorePatterns": [
"dist/"
],
"moduleFileExtensions": [
"ts",
"tsx",
Expand Down Expand Up @@ -72,6 +75,7 @@
},
"devDependencies": {
"@types/react": "~18.0.27",
"@types/jest": "^29.4.3",
"babel-jest": "^29.4.3",
"jest": "^29.4.3",
"react-test-renderer": "18.2.0"
Expand Down
Loading

0 comments on commit ea718f7

Please sign in to comment.