-
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.
fix: create the InputGroup component [MDS-188] (#358)
- Loading branch information
1 parent
92abbdf
commit 98f9f2c
Showing
21 changed files
with
706 additions
and
733 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,7 +325,7 @@ module.exports = { | |
"& a, & span": { | ||
padding: "0.5rem", | ||
}, | ||
}, | ||
} | ||
}); | ||
}), | ||
], | ||
|
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,22 @@ | ||
defmodule Moon.Components.InputGroup do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
alias Moon.Components.InputGroup.Container | ||
|
||
prop orientation, :string, | ||
default: "horizontal", | ||
values: ["horizontal", "vertical"] | ||
|
||
prop has_fields, :boolean, default: false | ||
|
||
slot default, required: true, args: [:group_class_fields] | ||
|
||
def render(assigns) do | ||
~F""" | ||
<Container orientation={@orientation}> | ||
<#slot /> | ||
</Container> | ||
""" | ||
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,46 @@ | ||
defmodule Moon.Components.InputGroup.Container do | ||
@moduledoc false | ||
|
||
use Moon.StatelessComponent | ||
|
||
prop orientation, :string | ||
prop background_color, :string, default: "gohan-100", values: Moon.colors() | ||
prop is_error, :boolean | ||
slot default | ||
|
||
def render(assigns) do | ||
~F""" | ||
<div class={ | ||
"moon-input-group border-none shadow-input relative rounded-moon-i-md", | ||
@orientation, | ||
"rtl-aware", | ||
get_class_for_orientation(@orientation, @is_error), | ||
"bg-#{@background_color}": @background_color | ||
}> | ||
<#slot /> | ||
</div> | ||
""" | ||
end | ||
|
||
defp get_class_for_orientation(orientation, is_error) do | ||
cond do | ||
orientation == "horizontal" && !is_error -> | ||
" | ||
flex | ||
after:content-[''] after:z-20 after:absolute after:top-0 after:bottom-0 after:w-px | ||
after:left-1/2 after:translate-x-[-50%] after:bg-beerus-100 after:x-[3] | ||
hover:after:hidden focus-within:after:hidden | ||
" | ||
|
||
!is_error -> | ||
" | ||
after:content-[''] after:z-20 after:absolute after:top-1/2 after:bottom-0 after:w-full after:h-px | ||
after:left-0 after:translate-y-[-50%] after:bg-beerus-100 after:x-[3] | ||
hover:after:hidden focus-within:after:hidden | ||
" | ||
|
||
true -> | ||
"" | ||
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
Oops, something went wrong.