Class: Keystone::Ui::HeroComponent

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

Constant Summary collapse

WRAPPER_CLASSES =
"relative min-h-screen pt-24"
INNER_CLASSES =
"mx-auto max-w-6xl px-6 py-24 lg:py-32"
CONTENT_COLUMN_CLASSES =
"flex flex-col gap-8"
CENTERED_COLUMN_CLASSES =
"items-center"
SPLIT_CLASSES =
"grid gap-12 lg:grid-cols-2 lg:gap-16 items-center"
CENTERED_CLASSES =
"flex flex-col items-center text-center"
TITLE_BASE_CLASSES =
"text-4xl font-bold tracking-tight sm:text-5xl lg:text-6xl"
SUBTITLE_BASE_CLASSES =
"max-w-lg text-lg"
BADGE_BASE_CLASSES =
"inline-flex w-fit items-center gap-2 rounded-full border px-4 py-1.5 text-sm"
ACTIONS_CLASSES =
"flex flex-wrap gap-4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, subtitle: nil, badge: nil, layout: :split) ⇒ HeroComponent

Returns a new instance of HeroComponent.



24
25
26
27
28
29
# File 'app/components/keystone/ui/hero_component.rb', line 24

def initialize(title:, subtitle: nil, badge: nil, layout: :split)
  @title = title
  @subtitle = subtitle
  @badge = badge
  @layout = layout
end

Instance Attribute Details

#badgeObject (readonly)

Returns the value of attribute badge.



22
23
24
# File 'app/components/keystone/ui/hero_component.rb', line 22

def badge
  @badge
end

#subtitleObject (readonly)

Returns the value of attribute subtitle.



22
23
24
# File 'app/components/keystone/ui/hero_component.rb', line 22

def subtitle
  @subtitle
end

#titleObject (readonly)

Returns the value of attribute title.



22
23
24
# File 'app/components/keystone/ui/hero_component.rb', line 22

def title
  @title
end

Instance Method Details

#actions_classesObject



69
70
71
# File 'app/components/keystone/ui/hero_component.rb', line 69

def actions_classes
  ACTIONS_CLASSES
end

#badge?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/components/keystone/ui/hero_component.rb', line 65

def badge?
  !@badge.nil?
end

#badge_classesObject



61
62
63
# File 'app/components/keystone/ui/hero_component.rb', line 61

def badge_classes
  "#{BADGE_BASE_CLASSES} border-accent-500/20 bg-accent-500/10 text-accent-600 dark:text-accent-400"
end

#classesObject



31
32
33
# File 'app/components/keystone/ui/hero_component.rb', line 31

def classes
  WRAPPER_CLASSES
end

#content_classesObject



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

def content_classes
  @layout == :centered ? CENTERED_CLASSES : SPLIT_CLASSES
end

#inner_classesObject



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

def inner_classes
  INNER_CLASSES
end

#inner_content_classesObject



43
44
45
46
47
# File 'app/components/keystone/ui/hero_component.rb', line 43

def inner_content_classes
  return CONTENT_COLUMN_CLASSES unless @layout == :centered

  "#{CONTENT_COLUMN_CLASSES} #{CENTERED_COLUMN_CLASSES}"
end

#subtitle?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/components/keystone/ui/hero_component.rb', line 57

def subtitle?
  !@subtitle.nil?
end

#subtitle_classesObject



53
54
55
# File 'app/components/keystone/ui/hero_component.rb', line 53

def subtitle_classes
  "#{SUBTITLE_BASE_CLASSES} text-surface-500 dark:text-surface-400"
end

#title_classesObject



49
50
51
# File 'app/components/keystone/ui/hero_component.rb', line 49

def title_classes
  "#{TITLE_BASE_CLASSES} text-surface-900 dark:text-white"
end