defmodule Doggo.Components.Card do
@moduledoc false
@behaviour Doggo.Component
use Phoenix.Component
@impl true
def doc do
"""
Renders a card in an `article` tag, typically used repetitively in a grid or
flex box layout.
"""
end
@impl true
def usage do
"""
```heex
<.card>
<:image>
<:header>
Dog Fashion Show
<:main>
The next dog fashion show is coming up quickly. Here's what you need
to look out for.
<:footer>
2023-11-15 12:24Events
```
"""
end
@impl true
def config do
[
type: :data,
since: "0.6.0",
maturity: :developing,
modifiers: []
]
end
@impl true
def nested_classes(_) do
[]
end
@impl true
def attrs_and_slots do
quote do
attr :rest, :global, doc: "Any additional HTML attributes."
slot :image,
doc: """
An optional image slot. The slot content will be rendered within a figure
element.
"""
slot :header,
doc: """
The header of the card. You typically want to wrap the header in a `h2` or
`h3` tag, or another header level, depending on the hierarchy on the page.
"""
slot :main, doc: "The main content of the card."
slot :footer,
doc: """
A footer of the card, typically containing controls, tags, or meta
information.
"""
end
end
@impl true
def init_block(_opts, _extra) do
[]
end
@impl true
def render(assigns) do
~H"""
{render_slot(@image)}{render_slot(@header)}{render_slot(@main)}
"""
end
end