Class: PhlexKit::Item

Inherits:
BaseComponent show all
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. variant :outline draws a bordered card row. .pk-item* (item.css).

Constant Summary collapse

VARIANTS =
{ default: nil, outline: "outline", muted: "muted" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(variant: :default, **attrs) ⇒ Item

Returns a new instance of Item.



9
10
11
12
# File 'app/components/phlex_kit/item/item.rb', line 9

def initialize(variant: :default, **attrs)
  @variant = variant.to_sym
  @attrs = attrs
end

Instance Method Details

#view_templateObject



14
15
16
# File 'app/components/phlex_kit/item/item.rb', line 14

def view_template(&)
  div(**mix({ class: [ "pk-item", VARIANTS.fetch(@variant) ].compact.join(" ") }, @attrs), &)
end