Current section

41 Versions

Jump to

Compare versions

11 files changed
+378 additions
-173 deletions
  @@ -38,7 +38,7 @@ Alternative, you can just install a single component
38 38 mix daisy badge input
39 39 ```
40 40
41 - **_NOTE:_** This will install as well component dependencies which can be another components.
41 + **_NOTE:_** This will install the components and it's dependencies.
42 42
43 43 ### Installing as a dependency
44 44
  @@ -179,13 +179,13 @@ List of available components.
179 179
180 180 | Component | Status | Storybook |
181 181 | ----------------------------------------------------- | ------ | --------- |
182 - | [Accordion](https://daisyui.com/components/accordion) | ❌ | ❌ |
182 + | [Accordion](https://daisyui.com/components/accordion) | ✅ | ❌ |
183 183 | [Avatar](https://daisyui.com/components/avatar) | âś… | âś… |
184 184 | [Badge](https://daisyui.com/components/badge) | âś… | âś… |
185 185 | [Card](https://daisyui.com/components/card) | âś… | âś… |
186 186 | [Carousel](https://daisyui.com/components/carousel) | ❌ | ❌ |
187 187 | [Chat bubble](https://daisyui.com/components/chat) | ❌ | ❌ |
188 - | [Collapse](https://daisyui.com/components/collapse) | ❌ | ❌ |
188 + | [Collapse](https://daisyui.com/components/collapse) | ✅ | ❌ |
189 189 | [Countdown](https://daisyui.com/components/countdown) | ❌ | ❌ |
190 190 | [Diff](https://daisyui.com/components/diff/) | ❌ | ❌ |
191 191 | [Kbd](https://daisyui.com/components/kbd) | ❌ | ❌ |
  @@ -1,7 +1,7 @@
1 1 {<<"links">>,
2 2 [{<<"GitHub">>,<<"https://github.com/phcurado/daisy_ui_components">>}]}.
3 3 {<<"name">>,<<"daisy_ui_components">>}.
4 - {<<"version">>,<<"0.8.5">>}.
4 + {<<"version">>,<<"0.8.6">>}.
5 5 {<<"description">>,<<"DaisyUI component library for LiveView">>}.
6 6 {<<"elixir">>,<<"~> 1.14">>}.
7 7 {<<"app">>,<<"daisy_ui_components">>}.
  @@ -10,6 +10,7 @@
10 10 [<<"lib">>,<<"lib/daisy_ui_components">>,
11 11 <<"lib/daisy_ui_components/utils.ex">>,
12 12 <<"lib/daisy_ui_components/drawer.ex">>,
13 + <<"lib/daisy_ui_components/collapse.ex">>,
13 14 <<"lib/daisy_ui_components/textarea.ex">>,
14 15 <<"lib/daisy_ui_components/avatar.ex">>,
15 16 <<"lib/daisy_ui_components/pagination.ex">>,
  @@ -32,6 +33,7 @@
32 33 <<"lib/daisy_ui_components/radio.ex">>,
33 34 <<"lib/daisy_ui_components/checkbox.ex">>,
34 35 <<"lib/daisy_ui_components/select.ex">>,
36 + <<"lib/daisy_ui_components/accordion.ex">>,
35 37 <<"lib/daisy_ui_components/alert.ex">>,
36 38 <<"lib/daisy_ui_components/label.ex">>,
37 39 <<"lib/daisy_ui_components/form.ex">>,
  @@ -42,6 +42,7 @@ defmodule DaisyUIComponents do
42 42
43 43 defmacro __using__(_) do
44 44 quote do
45 + import DaisyUIComponents.Accordion
45 46 import DaisyUIComponents.Alert
46 47 import DaisyUIComponents.Avatar
47 48 import DaisyUIComponents.Back
  @@ -50,6 +51,7 @@ defmodule DaisyUIComponents do
50 51 import DaisyUIComponents.Button
51 52 import DaisyUIComponents.Card
52 53 import DaisyUIComponents.Checkbox
54 + import DaisyUIComponents.Collapse
53 55 import DaisyUIComponents.Drawer
54 56 import DaisyUIComponents.Dropdown
55 57 import DaisyUIComponents.Fieldset
  @@ -0,0 +1,62 @@
1 + defmodule DaisyUIComponents.Accordion do
2 + @moduledoc """
3 + Accordion component
4 +
5 + https://daisyui.com/components/accordion/
6 + """
7 +
8 + use DaisyUIComponents, :component
9 +
10 + @doc """
11 + Renders an accordion.
12 +
13 + ## Examples
14 +
15 + <.accordion>
16 + <:title>Title</:title>
17 + Content goes here
18 + </.accordion>
19 + """
20 +
21 + attr :class, :any, default: nil
22 + attr :name, :string
23 + attr :arrow, :boolean, default: false
24 + attr :plus, :boolean, default: false
25 + attr :open, :boolean, default: false
26 + attr :close, :boolean, default: false
27 + attr :rest, :global
28 +
29 + slot :title, required: true
30 + slot :inner_block, required: true
31 +
32 + def accordion(assigns) do
33 + assigns =
34 + assigns
35 + |> assign(
36 + :class,
37 + classes([
38 + "collapse",
39 + maybe_add_class(assigns[:arrow], "collapse-arrow"),
40 + maybe_add_class(assigns[:plus], "collapse-plus"),
41 + maybe_add_class(assigns[:open], "collapse-open"),
42 + maybe_add_class(assigns[:close], "collapse-close"),
43 + assigns.class
44 + ])
45 + )
46 + |> assign_new(:name, fn -> "accordion-#{System.unique_integer([:positive])}" end)
47 +
48 + ~H"""
49 + <div class={@class} {@rest}>
50 + <input type="radio" name={@name} />
51 +
52 + <div class="collapse-title">
53 + {render_slot(@title)}
54 + </div>
55 +
56 + <div class="collapse-content">
57 + {render_slot(@inner_block)}
58 + </div>
59 + </div>
60 + """
61 + end
62 + end
  @@ -127,6 +127,10 @@ defmodule DaisyUIComponents.Alert do
127 127 attr :id, :string, default: nil, doc: "the optional id of alert container"
128 128 attr :class, :any, default: nil
129 129 attr :color, :string, values: ~w(info success warning error)
130 + attr :soft, :boolean, default: false
131 + attr :outline, :boolean, default: false
132 + attr :dash, :boolean, default: false
133 + attr :direction, :string, values: ~w(vertical horizontal)
130 134 attr :rest, :global
131 135 slot :inner_block
132 136
  @@ -138,6 +142,10 @@ defmodule DaisyUIComponents.Alert do
138 142 classes([
139 143 "alert",
140 144 alert_color(assigns[:color]),
145 + maybe_add_class(assigns[:soft], "alert-soft"),
146 + maybe_add_class(assigns[:outline], "alert-outline"),
147 + maybe_add_class(assigns[:dash], "alert-dash"),
148 + alert_direction(assigns[:direction]),
141 149 assigns.class
142 150 ])
143 151 )
  @@ -149,6 +157,11 @@ defmodule DaisyUIComponents.Alert do
149 157 """
150 158 end
151 159
160 + # Direction
161 + defp alert_direction("vertical"), do: "alert-vertical"
162 + defp alert_direction("horizontal"), do: "alert-horizontal"
163 + defp alert_direction(nil), do: nil
164 +
152 165 # Icon
153 166 defp get_icon("warning"), do: "hero-exclamation-triangle"
154 167 defp get_icon("success"), do: "hero-check-circle"
Loading more files…