view_component_storybook 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a494b62b4fd949d616e33e05db2957b077c7f4c6756e154c116688c7de54fbe
4
- data.tar.gz: e09647d265999dec735ea35fc6372f2e2f456d46ee540f9e9137a660a98654d7
3
+ metadata.gz: 75f49d5b86688ebe7d9edbb9233ca05e7bf8f4f96531a305c894be2716a9602f
4
+ data.tar.gz: 943f38d06448e65ea33663617de373d3b3e1e433834225f2d1998a7bb75fa654
5
5
  SHA512:
6
- metadata.gz: 10a4133518f33eaf19f137fd7b079481bcd24ea644e6893e0a2113ebc462535ec18832a9e3e6651b14274372cb8cbd0eb4f4bb3df4174fa1acb0e4006a51c8f6
7
- data.tar.gz: c6e66a11a39b5baf0ddbb26e060cdb453565fcffe9dd592847af0b6d2f078b75819b6b9d80123b25bbe99efdbb07f14fc2860624e1cf01c2b4525a004c7a618d
6
+ metadata.gz: 38cec8aad9a6e3771f50a7e5b2101d56a6fd58944e277300cea97fe74aa8827d2f6ffb6ae1ade78209bb1fb8b39362bc785a062df38dcdee6f25186af4d24f5e
7
+ data.tar.gz: 95cfd875ef6c6fdbfb276ec768629bcf4b83aaeb43a2f5a64316f2e311456f81c55293d888b56c04dd7bfb15ad317f03db66f3e21c6c8a561637b074cf47f7c4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ViewComponent::Storybook
2
2
 
3
- The ViewComponent::Storybook gem provides Ruby api for writing stories describing [View Components](https://github.com/github/view_component) and allowing them to be previewed and tested in [Storybook](https://github.com/storybookjs/storybook/)
3
+ The ViewComponent::Storybook gem provides Ruby api for writing stories describing [View Components](https://github.com/github/view_component) and allowing them to be previewed and tested in [Storybook](https://github.com/storybookjs/storybook/)
4
4
 
5
5
  ## Features
6
6
  * A Ruby DSL for writing Stories describing View Components
@@ -9,11 +9,11 @@ The ViewComponent::Storybook gem provides Ruby api for writing stories describin
9
9
 
10
10
  ## Installation
11
11
 
12
- ### Gem Installation
12
+ ### Gem Installation
13
13
 
14
14
  1. Add the `view_component_storybook` gem, to your Gemfile: `gem 'view_component_storybook'`
15
15
  2. Run `bundle install`.
16
- 3. Add `require "view_component_storybook/engine"` to `config/application.rb`
16
+ 3. Add `require "view_component/storybook/engine"` to `config/application.rb`
17
17
  4. Add `**/*.stories.json` to `.gitignore`
18
18
 
19
19
  ### Storybook Installation
@@ -29,7 +29,7 @@ The ViewComponent::Storybook gem provides Ruby api for writing stories describin
29
29
  "storybook": "start-storybook"
30
30
  }
31
31
  }
32
- ```
32
+ ```
33
33
  3. Create the .storybook/main.js file to configure Storybook to find the json stories the gem creates. Also configure the Controls addon:
34
34
  ```javascript
35
35
  module.exports = {
@@ -48,7 +48,7 @@ The ViewComponent::Storybook gem provides Ruby api for writing stories describin
48
48
  },
49
49
  };
50
50
  ```
51
-
51
+
52
52
 
53
53
  Note: `@storybook/server` will be part of the upcoming Storybook 6.0 release. Until that is released you'll need to use an [rc release](https://github.com/storybookjs/storybook/releases/tag/v6.0.0-rc.14)
54
54
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "active_model"
4
4
  require "active_support/dependencies/autoload"
5
- require "view_component/storybook/engine"
6
5
 
7
6
  module ViewComponent
8
7
  module Storybook
@@ -4,13 +4,28 @@ module ViewComponent
4
4
  module Storybook
5
5
  module Controls
6
6
  class OptionsConfig < ControlConfig
7
+
8
+ class << self
9
+ # support the options being a Hash or an Array. Storybook supports either.
10
+ def inclusion_in(config)
11
+ case config.options
12
+ when Hash
13
+ config.options.values
14
+ when Array
15
+ config.options
16
+ else
17
+ []
18
+ end
19
+ end
20
+ end
21
+
7
22
  TYPES = %i[select multi-select radio inline-radio check inline-check].freeze
8
23
 
9
24
  attr_reader :type, :options
10
25
 
11
26
  validates :value, :type, :options, presence: true
12
27
  validates :type, inclusion: { in: TYPES }, unless: -> { type.nil? }
13
- validates :value, inclusion: { in: ->(config) { config.options.values } }, unless: -> { options.nil? || value.nil? }
28
+ validates :value, inclusion: { in: method(:inclusion_in) }, unless: -> { options.nil? || value.nil? }
14
29
 
15
30
  def initialize(type, component, param, options, default_value, name: nil)
16
31
  super(component, param, default_value, name: name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ViewComponent
4
4
  module Storybook
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_storybook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: view_component