neiam
/lambent_ex
Lambent Aether 5
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions success · Badges · Packages
Log in to mark this repository.
modals in work, reskinned .17 form components in-use to be daisy
ede4deb · gmorell · 2022-12-13 06:04
Files changed
added
lib/lambent_ex/schema/lambent_ex/schema/links.ex
+35
−0
| 1 | +defmodule LambentEx.Schema.Links do | |
| 2 | + @moduledoc false | |
| 3 | + | |
| 4 | + use Ecto.Schema | |
| 5 | + import Ecto.Changeset | |
| 6 | + | |
| 7 | + alias LambentEx.Schema.Links | |
| 8 | + | |
| 9 | + | |
| 10 | + embedded_schema do | |
| 11 | + field :name, :string | |
| 12 | + field :source_id, :string | |
| 13 | + field :source_type, Ecto.Enum, values: [:machine, :anchor] | |
| 14 | + field :target_id, :string | |
| 15 | + field :target_type, Ecto.Enum, values: [:device, :group] | |
| 16 | + end | |
| 17 | + | |
| 18 | + def change_link(%Links{} = link, attrs \\ %{}) do | |
| 19 | + Links.changeset(link, attrs) | |
| 20 | + end | |
| 21 | + | |
| 22 | + def update_links(%Links{} = link, attrs) do | |
| 23 | + IO.puts("actual write") | |
| 24 | + | |
| 25 | + link | |
| 26 | + |> Links.changeset(attrs) | |
| 27 | + |> IO.inspect | |
| 28 | + end | |
| 29 | + | |
| 30 | + def changeset(source, params) do | |
| 31 | + source | |
| 32 | + |> cast(params, ~w(name source_id source_type target_id target_type)a) | |
| 33 | + |> validate_required([:name, :source_id, :source_type, :target_id, :target_type]) | |
| 34 | + end | |
| 35 | +end |
added
lib/lambent_ex/schema/lambent_ex/schema/machine.ex
+3
−0
| 1 | +defmodule LambentEx.Schema.Machines do | |
| 2 | + @moduledoc false | |
| 3 | +end |
modified
lib/lambent_ex_web.ex
+3
−0
| 91 | 91 | # Shortcut for generating JS commands |
| 92 | 92 | alias Phoenix.LiveView.JS |
| 93 | 93 | |
| 94 | + # Custom Components | |
| 95 | + import LambentEx.Components.Buttons | |
| 96 | + | |
| 94 | 97 | # Routes generation with the ~p sigil |
| 95 | 98 | unquote(verified_routes()) |
| 96 | 99 | end |
added
lib/lambent_ex_web/components/buttons.ex
+46
−0
| 1 | +defmodule LambentEx.Components.Buttons do | |
| 2 | + use Phoenix.Component | |
| 3 | + | |
| 4 | + alias Phoenix.LiveView.JS | |
| 5 | + | |
| 6 | + def itb(assigns) do # icon-text-button | |
| 7 | + assigns = assigns | |
| 8 | + |> assign_new(:icon, fn -> "fa-poo-storm" end) | |
| 9 | + |> assign_new(:what, fn -> "Poop" end) | |
| 10 | + | |
| 11 | + ~H""" | |
| 12 | + <%= live_patch to: @to, class: "btn gap-2 float-right" do %> | |
| 13 | + <i class={"fa-solid #{@icon}"}></i> | |
| 14 | + | |
| 15 | + <%= adj(@what) %> <%= @what %> | |
| 16 | + <% end %> | |
| 17 | + """ | |
| 18 | + end | |
| 19 | + | |
| 20 | + def ib(assigns) do | |
| 21 | + assigns = assigns | |
| 22 | + |> assign_new(:icon, fn -> "fa-poo-storm" end) | |
| 23 | + |> assign_new(:function, fn -> :live_patch end) | |
| 24 | + | |
| 25 | + ~H""" | |
| 26 | + <%= case @function do %> | |
| 27 | + <%= :live_patch -> %> | |
| 28 | + <%= live_patch to: @to, class: "btn btn-square btn-xs" do %> | |
| 29 | + <i class={"fa-solid #{@icon}"}></i> | |
| 30 | + <% end %> | |
| 31 | + <% :live_redirect -> %> | |
| 32 | + <%= live_redirect to: @to, class: "btn btn-square btn-xs" do %> | |
| 33 | + <i class={"fa-solid #{@icon}"}></i> | |
| 34 | + <% end %> | |
| 35 | + <% end %> | |
| 36 | + """ | |
| 37 | + end | |
| 38 | + | |
| 39 | + defp adj(what) do | |
| 40 | + case what do | |
| 41 | + "Edit" -> "" | |
| 42 | + "Back" -> "Go" | |
| 43 | + _ -> "New" | |
| 44 | + end | |
| 45 | + end | |
| 46 | +end |
modified
lib/lambent_ex_web/components/core_components.ex
+5
−5
| 48 | 48 | def modal(assigns) do |
| 49 | 49 | ~H""" |
| 50 | 50 | <div id={@id} phx-mounted={@show && show_modal(@id)} class="relative z-50 hidden"> |
| 51 | − <div id={"#{@id}-bg"} class="fixed inset-0 bg-zinc-50/90 transition-opacity" aria-hidden="true" /> | |
| 51 | + <div id={"#{@id}-bg"} class="fixed inset-0 bg-base-300/90 transition-opacity" aria-hidden="true" /> | |
| 52 | 52 | <div |
| 53 | 53 | class="fixed inset-0 overflow-y-auto" |
| 54 | 54 | aria-labelledby={"#{@id}-title"} |
| 65 | 65 | phx-window-keydown={hide_modal(@on_cancel, @id)} |
| 66 | 66 | phx-key="escape" |
| 67 | 67 | phx-click-away={hide_modal(@on_cancel, @id)} |
| 68 | − class="hidden relative rounded-2xl bg-white p-14 shadow-lg shadow-zinc-700/10 ring-1 ring-zinc-700/10 transition" | |
| 68 | + class="hidden relative rounded-2xl bg-primary p-14 shadow-lg shadow-zinc-700/10 ring-1 ring-zinc-700/10 transition" | |
| 69 | 69 | > |
| 70 | 70 | <div class="absolute top-6 right-5"> |
| 71 | 71 | <button |
| 191 | 191 | def simple_form(assigns) do |
| 192 | 192 | ~H""" |
| 193 | 193 | <.form :let={f} for={@for} as={@as} {@rest}> |
| 194 | − <div class="space-y-8 bg-white mt-10"> | |
| 194 | + <div class="space-y-8 mt-10"> | |
| 195 | 195 | <%= render_slot(@inner_block, f) %> |
| 196 | 196 | <div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6"> |
| 197 | 197 | <%= render_slot(action, f) %> |
| 303 | 303 | <select |
| 304 | 304 | id={@id} |
| 305 | 305 | name={@name} |
| 306 | − class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-zinc-500 focus:border-zinc-500 sm:text-sm" | |
| 306 | + class="select select-primary w-full max-w-xs" | |
| 307 | 307 | multiple={@multiple} |
| 308 | 308 | {@rest} |
| 309 | 309 | > |
| 373 | 373 | |
| 374 | 374 | def label(assigns) do |
| 375 | 375 | ~H""" |
| 376 | − <label for={@for} class="block text-sm font-semibold leading-6 text-zinc-800"> | |
| 376 | + <label for={@for} class="label"> | |
| 377 | 377 | <%= render_slot(@inner_block) %> |
| 378 | 378 | </label> |
| 379 | 379 | """ |
modified
lib/lambent_ex_web/components/layouts/app.html.heex
+9
−2
Click to load diff…
added
lib/lambent_ex_web/live/links/form_component.ex
+39
−0
Click to load diff…
added
lib/lambent_ex_web/live/links/form_component.html.heex
+18
−0
Click to load diff…
modified
lib/lambent_ex_web/live/links/index.ex
+16
−1
Click to load diff…
modified
lib/lambent_ex_web/live/links/index.html.heex
+16
−1
Click to load diff…
modified
lib/lambent_ex_web/router.ex
+2
−0
Click to load diff…
modified
mix.exs
+3
−1
Click to load diff…
modified
mix.lock
+3
−0
Click to load diff…
Parents: 349df56