Skip to content

Commit

Permalink
add action bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Nov 26, 2023
1 parent 7884934 commit 080d4d0
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions lib/doggo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,49 @@ defmodule Doggo do

## Components

@doc """
The action bar offers users quick access to primary actions within the
application.
It is typically positioned to float above other content.
## Example
<.action_bar>
<:item label="Edit" on_click={JS.push("edit")}>
<.icon size={:small}><Lucideicons.pencil aria-hidden /></Doggo.icon>
</:item>
<:item label="Move" on_click={JS.push("move")}>
<.icon size={:small}><Lucideicons.move aria-hidden /></Doggo.icon>
</:item>
<:item label="Archive" on_click={JS.push("archive")}>
<.icon size={:small}><Lucideicons.archive aria-hidden /></Doggo.icon>
</:item>
</.action_bar>
"""
@doc type: :component

attr :class, :any,
default: [],
doc: "Additional CSS classes. Can be a string or a list of strings."

attr :rest, :global, doc: "Any additional HTML attributes."

slot :item do
attr :label, :string, required: true
attr :on_click, JS, required: true
end

def action_bar(assigns) do
~H"""
<div class={["action-bar" | List.wrap(@class)]} {@rest}>
<.link :for={item <- @item} phx-click={item.on_click} title={item.label}>
<%= render_slot(item) %>
</.link>
</div>
"""
end

@doc """
Shows the flash messages as alerts.
Expand Down

0 comments on commit 080d4d0

Please sign in to comment.