Class: PhlexKit::Heading

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/typography/heading.rb

Overview

Heading, ported from ruby_ui's RubyUI::Heading. level: (1–4) picks the element AND a default size; as: overrides the element; size: (1–9) overrides the size on ruby_ui's scale (text-xs … text-5xl). Presentational; attrs pass through via mix. Tailwind → vanilla .pk-heading* (typography.css).

Constant Summary collapse

SIZES =
%w[1 2 3 4 5 6 7 8 9].freeze
LEVEL_SIZE =

ruby_ui's level → default size mapping (h1 is big, h4 smaller).

{ "1" => "7", "2" => "6", "3" => "5", "4" => "4" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(level: nil, as: nil, size: nil, **attrs) ⇒ Heading

Returns a new instance of Heading.



11
12
13
14
15
16
# File 'app/components/phlex_kit/typography/heading.rb', line 11

def initialize(level: nil, as: nil, size: nil, **attrs)
  @level = level
  @as = as
  @size = size
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



18
19
20
# File 'app/components/phlex_kit/typography/heading.rb', line 18

def view_template(&block)
  send(element, **mix({ class: classes }, @attrs), &block)
end