Class: Keystone::Ui::FunnelComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::FunnelComponent
- Defined in:
- app/components/keystone/ui/funnel_component.rb
Defined Under Namespace
Classes: Layer
Constant Summary collapse
- CONTAINER_CLASSES =
"space-y-2"- LAYER_CLASSES =
"space-y-1"- ROW_CLASSES =
"flex items-baseline justify-between gap-3"- LABEL_CLASSES =
"text-sm font-medium text-surface-700 truncate"- VALUE_CLASSES =
"text-sm font-semibold text-surface-900 tabular-nums"- BAR_CLASSES =
"h-8 rounded-md bg-accent-500 transition-all"- TRANSITION_CLASSES =
"py-1 text-center text-xs text-surface-500"
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #bar_classes ⇒ Object
- #container_classes ⇒ Object
-
#initialize(steps:) ⇒ FunnelComponent
constructor
A new instance of FunnelComponent.
- #label_classes ⇒ Object
- #layer_classes ⇒ Object
- #layers ⇒ Object
- #row_classes ⇒ Object
- #transition_classes ⇒ Object
- #value_classes ⇒ Object
Constructor Details
#initialize(steps:) ⇒ FunnelComponent
Returns a new instance of FunnelComponent.
18 19 20 |
# File 'app/components/keystone/ui/funnel_component.rb', line 18 def initialize(steps:) @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
16 17 18 |
# File 'app/components/keystone/ui/funnel_component.rb', line 16 def steps @steps end |
Instance Method Details
#bar_classes ⇒ Object
49 50 51 |
# File 'app/components/keystone/ui/funnel_component.rb', line 49 def BAR_CLASSES end |
#container_classes ⇒ Object
37 38 39 |
# File 'app/components/keystone/ui/funnel_component.rb', line 37 def container_classes CONTAINER_CLASSES end |
#label_classes ⇒ Object
53 54 55 |
# File 'app/components/keystone/ui/funnel_component.rb', line 53 def label_classes LABEL_CLASSES end |
#layer_classes ⇒ Object
41 42 43 |
# File 'app/components/keystone/ui/funnel_component.rb', line 41 def layer_classes LAYER_CLASSES end |
#layers ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/keystone/ui/funnel_component.rb', line 22 def layers previous = nil steps.map do |step| layer = Layer.new( label: step[:label], value: step[:value], width_percent: width_percent(step[:value]), conversion_percent: conversion_percent(step[:value], previous) ) previous = step[:value] layer end end |
#row_classes ⇒ Object
45 46 47 |
# File 'app/components/keystone/ui/funnel_component.rb', line 45 def row_classes ROW_CLASSES end |
#transition_classes ⇒ Object
61 62 63 |
# File 'app/components/keystone/ui/funnel_component.rb', line 61 def transition_classes TRANSITION_CLASSES end |
#value_classes ⇒ Object
57 58 59 |
# File 'app/components/keystone/ui/funnel_component.rb', line 57 def value_classes VALUE_CLASSES end |