Class: PhlexKit::Card

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

Overview

Container card kit, ported from ruby_ui's Card (https://ruby-ui.com). Six presentational parts — Card + CardHeader / CardTitle / CardDescription / CardContent / CardFooter — each wrapping its children in an element with a base class and passing arbitrary attrs straight through via mix (so a caller class: augments rather than clobbers, exactly like PhlexKit::Button).

Styles are namespaced .pk-card* in card.css rather than .card: this app already uses .card for the dashboard stat tiles (application.css), which are a different, padded component. Compose the parts:

render PhlexKit::Card.new do
render PhlexKit::CardHeader.new do
  render PhlexKit::CardTitle.new { "Title" }
  render PhlexKit::CardDescription.new { "Subtitle" }
end
render PhlexKit::CardContent.new { "" }
render PhlexKit::CardFooter.new { render PhlexKit::Button.new { "Action" } }
end

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ Card

Returns a new instance of Card.



21
22
23
# File 'app/components/phlex_kit/card/card.rb', line 21

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



25
26
27
# File 'app/components/phlex_kit/card/card.rb', line 25

def view_template(&block)
  div(**mix({ class: "pk-card" }, @attrs), &block)
end