view_component_storybook 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/view_component/storybook/controls/array_config.rb +1 -1
- data/lib/view_component/storybook/controls/boolean_config.rb +1 -1
- data/lib/view_component/storybook/controls/color_config.rb +0 -1
- data/lib/view_component/storybook/controls/control_config.rb +15 -3
- data/lib/view_component/storybook/controls/date_config.rb +0 -2
- data/lib/view_component/storybook/controls/number_config.rb +4 -1
- data/lib/view_component/storybook/controls/object_config.rb +1 -3
- data/lib/view_component/storybook/controls/options_config.rb +1 -4
- data/lib/view_component/storybook/controls/text_config.rb +0 -2
- data/lib/view_component/storybook/dsl/controls_dsl.rb +1 -1
- data/lib/view_component/storybook/stories.rb +1 -7
- data/lib/view_component/storybook/version.rb +1 -1
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8c8a3875d64fe89649af8851324d2a07bd40868065abce8b57cf848cbeb5d3
|
4
|
+
data.tar.gz: 554f43665400373ba30b9bc6e307285843b67d3760e5957e0088fa2ba53b325e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398124fee399213bea34acf3aef434877eb01d0c76d9d6f127f5d5493981ecf5ac1f0ddc94ad9850354f6ec3629f1a9e5ca6005b57208abd39d045026415abbd
|
7
|
+
data.tar.gz: 31a4a06293f40d19e575243a61cb61e1cff2bd7646da950c01de20f8edd73d1179970a7700064a8ee15cbcd3a73b2060f525bdbf427baeaddc9f9bd9ee6b7ebe
|
@@ -6,7 +6,7 @@ module ViewComponent
|
|
6
6
|
class ArrayConfig < ControlConfig
|
7
7
|
attr_reader :separator
|
8
8
|
|
9
|
-
validates :
|
9
|
+
validates :separator, presence: true
|
10
10
|
|
11
11
|
def initialize(component, param, value, separator = ",", name: nil)
|
12
12
|
super(component, param, value, name: name)
|
@@ -9,7 +9,7 @@ module ViewComponent
|
|
9
9
|
attr_reader :component, :param, :value, :name
|
10
10
|
|
11
11
|
validates :component, :param, presence: true
|
12
|
-
validates :param, inclusion: { in: ->(control_config) { control_config.
|
12
|
+
validates :param, inclusion: { in: ->(control_config) { control_config.component_param_names } }, if: :should_validate_params?
|
13
13
|
|
14
14
|
def initialize(component, param, value, name: nil)
|
15
15
|
@component = component
|
@@ -30,8 +30,8 @@ module ViewComponent
|
|
30
30
|
param
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
@
|
33
|
+
def component_param_names
|
34
|
+
@component_param_names ||= component_params&.map(&:last)
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
@@ -44,6 +44,18 @@ module ViewComponent
|
|
44
44
|
def csf_control_params
|
45
45
|
{ type: type }
|
46
46
|
end
|
47
|
+
|
48
|
+
def component_accepts_kwargs?
|
49
|
+
component_params.map(&:first).include?(:keyrest)
|
50
|
+
end
|
51
|
+
|
52
|
+
def component_params
|
53
|
+
@component_params ||= component.instance_method(:initialize).parameters
|
54
|
+
end
|
55
|
+
|
56
|
+
def should_validate_params?
|
57
|
+
component.present? && !component_accepts_kwargs?
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
@@ -4,9 +4,12 @@ module ViewComponent
|
|
4
4
|
module Storybook
|
5
5
|
module Controls
|
6
6
|
class NumberConfig < ControlConfig
|
7
|
+
TYPES = %i[number range].freeze
|
8
|
+
|
7
9
|
attr_reader :type, :min, :max, :step
|
8
10
|
|
9
|
-
validates :
|
11
|
+
validates :type, presence: true
|
12
|
+
validates :type, inclusion: { in: TYPES }, unless: -> { type.nil? }
|
10
13
|
|
11
14
|
def initialize(type, component, param, value, min: nil, max: nil, step: nil, name: nil)
|
12
15
|
super(component, param, value, name: name)
|
@@ -4,15 +4,13 @@ module ViewComponent
|
|
4
4
|
module Storybook
|
5
5
|
module Controls
|
6
6
|
class ObjectConfig < ControlConfig
|
7
|
-
validates :value, presence: true
|
8
|
-
|
9
7
|
def type
|
10
8
|
:object
|
11
9
|
end
|
12
10
|
|
13
11
|
def value_from_param(param)
|
14
12
|
if param.is_a?(String)
|
15
|
-
JSON.parse(param).
|
13
|
+
JSON.parse(param).deep_symbolize_keys
|
16
14
|
else
|
17
15
|
super(param)
|
18
16
|
end
|
@@ -4,7 +4,6 @@ module ViewComponent
|
|
4
4
|
module Storybook
|
5
5
|
module Controls
|
6
6
|
class OptionsConfig < ControlConfig
|
7
|
-
|
8
7
|
class << self
|
9
8
|
# support the options being a Hash or an Array. Storybook supports either.
|
10
9
|
def inclusion_in(config)
|
@@ -13,8 +12,6 @@ module ViewComponent
|
|
13
12
|
config.options.values
|
14
13
|
when Array
|
15
14
|
config.options
|
16
|
-
else
|
17
|
-
[]
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -23,7 +20,7 @@ module ViewComponent
|
|
23
20
|
|
24
21
|
attr_reader :type, :options, :symbol_value
|
25
22
|
|
26
|
-
validates :
|
23
|
+
validates :type, :options, presence: true
|
27
24
|
validates :type, inclusion: { in: TYPES }, unless: -> { type.nil? }
|
28
25
|
validates :value, inclusion: { in: method(:inclusion_in) }, unless: -> { options.nil? || value.nil? }
|
29
26
|
|
@@ -33,7 +33,7 @@ module ViewComponent
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def write_csf_json
|
36
|
-
json_path = File.join(
|
36
|
+
json_path = File.join(stories_path, "#{stories_name}.stories.json")
|
37
37
|
File.open(json_path, "w") do |f|
|
38
38
|
f.write(JSON.pretty_generate(to_csf_params))
|
39
39
|
end
|
@@ -81,8 +81,6 @@ module ViewComponent
|
|
81
81
|
|
82
82
|
def default_component
|
83
83
|
name.chomp("Stories").constantize
|
84
|
-
rescue StandardError
|
85
|
-
nil
|
86
84
|
end
|
87
85
|
|
88
86
|
def load_stories
|
@@ -93,10 +91,6 @@ module ViewComponent
|
|
93
91
|
Storybook.stories_path
|
94
92
|
end
|
95
93
|
|
96
|
-
def show_stories
|
97
|
-
Storybook.show_stories
|
98
|
-
end
|
99
|
-
|
100
94
|
def story_id(name)
|
101
95
|
"#{stories_name}/#{name.to_s.parameterize}".underscore
|
102
96
|
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
|
+
version: 0.8.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:
|
11
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: view_component
|
@@ -100,42 +100,42 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '1.9'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '1.9'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop-rails
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.9.1
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.
|
124
|
+
version: 2.9.1
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1
|
131
|
+
version: '2.1'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '1
|
138
|
+
version: '2.1'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.18.5
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov-console
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.9'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.9'
|
153
167
|
description: Generate Storybook CSF JSON for rendering Rails View Components in Storybook
|
154
168
|
email:
|
155
169
|
- 328224+jonspalmer@users.noreply.github.com
|
@@ -195,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
209
|
requirements:
|
196
210
|
- - ">="
|
197
211
|
- !ruby/object:Gem::Version
|
198
|
-
version: 2.
|
212
|
+
version: 2.4.0
|
199
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
214
|
requirements:
|
201
215
|
- - ">="
|