Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: modify styles of form fields, add badge_position prop to badge #192

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions priv/templates/components/badge.eex
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ defmodule <%= @module %> do

attr :icon, :string, default: nil, doc: "Icon displayed alongside of an item"
attr :class, :string, default: nil, doc: "Custom CSS class for additional styling"
attr :badge_position, :string, default: nil, doc: "Custom CSS class for additional styling"

attr :indicator_class, :string,
default: nil,
Expand Down Expand Up @@ -128,6 +129,8 @@ defmodule <%= @module %> do
color_variant(@variant, @color),
border_size(@border, @variant),
rounded_size(@rounded),
badge_position(@badge_position),
@badge_position && "absolute",
@font_weight,
@class
]
Expand Down Expand Up @@ -285,6 +288,18 @@ defmodule <%= @module %> do
~H"""
"""
end

defp badge_position("top-left"), do: "-translate-y-1/2 -translate-x-1/2 right-auto top-0 left-0"

defp badge_position("top-right"), do: "-translate-y-1/2 translate-x-1/2 left-auto top-0 right-0"

defp badge_position("bottom-left"), do: "translate-y-1/2 -translate-x-1/2 right-auto bottom-0 left-0"

defp badge_position("bottom-right"), do: "translate-y-1/2 translate-x-1/2 left-auto bottom-0 right-0"

defp badge_position(params) when is_binary(params), do: params
defp badge_position(_), do: nil

<%= if is_nil(@variant) or "default" in @variant do %>
<%= if is_nil(@color) or "white" in @color do %>
defp color_variant("default", "white") do
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/date_time_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder="select a date "
{@rest}
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/email_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder=" "
{@rest}
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/native_select.eex
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ defmodule <%= @module %> do
id={@id}
multiple={@multiple}
class={[
"select-field appearance-none block w-full",
"select-field appearance-none block w-full text-[16px] sm:font-inherit",
@multiple && "select-multiple-option",
@errors != [] && "select-field-error",
@min_height,
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/number_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer",
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer",
@controls == "fixed" &&
"[&::-webkit-outer-spin-button]:opacity-100 [&::-webkit-inner-spin-button]:opacity-100",
@controls == "hide" &&
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/password_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
{@rest}
/>
Expand Down
6 changes: 3 additions & 3 deletions priv/templates/components/range_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ defmodule <%= @module %> do

<%= if is_nil(@color) or "white" in @color do %>
defp color_class("default", "white") do
["accent-white dark:accent-white"]
["accent-white"]
end
<% end %>
<%= if is_nil(@color) or "natural" in @color do %>
Expand All @@ -309,7 +309,7 @@ defmodule <%= @module %> do
<% end %>
<%= if is_nil(@color) or "warning" in @color do %>
defp color_class("default", "warning") do
["accent-[#CA8D01] dark:accent-[#FDC034]"]
["accent-[#976A01] dark:accent-[#FDC034]"]
end
<% end %>
<%= if is_nil(@color) or "danger" in @color do %>
Expand Down Expand Up @@ -339,7 +339,7 @@ defmodule <%= @module %> do
<% end %>
<%= if is_nil(@color) or "dark" in @color do %>
defp color_class("default", "dark") do
["accent-[#282828] dark:accent-[#282828]"]
["accent-[#282828]"]
end
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/search_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder=" "
{@rest}
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/tel_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder=" "
{@rest}
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/text_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder=" "
{@rest}
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/textarea_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-3 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer",
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer",
@disable_resize && "resize-none"
]}
placeholder=" "
Expand Down
2 changes: 1 addition & 1 deletion priv/templates/components/url_field.eex
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ defmodule <%= @module %> do
value={@value}
class={[
"disabled:opacity-80 block w-full z-[2] focus:ring-0 placeholder:text-transparent pb-1 pt-2.5 px-2",
"focus:text-[16px] sm:focus:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
"text-[16px] sm:font-inherit appearance-none bg-transparent border-0 focus:outline-none peer"
]}
placeholder=" "
{@rest}
Expand Down