Module: ViewComponent::Storybook::Controls::ControlsHelpers
- Included in:
- StoryConfig
- Defined in:
- lib/view_component/storybook/controls/controls_helpers.rb
Instance Method Summary collapse
- #array(default_value, separator = nil) ⇒ Object
- #boolean(default_value) ⇒ Object
- #check(options, default_value, labels: nil) ⇒ Object
- #color(default_value, preset_colors: nil) ⇒ Object
- #custom(*args, **kwargs, &block) ⇒ Object
- #date(default_value) ⇒ Object
- #inline_check(options, default_value) ⇒ Object
- #inline_radio(options, default_value, labels: nil) ⇒ Object
- #klazz(value_class, *args, **kwargs) ⇒ Object
- #multi_select(options, default_value, labels: nil) ⇒ Object
- #number(default_value, min: nil, max: nil, step: nil) ⇒ Object
- #object(default_value) ⇒ Object
- #radio(options, default_value, labels: nil) ⇒ Object
- #range(default_value, min: nil, max: nil, step: nil) ⇒ Object
- #select(options, default_value, labels: nil) ⇒ Object
- #text(default_value) ⇒ Object
Instance Method Details
#array(default_value, separator = nil) ⇒ Object
55 56 57 58 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 55 def array(default_value, separator = nil) ActiveSupport::Deprecation.warn("`array` `separator` argument will be removed in v1.0.0.") if separator Controls::ObjectConfig.new(default_value) end |
#boolean(default_value) ⇒ Object
11 12 13 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 11 def boolean(default_value) Controls::BooleanConfig.new(default_value) end |
#check(options, default_value, labels: nil) ⇒ Object
47 48 49 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 47 def check(, default_value, labels: nil) Controls::MultiOptionsConfig.new(:check, , default_value, labels: labels) end |
#color(default_value, preset_colors: nil) ⇒ Object
23 24 25 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 23 def color(default_value, preset_colors: nil) Controls::ColorConfig.new(default_value, preset_colors: preset_colors) end |
#custom(*args, **kwargs, &block) ⇒ Object
64 65 66 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 64 def custom(*args, **kwargs, &block) Controls::CustomConfig.new.with_value(*args, **kwargs, &block) end |
#date(default_value) ⇒ Object
60 61 62 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 60 def date(default_value) Controls::DateConfig.new(default_value) end |
#inline_check(options, default_value) ⇒ Object
51 52 53 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 51 def inline_check(, default_value) Controls::MultiOptionsConfig.new(:'inline-check', , default_value) end |
#inline_radio(options, default_value, labels: nil) ⇒ Object
43 44 45 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 43 def inline_radio(, default_value, labels: nil) Controls::OptionsConfig.new(:'inline-radio', , default_value, labels: labels) end |
#klazz(value_class, *args, **kwargs) ⇒ Object
68 69 70 71 72 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 68 def klazz(value_class, *args, **kwargs) Controls::CustomConfig.new.with_value(*args, **kwargs) do |*a, **kwa| value_class.new(*a, **kwa) end end |
#multi_select(options, default_value, labels: nil) ⇒ Object
35 36 37 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 35 def multi_select(, default_value, labels: nil) Controls::MultiOptionsConfig.new(:'multi-select', , default_value, labels: labels) end |
#number(default_value, min: nil, max: nil, step: nil) ⇒ Object
15 16 17 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 15 def number(default_value, min: nil, max: nil, step: nil) Controls::NumberConfig.new(:number, default_value, min: min, max: max, step: step) end |
#object(default_value) ⇒ Object
27 28 29 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 27 def object(default_value) Controls::ObjectConfig.new(default_value) end |
#radio(options, default_value, labels: nil) ⇒ Object
39 40 41 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 39 def radio(, default_value, labels: nil) Controls::OptionsConfig.new(:radio, , default_value, labels: labels) end |
#range(default_value, min: nil, max: nil, step: nil) ⇒ Object
19 20 21 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 19 def range(default_value, min: nil, max: nil, step: nil) Controls::NumberConfig.new(:range, default_value, min: min, max: max, step: step) end |
#select(options, default_value, labels: nil) ⇒ Object
31 32 33 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 31 def select(, default_value, labels: nil) Controls::OptionsConfig.new(:select, , default_value, labels: labels) end |
#text(default_value) ⇒ Object
7 8 9 |
# File 'lib/view_component/storybook/controls/controls_helpers.rb', line 7 def text(default_value) Controls::TextConfig.new(default_value) end |