show identities on home, add icon to identities

This commit is contained in:
Inhji 2023-03-09 22:18:19 +01:00
parent c72ed6fca8
commit 5bf3782927
5 changed files with 25 additions and 40 deletions

View file

@ -3,12 +3,13 @@ defmodule Chiya.Identities.Identity do
import Ecto.Changeset
schema "identities" do
field :active, :boolean, default: false
field :name, :string
field :public, :boolean, default: false
field :rel, :string
field :url, :string
field :icon, :string
field :rel, :string, default: "me"
field :icon, :string, default: "cube"
field :public, :boolean, default: false
field :active, :boolean, default: false
timestamps()
end
@ -16,7 +17,7 @@ defmodule Chiya.Identities.Identity do
@doc false
def changeset(identity, attrs) do
identity
|> cast(attrs, [:name, :rel, :url, :public, :active, :icon])
|> validate_required([:name, :rel, :url, :public, :active, :icon])
|> cast(attrs, [:name, :rel, :url, :icon])
|> validate_required([:name, :rel, :url, :icon])
end
end

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="checkbox" label="Icon" />
<.input field={f[:icon]} type="text" label="Icon" />
<:actions>
<.button>Save Identity</.button>
</:actions>

View file

@ -8,6 +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="Name"><%= identity.name %></:col>
<:col :let={identity} label="Rel"><%= identity.rel %></:col>
<:col :let={identity} label="Url"><%= identity.url %></:col>

View file

@ -9,6 +9,7 @@
</.header>
<.list>
<:item title="Icon"><.icon name={@identity.icon} class="w-5 h-5" /></:item>
<:item title="Name"><%= @identity.name %></:item>
<:item title="Rel"><%= @identity.rel %></:item>
<:item title="Url"><%= @identity.url %></:item>

View file

@ -6,41 +6,23 @@
<p class="mt-4 text-base leading-7 text-zinc-600">
<%= @settings.subtitle %>
</p>
<div class="flex">
<div class="w-full sm:w-auto">
<div class="mt-10 grid grid-cols-1 gap-y-4 text-sm leading-6 text-zinc-700 sm:grid-cols-2">
<div>
<a
href="https://fullvoid.de/@inhji"
class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-zinc-50 hover:text-zinc-900"
>
<svg
viewBox="0 0 16 16"
aria-hidden="true"
class="h-4 w-4 fill-zinc-400 group-hover:fill-zinc-600"
>
<path d="M5.403 14c5.283 0 8.172-4.617 8.172-8.62 0-.131 0-.262-.008-.391A6.033 6.033 0 0 0 15 3.419a5.503 5.503 0 0 1-1.65.477 3.018 3.018 0 0 0 1.263-1.676 5.579 5.579 0 0 1-1.824.736 2.832 2.832 0 0 0-1.63-.916 2.746 2.746 0 0 0-1.821.319A2.973 2.973 0 0 0 8.076 3.78a3.185 3.185 0 0 0-.182 1.938 7.826 7.826 0 0 1-3.279-.918 8.253 8.253 0 0 1-2.64-2.247 3.176 3.176 0 0 0-.315 2.208 3.037 3.037 0 0 0 1.203 1.836A2.739 2.739 0 0 1 1.56 6.22v.038c0 .7.23 1.377.65 1.919.42.54 1.004.912 1.654 1.05-.423.122-.866.14-1.297.052.184.602.541 1.129 1.022 1.506a2.78 2.78 0 0 0 1.662.598 5.656 5.656 0 0 1-2.007 1.074A5.475 5.475 0 0 1 1 12.64a7.827 7.827 0 0 0 4.403 1.358" />
</svg>
Follow me on Mastodon
</a>
</div>
<div>
<a
href="https://git.inhji.de"
class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-zinc-50 hover:text-zinc-900"
>
<svg
viewBox="0 0 16 16"
aria-hidden="true"
class="h-4 w-4 fill-zinc-400 group-hover:fill-zinc-600"
>
<path d="M8 13.833c3.866 0 7-2.873 7-6.416C15 3.873 11.866 1 8 1S1 3.873 1 7.417c0 1.081.292 2.1.808 2.995.606 1.05.806 2.399.086 3.375l-.208.283c-.285.386-.01.905.465.85.852-.098 2.048-.318 3.137-.81a3.717 3.717 0 0 1 1.91-.318c.263.027.53.041.802.041Z" />
</svg>
Check my code
</a>
</div>
<div class="w-full mt-6 sm:w-auto">
<div class="flex gap-4 text-sm leading-6 text-zinc-700">
<%= for identity <- @identities do %>
<div>
<a
rel={identity.rel}
href={identity.url}
target="_blank"
class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-zinc-50 hover:text-zinc-900"
>
<.icon name="hero-cube" />
<%= identity.name %>
</a>
</div>
<% end %>
</div>
</div>
</div>
</div>