Class: PhlexKit::Item
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Item
- Defined in:
- app/components/phlex_kit/item/item.rb
Overview
List row, ported from shadcn/ui's Item: a flex row of ItemMedia +
ItemContent(ItemTitle + ItemDescription) + ItemActions, optionally grouped
in an ItemGroup (with ItemSeparator) or stacked under an ItemHeader.
variant :outline draws a bordered card row; size: tightens (:sm/:xs);
href: renders an (their asChild link item — hover fills apply).
.pk-item* (item.css).
Constant Summary collapse
- VARIANTS =
{ default: nil, outline: "outline", muted: "muted" }.freeze
- SIZES =
{ md: nil, sm: "sm", xs: "xs" }.freeze
Instance Method Summary collapse
-
#initialize(variant: :default, size: :md, href: nil, **attrs) ⇒ Item
constructor
A new instance of Item.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(variant: :default, size: :md, href: nil, **attrs) ⇒ Item
Returns a new instance of Item.
12 13 14 15 16 17 |
# File 'app/components/phlex_kit/item/item.rb', line 12 def initialize(variant: :default, size: :md, href: nil, **attrs) @variant = variant.to_sym @size = size.to_sym @href = href @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/components/phlex_kit/item/item.rb', line 19 def view_template(&) classes = [ "pk-item", fetch_option(VARIANTS, @variant, :variant), fetch_option(SIZES, @size, :size) ].compact.join(" ") if @href a(**mix({ class: classes, href: @href }, @attrs), &) else div(**mix({ class: classes }, @attrs), &) end end |