svg preview renderer
This commit is contained in:
parent
43a8412f06
commit
faa9599849
29 changed files with 1027 additions and 254 deletions
|
|
@ -1,6 +1,8 @@
|
|||
defmodule ZoeyscomputerWeb.GistLive.FormComponent do
|
||||
use ZoeyscomputerWeb, :live_component
|
||||
|
||||
import ZoeyscomputerWeb.GistLive.Select
|
||||
|
||||
alias Zoeyscomputer.Gists
|
||||
|
||||
@impl true
|
||||
|
|
@ -11,7 +13,6 @@ defmodule ZoeyscomputerWeb.GistLive.FormComponent do
|
|||
<%= @title %>
|
||||
<:subtitle>Use this form to manage gist records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.simple_form
|
||||
for={@form}
|
||||
id="gist-form"
|
||||
|
|
@ -19,8 +20,22 @@ defmodule ZoeyscomputerWeb.GistLive.FormComponent do
|
|||
phx-change="validate"
|
||||
phx-submit="save"
|
||||
>
|
||||
<.input field={@form[:code]} type="text" label="Code" />
|
||||
<.input field={@form[:lang]} type="text" label="Lang" />
|
||||
<.input field={@form[:title]} type="text" label="Title" />
|
||||
<.input field={@form[:desc]} type="textarea" label="Description" />
|
||||
<.input field={@form[:code]} type="textarea" label="Code" />
|
||||
<.select
|
||||
id="lang-select"
|
||||
form={@form}
|
||||
field={:lang}
|
||||
label="Language"
|
||||
options={[
|
||||
{"JavaScript", "javascript"},
|
||||
{"Python", "python"},
|
||||
{"Elixir", "elixir"},
|
||||
{"Ruby", "ruby"},
|
||||
{"Rust", "rust"}
|
||||
]}
|
||||
/>
|
||||
<:actions>
|
||||
<.button phx-disable-with="Saving...">Save Gist</.button>
|
||||
</:actions>
|
||||
|
|
@ -49,6 +64,14 @@ defmodule ZoeyscomputerWeb.GistLive.FormComponent do
|
|||
save_gist(socket, socket.assigns.action, gist_params)
|
||||
end
|
||||
|
||||
# Updated to use lang instead of language
|
||||
def handle_event("change", %{"value" => value}, socket) do
|
||||
current_params = socket.assigns.form.params || %{}
|
||||
updated_params = Map.put(current_params, "lang", value)
|
||||
changeset = Gists.change_gist(socket.assigns.gist, updated_params)
|
||||
{:noreply, assign(socket, form: to_form(changeset, action: :validate))}
|
||||
end
|
||||
|
||||
defp save_gist(socket, :edit, gist_params) do
|
||||
case Gists.update_gist(socket.assigns.gist, gist_params) do
|
||||
{:ok, gist} ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue