class ViewComponent::Storybook::Controls::BaseOptionsConfig

Attributes

labels[R]
options[R]
type[R]

Public Class Methods

new(type, options, default_value, labels: nil, param: nil, name: nil) click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/base_options_config.rb, line 11
def initialize(type, options, default_value, labels: nil, param: nil, name: nil)
  super(default_value, param: param, name: name)
  @type = type
  @options = options
  @labels = labels
  normalize_options
end

Public Instance Methods

to_csf_params() click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/base_options_config.rb, line 19
def to_csf_params
  super.deep_merge(argTypes: { param => { options: options } })
end

Private Instance Methods

csf_control_params() click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/base_options_config.rb, line 25
def csf_control_params
  labels.nil? ? super : super.merge(labels: labels)
end
normalize_options() click to toggle source
# File lib/view_component/storybook/controls/base_options_config.rb, line 29
def normalize_options
  return unless options.is_a?(Hash)

  warning = "Hash options is deprecated and will be removed in v1.0.0. Use array options and `labels` instead."
  ActiveSupport::Deprecation.warn(warning)

  @labels = options.invert
  @options = options.values
end