storybook_rails 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -0
- data/README.md +33 -2
- data/app/controllers/action_view/storybook/stories_controller.rb +1 -1
- data/lib/action_view/storybook/helpers/story_params.rb +3 -1
- data/lib/action_view/storybook/stories.rb +5 -5
- data/lib/action_view/storybook/story_config.rb +7 -11
- data/lib/action_view/storybook/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9e73c7b0bf6d8f82291a937ef7d37f74621b5e1803d561a7396829ca4f61c3
|
4
|
+
data.tar.gz: ce0f60e3dd44c77e3678287d74ac340b3d5dd3233b1f7d52e31f083d734acb8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a7b37fc8c986e55f9926c307e8966b40cc855f0174f2cf9c9fd7b4e2458abe3b634471edcfc007b85b1822f4ca2a231e149cfe995228fa499a7a280f54794b7
|
7
|
+
data.tar.gz: 8f6e2d0188d83131473477881735d314c3f118f3dbe08c6028e5650fe4b58e6b9b804b0df66d3f022043a1f262a5deb5d43e92d2c5db26ff09ed0cfc2340c772
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ This gem is a fork of [ViewComponent::Storybook](https://github.com/jonspalmer/v
|
|
22
22
|
#### Configure Asset Hosts
|
23
23
|
|
24
24
|
If your views depend on Javascript, CSS or other assets served by the Rails application you will need to configure `asset_hosts`
|
25
|
-
|
25
|
+
appropriately for your various environments. For local development, do this by adding the following to `config/development.rb`:
|
26
26
|
```ruby
|
27
27
|
Rails.application.configure do
|
28
28
|
...
|
@@ -65,7 +65,7 @@ Equivalent configuration will be necessary in `config/production.rb` or `applica
|
|
65
65
|
};
|
66
66
|
```
|
67
67
|
|
68
|
-
|
68
|
+
### Webpacker
|
69
69
|
If your application uses Webpacker to compile your JavaScript and/or CSS, you will need to modify the default Storybook webpack configuration. Please see the [Storybook Webpack config](https://storybook.js.org/docs/react/configure/webpack) for more information on how to do that. Here's an example:
|
70
70
|
|
71
71
|
```javascript
|
@@ -105,6 +105,26 @@ module.exports = {
|
|
105
105
|
};
|
106
106
|
```
|
107
107
|
|
108
|
+
### Optional Nice-To-Haves
|
109
|
+
#### Setup File-Watching and Automatically run `rake storybook_rails:write_stories_json`
|
110
|
+
For a better developer experience, install your favorite file watching utility, such as [chokidar](https://github.com/kimmobrunfeldt/chokidar-cli) and add a couple scripts to enable automatic regeneration of `*.stories.json` files when you update `*_stories.rb` files:
|
111
|
+
|
112
|
+
`yarn add -D chokidar-cli`
|
113
|
+
|
114
|
+
In package.json:
|
115
|
+
```js
|
116
|
+
{
|
117
|
+
...
|
118
|
+
"scripts": {
|
119
|
+
"storybook:start": "rm -rf node_modules/.cache/storybook && start-storybook",
|
120
|
+
"storybook:write-json": "bundle exec rake storybook_rails:write_stories_json",
|
121
|
+
"storybook:watch": "chokidar '**/*_stories.rb' -c 'yarn storybook:write-json'"
|
122
|
+
},
|
123
|
+
...
|
124
|
+
}
|
125
|
+
```
|
126
|
+
|
127
|
+
|
108
128
|
## Usage
|
109
129
|
|
110
130
|
### Writing Stories
|
@@ -195,6 +215,17 @@ By Default `storybook_rails` expects to find stories in the folder `test/compone
|
|
195
215
|
config.storybook_rails.stories_path = Rails.root.join("spec/components/stories")
|
196
216
|
```
|
197
217
|
|
218
|
+
### Troubleshooting
|
219
|
+
#### Restarting Storybook Fails
|
220
|
+
If Storybook fails to load with a `cannot get /` error, it could be related to [this issue](https://github.com/storybookjs/storybook/issues/14152). As a workaround, you can update the `yarn storybook` script to remove the `node_modules/.cache/storybook` files before Storybook starts:
|
221
|
+
```json
|
222
|
+
{
|
223
|
+
"scripts": {
|
224
|
+
"storybook": "rm -rf node_modules/.cache/storybook && start-storybook"
|
225
|
+
}
|
226
|
+
}
|
227
|
+
```
|
228
|
+
|
198
229
|
### The Story DSL
|
199
230
|
|
200
231
|
Coming Soon
|
@@ -18,7 +18,7 @@ module ActionView
|
|
18
18
|
story_params = @story.values_from_params(params.permit!.to_h)
|
19
19
|
story_params.deep_merge!(story_name: params[:story_name])
|
20
20
|
|
21
|
-
render template:
|
21
|
+
render template: @story.template.to_s, layout: @story.layout, locals: { story_params: story_params }
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -97,14 +97,14 @@ module ActionView
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def default_template
|
100
|
-
"#{name.chomp(
|
100
|
+
"#{name.chomp('Stories').underscore}_stories"
|
101
101
|
end
|
102
102
|
|
103
103
|
def load_stories
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
return unless stories_path
|
105
|
+
|
106
|
+
Dir["#{stories_path}/**/*_stories.rb"].sort.each do |file|
|
107
|
+
require_dependency file
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -20,15 +20,15 @@ module ActionView
|
|
20
20
|
|
21
21
|
def to_csf_params
|
22
22
|
validate!
|
23
|
-
csf_params = {
|
23
|
+
csf_params = {
|
24
24
|
name: pretty_name(name),
|
25
|
-
parameters: {
|
26
|
-
server: {
|
25
|
+
parameters: {
|
26
|
+
server: {
|
27
27
|
id: id,
|
28
|
-
params: {
|
29
|
-
story_name: name
|
30
|
-
}
|
31
|
-
}
|
28
|
+
params: {
|
29
|
+
story_name: name
|
30
|
+
}
|
31
|
+
}
|
32
32
|
}
|
33
33
|
}
|
34
34
|
csf_params.deep_merge!(parameters: parameters) if parameters.present?
|
@@ -59,10 +59,6 @@ module ActionView
|
|
59
59
|
protected
|
60
60
|
|
61
61
|
def valid_controls
|
62
|
-
controls.reject(&:valid?).each do |control|
|
63
|
-
errors.add(:controls, :invalid, value: control)
|
64
|
-
end
|
65
|
-
|
66
62
|
control_names = controls.map(&:name)
|
67
63
|
duplicate_names = control_names.group_by(&:itself).map { |k, v| k if v.length > 1 }.compact
|
68
64
|
return if duplicate_names.empty?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storybook_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pence
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|