class Playbook::PbProgressSimple::ProgressSimple

def classname

def classname
  generate_classname("pb_progress_simple_kit", muted_class, variant_class, align)
end

def data_values

def data_values
  prop(:data).merge(value: number_value)
end

def muted_class

def muted_class
  muted ? "muted" : nil
end

def number_value

def number_value
  validate_required_progress_props
  if percent
    validate_percent
    percent
  else
    validate_value_max
    (value * 100) / max
  end
end

def style

def style
  "width:#{width};"
end

def validate_percent

def validate_percent
  if max || value
    raise(
      ConflictingPropsError,
      "Do not use `value` or `max` props when passing `percent`"
    )
  end
end

def validate_required_progress_props

def validate_required_progress_props
  unless percent || value || max
    raise(
      ProgressError,
      "Pass `percent` or pass both `value` and `max` to this kit."
    )
  end
end

def validate_value_max

def validate_value_max
  if !value
    raise(
      MissingPropError,
      "Must pass `value` when passing `max`"
    )
  elsif !max
    raise(
      MissingPropError,
      "Must pass `max` when passing `value`"
    )
  end
end

def value_style

def value_style
  "width:#{number_value}%;"
end

def variant_class

def variant_class
  variant == "default" ? nil : variant
end

def wrapper_classname

def wrapper_classname
  generate_classname("pb_progress_simple_wrapper_#{align}")
end