File tree 5 files changed +173
-1
lines changed
lib/bloom_site_web/components
storybook/bloom_components
5 files changed +173
-1
lines changed Original file line number Diff line number Diff line change
1
+ defmodule BloomSiteWeb.Components.Button do
2
+ use Phoenix.Component
3
+
4
+ @ doc """
5
+ An extension of the *core_components button*.
6
+ The `<.button>` has the ability to handle a variant attribute.
7
+ This makes it possible to have a `contained` or `outlined` look.
8
+
9
+ ⚠️ Uninstall the core button component!
10
+ As you do not need two button components, the button component of the core phoenix_package can be deleted.
11
+ """
12
+
13
+ attr ( :type , :string , default: nil )
14
+ attr ( :class , :string , default: nil )
15
+ attr ( :rest , :global , include: ~w( disabled form name value) )
16
+ attr ( :variant , :string , default: "contained" )
17
+
18
+ slot ( :inner_block , required: true )
19
+
20
+ def button ( assigns ) do
21
+ ~H"""
22
+ < button
23
+ type = { @ type }
24
+ class = { [
25
+ "rounded-lg px-3 py-2 box-sizing:border-box phx-submit-loading:opacity-75" ,
26
+ "text-sm font-semibold leading-6 text-white active:text-white/80" ,
27
+ get_variant ( assigns . variant ) ,
28
+ @ class
29
+ ] }
30
+ { @ rest }
31
+ >
32
+ <%= render_slot ( @ inner_block ) %>
33
+ </ button >
34
+ """
35
+ end
36
+
37
+ defp get_variant ( variant ) do
38
+ case variant do
39
+ "contained" ->
40
+ "border-2 border-zinc-900 hover:border-zinc-700 bg-zinc-900 hover:bg-zinc-700"
41
+
42
+ "outlined" ->
43
+ "border-2 border-zinc-900 bg-transparent text-zinc-900 hover:bg-zinc-700 hover:border-zinc-700 hover:text-white active:bg-zinc-700"
44
+
45
+ _ ->
46
+ "bg-zinc-900 hover:bg-zinc-700"
47
+ end
48
+ end
49
+ end
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ defmodule BloomSite.MixProject do
54
54
{ :gettext , "~> 0.20" } ,
55
55
{ :jason , "~> 1.2" } ,
56
56
{ :plug_cowboy , "~> 2.5" } ,
57
- { :bloom , "~> 0.0.7 "} ,
57
+ { :bloom , path: "../ "} ,
58
58
# {:bloom, path: "..", override: true},
59
59
{ :phoenix_storybook , "~> 0.6.0" }
60
60
]
Original file line number Diff line number Diff line change
1
+ defmodule BloomSite.Storybook.BloomComponents.Button do
2
+ use PhoenixStorybook.Story , :component
3
+
4
+ def function , do: & BloomSiteWeb.Components.Button . button / 1
5
+
6
+ def variations do
7
+ [
8
+ % Variation {
9
+ id: :default ,
10
+ slots: [
11
+ "Button"
12
+ ]
13
+ } ,
14
+ % Variation {
15
+ id: :outlined ,
16
+ attributes: % {
17
+ variant: "outlined"
18
+ } ,
19
+ slots: [
20
+ "Outlined button"
21
+ ]
22
+ } ,
23
+ ]
24
+ end
25
+ end
Original file line number Diff line number Diff line change
1
+ defmodule Bloom.Components.Button do
2
+ use Phoenix.Component
3
+
4
+ @ doc """
5
+ An extension of the *core_components button*.
6
+ The `<.button>` has the ability to handle a variant attribute.
7
+ This makes it possible to have a `contained` or `outlined` look.
8
+
9
+ ⚠️ Uninstall the core button component!
10
+ As you do not need two button components, the button component of the core phoenix_package can be deleted.
11
+ """
12
+
13
+ attr ( :type , :string , default: nil )
14
+ attr ( :class , :string , default: nil )
15
+ attr ( :rest , :global , include: ~w( disabled form name value) )
16
+ attr ( :variant , :string , default: "contained" )
17
+
18
+ slot ( :inner_block , required: true )
19
+
20
+ def button ( assigns ) do
21
+ ~H"""
22
+ < button
23
+ type = { @ type }
24
+ class = { [
25
+ "rounded-lg px-3 py-2 box-sizing:border-box phx-submit-loading:opacity-75" ,
26
+ "text-sm font-semibold leading-6 text-white active:text-white/80" ,
27
+ get_variant ( assigns . variant ) ,
28
+ @ class
29
+ ] }
30
+ { @ rest }
31
+ >
32
+ <%= render_slot ( @ inner_block ) %>
33
+ </ button >
34
+ """
35
+ end
36
+
37
+ defp get_variant ( variant ) do
38
+ case variant do
39
+ "contained" ->
40
+ "border-2 border-zinc-900 hover:border-zinc-700 bg-zinc-900 hover:bg-zinc-700"
41
+
42
+ "outlined" ->
43
+ "border-2 border-zinc-900 bg-transparent text-zinc-900 hover:bg-zinc-700 hover:border-zinc-700 hover:text-white active:bg-zinc-700"
44
+
45
+ _ ->
46
+ "bg-zinc-900 hover:bg-zinc-700"
47
+ end
48
+ end
49
+ end
Original file line number Diff line number Diff line change
1
+ defmodule <% = @ module_name % > Web.Components.Button do
2
+ use Phoenix.Component
3
+
4
+ @ doc """
5
+ An extension of the *core_components button*.
6
+ The `<.button>` has the ability to handle a variant attribute.
7
+ This makes it possible to have a `contained` or `outlined` look.
8
+
9
+ ⚠️ Uninstall the core button component!
10
+ As you do not need two button components, the button component of the core phoenix_package can be deleted.
11
+ """
12
+
13
+ attr ( :type , :string , default: nil )
14
+ attr ( :class , :string , default: nil )
15
+ attr ( :rest , :global , include: ~w( disabled form name value) )
16
+ attr ( :variant , :string , default: "contained" )
17
+
18
+ slot ( :inner_block , required: true )
19
+
20
+ def button ( assigns ) do
21
+ ~H"""
22
+ < button
23
+ type = { @ type }
24
+ class = { [
25
+ "rounded-lg px-3 py-2 box-sizing:border-box phx-submit-loading:opacity-75" ,
26
+ "text-sm font-semibold leading-6 text-white active:text-white/80" ,
27
+ get_variant ( assigns . variant ) ,
28
+ @ class
29
+ ] }
30
+ { @ rest }
31
+ >
32
+ <%%= render_slot ( @ inner_block ) %>
33
+ </ button >
34
+ """
35
+ end
36
+
37
+ defp get_variant ( variant ) do
38
+ case variant do
39
+ "contained" ->
40
+ "border-2 border-zinc-900 hover:border-zinc-700 bg-zinc-900 hover:bg-zinc-700"
41
+
42
+ "outlined" ->
43
+ "border-2 border-zinc-900 bg-transparent text-zinc-900 hover:bg-zinc-700 hover:border-zinc-700 hover:text-white active:bg-zinc-700"
44
+
45
+ _ ->
46
+ "bg-zinc-900 hover:bg-zinc-700"
47
+ end
48
+ end
49
+ end
You can’t perform that action at this time.
0 commit comments