Class: PhlexKit::Text
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Text
- Defined in:
- app/components/phlex_kit/typography/text.rb
Overview
Body text, ported from ruby_ui's RubyUI::Text. as: picks the element
(default :p), size: (1ā9 or xs/sm/base/lg/xl/2xlā¦) the size, weight: the
font-weight ā plus ruby_ui's :muted "weight", which is really the muted
COLOR (a drop-in for the legacy .muted utility). Attrs pass through via mix.
SIZES/WEIGHTS fetch fails loud. Tailwind ā vanilla .pk-text*.
Constant Summary collapse
- SIZES =
{ "1" => "1", "xs" => "1", "2" => "2", "sm" => "2", "3" => "3", "base" => "3", "4" => "4", "lg" => "4", "5" => "5", "xl" => "5", "6" => "6", "2xl" => "6", "7" => "7", "3xl" => "7", "8" => "8", "4xl" => "8", "9" => "9", "5xl" => "9" }.freeze
- WEIGHTS =
weight => modifier class (nil = regular).
:mutedis a colour, not a weight, matching ruby_ui's API. { regular: nil, light: "pk-text-light", medium: "pk-text-medium", semibold: "pk-text-semibold", bold: "pk-text-bold", muted: "pk-text-muted" }.freeze
Instance Method Summary collapse
-
#initialize(as: :p, size: "3", weight: :regular, **attrs) ⇒ Text
constructor
A new instance of Text.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :p, size: "3", weight: :regular, **attrs) ⇒ Text
Returns a new instance of Text.
31 32 33 34 35 36 |
# File 'app/components/phlex_kit/typography/text.rb', line 31 def initialize(as: :p, size: "3", weight: :regular, **attrs) @as = as @size = size.to_s @weight = weight.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
38 39 40 |
# File 'app/components/phlex_kit/typography/text.rb', line 38 def view_template(&block) send(@as, **mix({ class: classes }, @attrs), &block) end |