-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Avatar and Buttons to Parts [MDS-749] (#748)
- Loading branch information
1 parent
2a9fee6
commit 4293854
Showing
25 changed files
with
456 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
defmodule Moon.Design.Button.IconButtonProperties do | ||
@moduledoc "Module for putting button properties in one place" | ||
|
||
defmacro __using__(_opts \\ []) do | ||
quote do | ||
@doc "Visual/Logical variant of button" | ||
prop(variant, :string, | ||
values: ["fill", "outline", "ghost", "primary", "secondary", "tertiary"], | ||
default: "fill" | ||
) | ||
|
||
@doc "Size of button" | ||
prop(size, :string, values: ["xs", "sm", "md", "lg", "xl"], default: "md") | ||
@doc "Rendered HTML element" | ||
prop(as, :string, values!: ~w(a button), default: "button") | ||
@doc "A href attribute when prop as=\"a\"" | ||
prop(href, :string) | ||
@doc "Disabled button" | ||
prop(disabled, :boolean) | ||
@doc "Animation of button" | ||
prop(animation, :string, values: ~w(progress success error pulse)) | ||
@doc "Additional Tailwind classes" | ||
prop(class, :css_class) | ||
@doc "Icon. To be deprecated. Use prop \"icon\" instead." | ||
prop(icon_only, :string) | ||
@doc "Icon" | ||
prop(icon, :string) | ||
@doc "Additional Tailwind classes for hover background" | ||
prop(hover_bg_class, :css_class) | ||
@doc "Type attribute for DOM element" | ||
prop(type, :string, default: "button") | ||
@doc "Form attribute for DOM element" | ||
prop(form, :string) | ||
@doc "On click event" | ||
prop(on_click, :event) | ||
@doc "list of additional values to associate with the DOM element" | ||
prop(values, :keyword, default: []) | ||
@doc "Value attribute for DOM element" | ||
prop(value, :string) | ||
@doc "Id attribute for DOM element" | ||
prop(id, :string) | ||
@doc "Data-testid attribute for DOM element" | ||
prop(testid, :string) | ||
@doc "Additional attributes for DOM element" | ||
prop(attrs, :keyword, default: []) | ||
@doc "Aria label attribute for DOM element" | ||
prop(aria_label, :string) | ||
@doc "Target attribute for DOM element" | ||
prop(target, :string) | ||
@doc "Rel attribute for DOM element" | ||
prop(rel, :string) | ||
@doc "Slot for customizations" | ||
slot(default) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
defmodule Moon.Design.Button.Properties do | ||
@moduledoc "Module for putting button properties in one place" | ||
|
||
defmacro __using__(_opts \\ []) do | ||
quote do | ||
@doc "Visual/Logical variant of button" | ||
prop(variant, :string, | ||
values: ["fill", "outline", "ghost", "primary", "secondary", "tertiary"], | ||
default: "fill" | ||
) | ||
|
||
@doc "Size of button" | ||
prop(size, :string, values: ["xs", "sm", "md", "lg", "xl"], default: "md") | ||
@doc "Rendered HTML element" | ||
prop(as, :string, values!: ~w(a button), default: "button") | ||
@doc "A href attribute when prop as=\"a\"" | ||
prop(href, :string) | ||
@doc "Full width button" | ||
prop(full_width, :boolean) | ||
@doc "Disabled button" | ||
prop(disabled, :boolean) | ||
@doc "Animation of button" | ||
prop(animation, :string, values: ~w(progress success error pulse)) | ||
@doc "Additional Tailwind classes" | ||
prop(class, :css_class) | ||
@doc "Additional Tailwind classes for hover background" | ||
prop(hover_bg_class, :css_class) | ||
@doc "Type attribute for DOM element" | ||
prop(type, :string, default: "button") | ||
@doc "Form attribute for DOM element" | ||
prop(form, :string) | ||
@doc "On click event" | ||
prop(on_click, :event) | ||
@doc "list of additional values to associate with the DOM element" | ||
prop(values, :keyword, default: []) | ||
@doc "Value attribute for DOM element" | ||
prop(value, :string) | ||
@doc "Left icon" | ||
prop(left_icon, :string) | ||
@doc "Right icon" | ||
prop(right_icon, :string) | ||
@doc "Id attribute for DOM element" | ||
prop(id, :string) | ||
@doc "Data-testid attribute for DOM element" | ||
prop(testid, :string) | ||
@doc "Additional attributes for DOM element" | ||
prop(attrs, :keyword, default: []) | ||
@doc "Aria label attribute for DOM element" | ||
prop(aria_label, :string) | ||
@doc "Target attribute for DOM element" | ||
prop(target, :string) | ||
@doc "Rel attribute for DOM element" | ||
prop(rel, :string) | ||
@doc "Inner content of the component" | ||
slot(default) | ||
@doc "Right icon slot" | ||
slot(right_icon_slot) | ||
@doc "Left icon slot" | ||
slot(left_icon_slot) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
defmodule Moon.Parts.Button do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
|
||
use Moon.Design.Button.Properties | ||
|
||
alias Moon.Design.Button | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-popo") | ||
|
||
def render(assigns) do | ||
~F""" | ||
<Button | ||
{=@as} | ||
{=@variant} | ||
{=@size} | ||
{=@full_width} | ||
{=@disabled} | ||
{=@animation} | ||
{=@type} | ||
{=@form} | ||
{=@hover_bg_class} | ||
{=@left_icon} | ||
{=@right_icon} | ||
{=@href} | ||
{=@id} | ||
{=@on_click} | ||
{=@testid} | ||
{=@aria_label} | ||
{=@values} | ||
{=@value} | ||
{=@target} | ||
{=@rel} | ||
{=@attrs} | ||
class={"rounded-moon-s-xx rounded-full", @bg_class, @class} | ||
> | ||
<#slot {@left_icon_slot} /> | ||
<#slot /> | ||
<#slot {@right_icon_slot} /> | ||
</Button> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Moon.Parts.Button.Error do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
use Moon.Design.Button.Properties | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-chichi-10 text-chichi") | ||
|
||
defdelegate render(assigns), to: Moon.Parts.Button | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Moon.Parts.Button.Gray do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
use Moon.Design.Button.Properties | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-gohan text-bulma border border-beerus") | ||
|
||
defdelegate render(assigns), to: Moon.Parts.Button | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Moon.Parts.Button.Success do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
use Moon.Design.Button.Properties | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-roshi-10 text-roshi") | ||
|
||
defdelegate render(assigns), to: Moon.Parts.Button | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Moon.Parts.Button.Warning do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
use Moon.Design.Button.Properties | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-krillin-10 text-krillin") | ||
|
||
defdelegate render(assigns), to: Moon.Parts.Button | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Moon.Parts.Button.White do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
use Moon.Design.Button.Properties | ||
|
||
@doc "Background tailwind class(es)" | ||
prop(bg_class, :css_class, default: "bg-goku text-bulma border border-beerus") | ||
|
||
defdelegate render(assigns), to: Moon.Parts.Button | ||
end |
Oops, something went wrong.