Class: ViewComponent::Storybook::Controls::SimpleControl

Inherits:
Control
  • Object
show all
Defined in:
lib/view_component/storybook/controls/simple_control.rb

Overview

A simple Control Config maps to one Storybook Control It has a value and pulls its value from params by key

Direct Known Subclasses

BaseOptions, Boolean, Color, Date, Number, Object, Text

Instance Attribute Summary

Attributes inherited from Control

#default, #description, #name, #param

Instance Method Summary collapse

Constructor Details

#initialize(param, default: nil, name: nil, description: nil, **opts) ⇒ SimpleControl

Returns a new instance of SimpleControl.



10
11
12
# File 'lib/view_component/storybook/controls/simple_control.rb', line 10

def initialize(param, default: nil, name: nil, description: nil, **opts)
  super(param, default: default, name: name, description: description, **opts)
end

Instance Method Details

#parse_param_value(value) ⇒ Object



24
25
26
# File 'lib/view_component/storybook/controls/simple_control.rb', line 24

def parse_param_value(value)
  value
end

#to_csf_paramsObject



14
15
16
17
18
19
20
21
22
# File 'lib/view_component/storybook/controls/simple_control.rb', line 14

def to_csf_params
  validate!
  {
    args: { param => csf_value },
    argTypes: {
      param => { control: csf_control_params, name: name, description: description }.compact
    }
  }
end