Class: Keystone::Ui::PipelineComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/pipeline_component.rb

Constant Summary collapse

CONTAINER_CLASSES =
"rounded-xl border border-surface-700 bg-surface-800 p-6"
HEADER_CLASSES =
"mb-4"
TITLE_CLASSES =
"text-lg font-semibold text-white"
SUBTITLE_CLASSES =
"mt-1 text-sm text-surface-400"
TRACK_CLASSES =
"flex flex-col gap-3 sm:flex-row sm:items-stretch"
BOX_CLASSES =
"flex flex-1 flex-col items-center gap-2 rounded-lg border border-surface-700 bg-surface-900 p-4 text-center"
BOX_LABEL_CLASSES =
"text-xs uppercase tracking-wide text-surface-500"
CONNECTOR_CLASSES =
"flex items-center justify-center"
COUNT_BASE_CLASSES =
"text-3xl font-bold"
"link-toggle text-2xl leading-none"
"text-accent-500"
"text-red-500"
COUNT_CLASSES =
{
  amber: "text-amber-400",
  emerald: "text-accent-400",
  danger: "text-red-400",
  muted: "text-surface-500"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, boxes:, links:, subtitle: nil) ⇒ PipelineComponent

Returns a new instance of PipelineComponent.



28
29
30
31
32
33
# File 'app/components/keystone/ui/pipeline_component.rb', line 28

def initialize(title:, boxes:, links:, subtitle: nil)
  @title = title
  @boxes = boxes
  @links = links
  @subtitle = subtitle
end

Instance Attribute Details

#boxesObject (readonly)

Returns the value of attribute boxes.



26
27
28
# File 'app/components/keystone/ui/pipeline_component.rb', line 26

def boxes
  @boxes
end

Returns the value of attribute links.



26
27
28
# File 'app/components/keystone/ui/pipeline_component.rb', line 26

def links
  @links
end

#subtitleObject (readonly)

Returns the value of attribute subtitle.



26
27
28
# File 'app/components/keystone/ui/pipeline_component.rb', line 26

def subtitle
  @subtitle
end

#titleObject (readonly)

Returns the value of attribute title.



26
27
28
# File 'app/components/keystone/ui/pipeline_component.rb', line 26

def title
  @title
end

Instance Method Details

#count_class(accent) ⇒ Object



35
36
37
# File 'app/components/keystone/ui/pipeline_component.rb', line 35

def count_class(accent)
  "#{COUNT_BASE_CLASSES} #{COUNT_CLASSES.fetch(accent, COUNT_CLASSES[:muted])}"
end


39
40
41
# File 'app/components/keystone/ui/pipeline_component.rb', line 39

def link_after(index)
  links[index]
end


43
44
45
# File 'app/components/keystone/ui/pipeline_component.rb', line 43

def link_classes(link)
  "#{LINK_BASE_CLASSES} #{link[:broken] ? LINK_BROKEN_CLASSES : LINK_HEALTHY_CLASSES}"
end