save and show identity icons as raw svg

This commit is contained in:
Inhji 2023-03-14 22:57:40 +01:00
parent 0780a4c048
commit ca2400c8f0
8 changed files with 20 additions and 7 deletions

View file

@ -3,4 +3,7 @@
@import "tailwindcss/utilities";
@import "./lolight.css";
@import "./lightbox.css";
@import "./lightbox.css";
/* Set appropriate width for identity icons */
a[rel] svg { width: 1em; }

View file

@ -6,7 +6,7 @@ defmodule Chiya.Identities.Identity do
field :name, :string
field :url, :string
field :rel, :string, default: "me"
field :icon, :string, default: "cube"
field :icon, :string, default: ""
field :public, :boolean, default: false
field :active, :boolean, default: false

View file

@ -12,7 +12,7 @@ defmodule ChiyaWeb.CoreComponents do
alias Phoenix.LiveView.JS
import ChiyaWeb.Gettext
@doc """
Renders a horizontal line
"""

View file

@ -7,7 +7,7 @@
<.input field={f[:url]} type="text" label="Url" />
<.input field={f[:public]} type="checkbox" label="Public" />
<.input field={f[:active]} type="checkbox" label="Active" />
<.input field={f[:icon]} type="text" label="Icon" />
<.input field={f[:icon]} type="textarea" label="Icon" />
<:actions>
<.button>Save Identity</.button>
</:actions>

View file

@ -8,7 +8,7 @@
</.header>
<.table id="identities" rows={@identities} row_click={&JS.navigate(~p"/admin/identities/#{&1}")}>
<:col :let={identity} label="Icon"><%= identity.icon %></:col>
<:col :let={identity} label="Icon"><%= raw identity.icon %></:col>
<:col :let={identity} label="Name"><%= identity.name %></:col>
<:col :let={identity} label="Rel"><%= identity.rel %></:col>
<:col :let={identity} label="Url"><%= identity.url %></:col>

View file

@ -6,6 +6,7 @@
<p class="mt-4 text-base leading-7 text-gray-600">
<%= @settings.subtitle %>
</p>
<div class="w-full mt-6 sm:w-auto">
<div class="flex gap-4 text-sm leading-6 text-gray-700">
<%= for identity <- @identities do %>
@ -16,7 +17,7 @@
target="_blank"
class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-gray-50 hover:text-gray-900"
>
<.icon name="hero-cube" />
<%= raw identity.icon %>
<%= identity.name %>
</a>
</div>

View file

@ -12,4 +12,4 @@ defmodule Chiya.Repo.Migrations.CreateNoteImages do
create index(:note_images, [:note_id])
end
end
end

View file

@ -0,0 +1,9 @@
defmodule Chiya.Repo.Migrations.ChangeIdentityIconToText do
use Ecto.Migration
def change do
alter table(:identities) do
modify :icon, :text, from: :string
end
end
end