-
Notifications
You must be signed in to change notification settings - Fork 0
/
actionbar.ex
77 lines (68 loc) · 1.23 KB
/
actionbar.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
defmodule Phoenix.WebComponent.Actionbar do
@moduledoc """
Render actionbar.
"""
use Phoenix.WebComponent, :html
@doc """
Generates a actionbar.
## Examples
```heex
<.wc_actionbar class="shadow">
<:left>
Star Wars
</:left>
<:right>
<button>action</button>
</:right>
</.wc_actionbar>
```
"""
@doc type: :component
attr(:id, :any,
default: false,
doc: """
html attribute id
"""
)
attr(:class, :string,
default: "",
doc: """
html attribute class
"""
)
slot(:left,
required: false,
doc: """
Left part of action bar.
"""
)
slot(:right,
required: false,
doc: """
Right part of action bar.
"""
)
def wc_actionbar(assigns) do
assigns =
assigns
|> assign_new(:left, fn -> [] end)
|> assign_new(:right, fn -> [] end)
~H"""
<div
id={@id}
class={[
"w-full h-16 px-4",
"flex justify-between items-center",
@class,
]}
>
<div classs="flex justify-start items-center">
<%= render_slot(@left) %>
</div>
<div classs="flex justify-end items-center">
<%= render_slot(@right) %>
</div>
</div>
"""
end
end