|
|
@ -2,35 +2,40 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents.AuthorCard do
|
|
|
|
use Phoenix.Component
|
|
|
|
use Phoenix.Component
|
|
|
|
use DecentralisedBookIndexWeb, :verified_routes
|
|
|
|
use DecentralisedBookIndexWeb, :verified_routes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias DecentralisedBookIndex.Accounts.Role
|
|
|
|
|
|
|
|
|
|
|
|
attr(:author, :map, required: true)
|
|
|
|
attr(:author, :map, required: true)
|
|
|
|
|
|
|
|
attr :current_user, :map, default: nil
|
|
|
|
|
|
|
|
|
|
|
|
def author_card(assigns) do
|
|
|
|
def author_card(assigns) do
|
|
|
|
~H"""
|
|
|
|
~H"""
|
|
|
|
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
|
|
|
<div class="w-full max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700 mx-auto my-3">
|
|
|
|
<div class="flex justify-end px-4 pt-4">
|
|
|
|
<%= if @current_user != nil and Role.can_moderate?(@current_user.role) do %>
|
|
|
|
<button id={"dropdownButton#{@author.id}"} data-dropdown-toggle={"dropdown#{@author.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
|
|
|
<div class="flex justify-end px-4 pt-4">
|
|
|
|
<span class="sr-only">Open dropdown</span>
|
|
|
|
<button id={"dropdownButton#{@author.id}"} data-dropdown-toggle={"dropdown#{@author.id}"} class="inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button">
|
|
|
|
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
|
|
|
<span class="sr-only">Open dropdown</span>
|
|
|
|
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
|
|
|
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 3">
|
|
|
|
</svg>
|
|
|
|
<path d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/>
|
|
|
|
</button>
|
|
|
|
</svg>
|
|
|
|
<!-- Dropdown menu -->
|
|
|
|
</button>
|
|
|
|
<div id={"dropdown#{@author.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
|
|
|
<!-- Dropdown menu -->
|
|
|
|
<ul class="py-2" aria-labelledby="dropdownButton">
|
|
|
|
<div id={"dropdown#{@author.id}"} class="z-10 hidden text-base list-none bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-44 dark:bg-gray-700">
|
|
|
|
<li>
|
|
|
|
<ul class="py-2" aria-labelledby="dropdownButton">
|
|
|
|
<.link navigate={~p"/authors/#{@author.id}/edit"}
|
|
|
|
<li>
|
|
|
|
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
|
|
|
<.link navigate={~p"/authors/#{@author.id}/edit"}
|
|
|
|
>
|
|
|
|
class="flex items-center block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
|
|
>
|
|
|
|
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-2 -ml-0.5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
|
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
|
|
|
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path>
|
|
|
|
</svg>
|
|
|
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path>
|
|
|
|
Edit
|
|
|
|
</svg>
|
|
|
|
</.link>
|
|
|
|
Edit
|
|
|
|
</li>
|
|
|
|
</.link>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<div class="flex flex-col items-center py-5 text-center">
|
|
|
|
<div class="flex flex-col items-center py-5 text-center">
|
|
|
|
<.link navigate={~p"/authors/#{@author.id}"}>
|
|
|
|
<.link navigate={~p"/authors/#{@author.id}"}>
|
|
|
|
<%= if @author.avatar_url != nil do %>
|
|
|
|
<%= if @author.avatar_url != nil do %>
|
|
|
|