Skip to content

Commit

Permalink
feat(deps)!: migrate to Storybook 7.0 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbardini authored Apr 9, 2023
1 parent c1b36bb commit 43fe3f2
Show file tree
Hide file tree
Showing 47 changed files with 8,969 additions and 9,230 deletions.
33 changes: 0 additions & 33 deletions .babelrc.js

This file was deleted.

55 changes: 0 additions & 55 deletions .eslintrc

This file was deleted.

8 changes: 1 addition & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install
run: npm ci

- name: Install example
run: npm i --prefix example

- name: Build
run: npm run build

- name: Lint
run: npm run lint

- name: Format-check
run: npm run format-check

Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dist/
node_modules/
storybook-static/
.DS_Store
.env
.vscode
dist
node_modules
storybook-static
build-storybook.log
7 changes: 0 additions & 7 deletions .lintstagedrc

This file was deleted.

3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*": "prettier --ignore-unknown --write"
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
2 changes: 2 additions & 0 deletions .prettierrc → .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
12 changes: 12 additions & 0 deletions .storybook/local-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function previewAnnotations(entry = []) {
return [...entry, require.resolve('../dist/preview.mjs')]
}

function managerEntries(entry = []) {
return [...entry, require.resolve('../dist/manager.mjs')]
}

module.exports = {
managerEntries,
previewAnnotations,
}
15 changes: 15 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { StorybookConfig } from '@storybook/react-vite'

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['./local-preset.js'],
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
}

export default config
6 changes: 3 additions & 3 deletions example/.storybook/manager.js → .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { addons } from '@storybook/addons';
import { create } from '@storybook/theming/create';
import { addons } from '@storybook/manager-api'
import { create } from '@storybook/theming/create'

addons.setConfig({
theme: create({
base: 'light',
brandTitle: 'Storybook Paddings Addon',
}),
});
})
9 changes: 9 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
layout: 'fullscreen',
},
}

export default preview
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Storybook Paddings Addon

[![npm package version](https://img.shields.io/npm/v/storybook-addon-paddings)](https://www.npmjs.com/package/storybook-addon-paddings)
[![Build status](https://img.shields.io/github/workflow/status/rbardini/storybook-addon-paddings/Main)](https://github.com/rbardini/storybook-addon-paddings/actions)
[![Build status](https://img.shields.io/github/actions/workflow/status/rbardini/storybook-addon-paddings/main.yml)](https://github.com/rbardini/storybook-addon-paddings/actions)
[![Dependencies status](https://img.shields.io/librariesio/release/npm/storybook-addon-paddings)](https://libraries.io/npm/storybook-addon-paddings)

🔲 A [Storybook](https://storybook.js.org) addon to add different paddings to your preview. Useful for checking how components behave when surrounded with white space.
Expand All @@ -16,15 +16,19 @@
npm install --save-dev storybook-addon-paddings
```

within [`.storybook/main.js`](https://storybook.js.org/docs/react/configure/overview#configure-your-storybook-project):

```js
module.exports = {
// .storybook/main.js
export default {
addons: ['storybook-addon-paddings'],
};
```
}

See [`example`](example) for a minimal working setup.
// .storybook/preview.js
export default {
parameters: {
layout: 'fullscreen', // remove default Storybook padding
},
}
```

## Configuration

Expand All @@ -42,7 +46,7 @@ export const parameters = {
],
default: 'Medium',
},
};
}
```

You can also configure on per-story or per-component basis using [parameter inheritance](https://storybook.js.org/docs/react/writing-stories/parameters#component-parameters):
Expand All @@ -53,6 +57,7 @@ You can also configure on per-story or per-component basis using [parameter inhe
// Set padding options for all Button stories
export default {
title: 'Button',
component: Button,
parameters: {
paddings: {
values: [
Expand All @@ -63,11 +68,14 @@ export default {
default: 'Large',
},
},
};
}

// Disable addon in Button/Large story only
export const Large = Template.bind({});
Large.parameters = {
paddings: { disable: true },
};
export const Large {
parameters: {
paddings: { disable: true },
},
}
```

See other [story examples](./src/stories/Card.stories.ts).
10 changes: 0 additions & 10 deletions example/.eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion example/.npmrc

This file was deleted.

8 changes: 0 additions & 8 deletions example/.storybook/main.js

This file was deleted.

22 changes: 0 additions & 22 deletions example/package.json

This file was deleted.

1 change: 0 additions & 1 deletion example/public/_redirects

This file was deleted.

13 changes: 0 additions & 13 deletions example/src/Card.js

This file was deleted.

46 changes: 0 additions & 46 deletions example/src/Card.stories.js

This file was deleted.

1 change: 1 addition & 0 deletions manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/manager'
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
command = "npm i --prefix example && npm run build-example"
publish = "example/storybook-static"
command = "npm i && npm run build && npm run build-storybook"
publish = "storybook-static"
Loading

0 comments on commit 43fe3f2

Please sign in to comment.