Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pad preview document body instead of iframe element #2

Merged
merged 25 commits into from
Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e074508
remove global styles from padding selector
rbardini Feb 15, 2020
d2b6e05
migrate example from HTML to React
rbardini Feb 15, 2020
e528abd
add `withPaddings` decorator
rbardini Feb 15, 2020
e9813c6
update linting rules
rbardini Feb 15, 2020
0db7784
wrap decorated story with fragment
rbardini Feb 15, 2020
07560fc
use Global component to add styles
rbardini Feb 16, 2020
d7e722f
update README
rbardini Feb 16, 2020
b863faa
type `onUpdate` listener
rbardini Feb 16, 2020
149b189
use global state to keep paddings between stories
rbardini Feb 22, 2020
6612036
only set paddings if addon is not disabled
rbardini Feb 22, 2020
1f2b44a
don't run decorator if no options or params set
rbardini Feb 22, 2020
2404957
convert padding selector to functional compoenent
rbardini Feb 22, 2020
93a5dc7
normalize default selected
rbardini Feb 23, 2020
214c3fc
use useParameter hook
rbardini Feb 23, 2020
cb24c9c
enforce Rules of Hooks
rbardini Feb 23, 2020
abec15f
only emit selected padding value
rbardini Feb 23, 2020
a2e331a
move all types to the top of the file
rbardini Feb 23, 2020
8248363
set initial padding from decorator wrapper
rbardini Feb 23, 2020
84de6b4
pass story as children to decorator wrapper
rbardini Feb 24, 2020
c41a291
use empty string as default padding
rbardini Feb 24, 2020
d05ae7e
add Card story example
rbardini Feb 25, 2020
60014ec
remove preview body margin
rbardini Feb 25, 2020
4076f69
update dependencies
rbardini Feb 29, 2020
6b60f5e
update demo recording
rbardini Feb 29, 2020
0309a6c
install example before linting
rbardini Feb 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
},
"plugins": [
"react",
"react-hooks",
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"import/extensions": ["error", "ignorePackages", { "tsx": "never" }],
"react/jsx-filename-extension": ["error", { "extensions": [".tsx"] }]
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["example/**/*.js"]}],
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".tsx"] }],
"react/prop-types": "off",
"react-hooks/exhaustive-deps": "warn",
"react-hooks/rules-of-hooks": "error"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".tsx"]
"extensions": [".js", ".tsx"]
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: Install
run: npm ci

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

- name: Build
run: npm run build

Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ module.exports = {
}
```

within `.storybook/preview.js`:

```js
import { addDecorator } from '@storybook/react';
import { withPaddings } from 'storybook-addon-paddings';

addDecorator(withPaddings);
```

See [`example`](example) for a minimal working setup.

## Configuration
Expand All @@ -36,7 +45,10 @@ The addon can be configured globally and per story with the `paddings` parameter
To add paddings to all stories, call `addParameters` in `.storybook/preview.js`:

```js
import { addParameters } from '@storybook/html'; // or your Storybook framework
import { addParameters } from '@storybook/react';
import { withPaddings } from 'storybook-addon-paddings';

addDecorator(withPaddings);

addParameters({
paddings: [
Expand Down
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion example/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
addons: ['storybook-addon-paddings'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'storybook-addon-paddings',
],
stories: ['../stories/**/*.stories.js'],
};
3 changes: 3 additions & 0 deletions example/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<style>
body { margin: 0 }
</style>
5 changes: 4 additions & 1 deletion example/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { addParameters } from '@storybook/html';
import { addDecorator, addParameters } from '@storybook/react';
import { withPaddings } from 'storybook-addon-paddings';

addDecorator(withPaddings);

addParameters({
paddings: [
Expand Down
Loading