Module: ViewComponent::Storybook::Controls::ControlsHelpers

Included in:
StoryConfig
Defined in:
lib/view_component/storybook/controls/controls_helpers.rb

Instance Method Summary collapse

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(options, default_value, labels: nil)
  Controls::MultiOptionsConfig.new(:check, options, 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(options, default_value)
  Controls::MultiOptionsConfig.new(:'inline-check', options, 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(options, default_value, labels: nil)
  Controls::OptionsConfig.new(:'inline-radio', options, 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(options, default_value, labels: nil)
  Controls::MultiOptionsConfig.new(:'multi-select', options, 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(options, default_value, labels: nil)
  Controls::OptionsConfig.new(:radio, options, 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(options, default_value, labels: nil)
  Controls::OptionsConfig.new(:select, options, 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