fix preview background
This commit is contained in:
@@ -8,6 +8,10 @@ defmodule LabelmakerWeb.Home do
|
||||
assigns =
|
||||
Constants.defaults()
|
||||
|> Map.merge(Constants.preview())
|
||||
|> Map.put(
|
||||
:preview_background,
|
||||
Tools.process_preview_background(Constants.preview().preview_background)
|
||||
)
|
||||
|> Enum.to_list()
|
||||
|
||||
{
|
||||
@@ -32,15 +36,7 @@ defmodule LabelmakerWeb.Home do
|
||||
end
|
||||
|
||||
def handle_event("update_preview", %{"bg" => bg}, socket) do
|
||||
preview_background =
|
||||
case bg do
|
||||
"r" -> "bg-[linear-gradient(to_right,_black_33%,_white_67%)]"
|
||||
"b" -> "bg-[linear-gradient(to_bottom,_black_33%,_white_67%)]"
|
||||
"c" -> ""
|
||||
_ -> "bg-[linear-gradient(to_right,_black_33%,_white_67%)]"
|
||||
end
|
||||
|
||||
{:noreply, assign(socket, :preview_background, preview_background)}
|
||||
{:noreply, assign(socket, :preview_background, Tools.process_preview_background(bg))}
|
||||
end
|
||||
|
||||
def handle_event("update_alignment", %{"option" => option}, socket) do
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div
|
||||
class={
|
||||
"flex justify-center items-center p-4 overflow-hidden whitespace-nowrap border rounded transition duration-300 #{@preview_background} #{if @label_too_long, do: "border-danger", else: "border-primary"} #{if @label_too_long, do: "outline-danger", else: @outline != "none" && "outline-#{@outline}"}"}
|
||||
style={"height: calc(2rem + #{@preview_height}px); color: #{if @label_too_long, do: "white", else: @color}; #{Tools.outline(@outline, @label_too_long)} font-family: #{@font}; font-size: #{@size}px; line-height: #{@size}px; background-color: #{if @preview_background == "c", do: @color, else: ""}"}
|
||||
style={"height: calc(2rem + #{@preview_height}px); color: #{if @label_too_long, do: "white", else: @color}; #{Tools.outline(@outline, @label_too_long)} font-family: #{@font}; font-size: #{@size}px; line-height: #{@size}px; background-color: #{if @preview_background == "", do: @color, else: ""}"}
|
||||
>
|
||||
<%= if @label_too_long do %>
|
||||
{Constants.max_label_error()}
|
||||
|
||||
@@ -93,6 +93,15 @@ defmodule LabelmakerWeb.Tools do
|
||||
~p"/#{label}?#{Map.take(parameters, [:align, :color, :font, :height, :outline, :width])}"
|
||||
end
|
||||
|
||||
def process_preview_background(bg) do
|
||||
case bg do
|
||||
"r" -> "bg-[linear-gradient(to_right,_black_33%,_white_67%)]"
|
||||
"b" -> "bg-[linear-gradient(to_bottom,_black_33%,_white_67%)]"
|
||||
"c" -> ""
|
||||
_ -> "bg-[linear-gradient(to_right,_black_33%,_white_67%)]"
|
||||
end
|
||||
end
|
||||
|
||||
defp process_width("", _parameters), do: ""
|
||||
|
||||
# defp process_width("", parameters) do
|
||||
|
||||
Reference in New Issue
Block a user