Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 61 additions & 55 deletions app-modules/portal/resources/views/articles.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,74 @@
<div x-data="articlesFeed(@js($feedItems))" class="pb-20">
<x-portal::articles.opening-band :stats="$stats" />

<div class="hp-page grid gap-7 lg:grid-cols-[minmax(0,1fr)_320px]">
<div class="min-w-0">
@if ($articles === [])
{{-- O catálogo é preenchido pelo sync; até a primeira rodada rodar, a
página diz o que houve em vez de fingir que ninguém escreveu. --}}
<div class="border-outline-low bg-elevation-01dp flex flex-col items-center gap-3 rounded-lg border border-dashed p-12 text-center">
<p class="text-text-high text-sm font-semibold">Ainda não há artigos por aqui.</p>
<p class="text-text-medium max-w-sm text-xs">
O acervo da comunidade é publicado no dev.to. Enquanto ele não aparece aqui, vá direto
para a organização.
</p>
<x-he4rt::button href="https://dev.to/he4rt" target="_blank" rel="noopener" size="sm">
Abrir no dev.to
</x-he4rt::button>
</div>
@else
@if ($highlight)
<div class="hp-page">
@if ($articles !== [] && $highlight)
{{-- Mesmas colunas do grid abaixo, só para o destaque herdar a largura
da coluna de artigos em vez de ocupar a página inteira. --}}
<div class="grid lg:grid-cols-[minmax(0,1fr)_320px] lg:gap-7">
<x-portal::articles.featured :article="$highlight" />
@endif

<x-portal::articles.toolbar :topics="$topics" :total="count($articles)" />

{{-- A grade é o padrão do servidor; o Alpine só troca para lista. Assim a
página nasce com layout correto mesmo antes (ou sem) o JS. --}}
<div
class="grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(260px,1fr))]"
x-bind:class="view === 'list' ? 'is-list !grid-cols-1' : ''"
>
@foreach ($articles as $index => $article)
<x-portal::articles.card :article="$article" :index="$index" />
@endforeach
</div>
@endif

<div class="grid gap-7 lg:grid-cols-[minmax(0,1fr)_320px]">
<div class="min-w-0">
@if ($articles === [])
{{-- O catálogo é preenchido pelo sync; até a primeira rodada rodar, a
página diz o que houve em vez de fingir que ninguém escreveu. --}}
<div class="border-outline-low bg-elevation-01dp flex flex-col items-center gap-3 rounded-lg border border-dashed p-12 text-center">
<p class="text-text-high text-sm font-semibold">Ainda não há artigos por aqui.</p>
<p class="text-text-medium max-w-sm text-xs">
O acervo da comunidade é publicado no dev.to. Enquanto ele não aparece aqui, vá direto
para a organização.
</p>
<x-he4rt::button href="https://dev.to/he4rt" target="_blank" rel="noopener" size="sm">
Abrir no dev.to
</x-he4rt::button>
</div>
@else
<x-portal::articles.toolbar :topics="$topics" :total="count($articles)" />

{{-- A grade é o padrão do servidor; o Alpine só troca para lista. Assim a
página nasce com layout correto mesmo antes (ou sem) o JS. --}}
<div
class="grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(260px,1fr))]"
x-bind:class="view === 'list' ? 'is-list !grid-cols-1' : ''"
>
@foreach ($articles as $index => $article)
<x-portal::articles.card :article="$article" :index="$index" />
@endforeach
</div>

<div
x-show="visibleCount === 0"
x-cloak
style="display: none"
class="border-outline-low bg-elevation-01dp mt-4 flex flex-col items-center gap-3 rounded-lg border border-dashed p-10 text-center"
>
<p class="text-text-high text-sm font-semibold">Nenhum artigo com essa combinação.</p>
<p class="text-text-medium max-w-sm text-xs">
O tema e a pessoa selecionados não se cruzam no acervo. As duas listas seguem ativas — dá para
trocar o recorte sem sair daqui.
</p>
<button
type="button"
x-on:click="clearAll()"
class="from-primary to-secondary text-text-light cursor-pointer rounded-md bg-gradient-to-br px-4 py-2 text-xs font-semibold transition-all duration-300 hover:scale-[1.02] active:scale-95"
<div
x-show="visibleCount === 0"
x-cloak
style="display: none"
class="border-outline-low bg-elevation-01dp mt-4 flex flex-col items-center gap-3 rounded-lg border border-dashed p-10 text-center"
>
limpar tudo
</button>
<p class="text-text-high text-sm font-semibold">Nenhum artigo com essa combinação.</p>
<p class="text-text-medium max-w-sm text-xs">
O tema e a pessoa selecionados não se cruzam no acervo. As duas listas seguem ativas — dá para
trocar o recorte sem sair daqui.
</p>
<button
type="button"
x-on:click="clearAll()"
class="from-primary to-secondary text-text-light cursor-pointer rounded-md bg-gradient-to-br px-4 py-2 text-xs font-semibold transition-all duration-300 hover:scale-[1.02] active:scale-95"
>
limpar tudo
</button>
</div>
@endif
</div>

{{-- No telefone a coluna de pessoas vai para baixo do feed: empilhar 17 linhas
acima dos cards custaria a dobra inteira. --}}
@if ($authors !== [])
<div class="order-last lg:sticky lg:top-4 lg:order-0 lg:mt-8 lg:self-start">
<x-portal::articles.author-rail :authors="$authors" />
</div>
@endif
</div>

{{-- No telefone a coluna de pessoas vai para baixo do feed: empilhar 17 linhas
acima dos cards custaria a dobra inteira. --}}
@if ($authors !== [])
<div class="order-last lg:sticky lg:top-4 lg:order-none lg:self-start">
<x-portal::articles.author-rail :authors="$authors" />
</div>
@endif
</div>

{{-- Componente class-based: o Livewire 4 exige @assets/@script para JS de componente.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
@endphp

<aside class="flex flex-col gap-3" aria-labelledby="articles-authors-heading">
<div class="flex items-baseline justify-between gap-2">
<h2 id="articles-authors-heading" class="text-text-medium font-mono text-xs tracking-[0.2em] uppercase">
Quem escreve
</h2>
<span class="text-text-low font-mono text-[0.65rem]">artigos · reações</span>
</div>
<h2 id="articles-authors-heading" class="text-text-medium font-mono text-xs tracking-[0.2em] uppercase">
Quem escreve
</h2>

{{-- Volume e alcance divergem no acervo: quem publicou uma vez pode ter mais
reações que quem publicou quatro. Por isso as duas ordens são oferecidas. --}}
Expand All @@ -35,29 +32,41 @@ class="flex-1 cursor-pointer rounded-md border px-2 py-1.5 text-xs font-medium t
@endforeach
</div>

<ul class="flex flex-col">
@foreach ($authors as $author)
<li x-bind:style="{ order: authorSort === 'reactions' ? {{ $reactionRank[$author->username] }} : {{ $loop->index }} }">
<button
type="button"
x-on:click="toggleAuthor(@js($author->username))"
x-bind:aria-pressed="author === @js($author->username) ? 'true' : 'false'"
x-bind:class="{ 'bg-primary/16': author === @js($author->username) }"
class="hover:bg-primary/10 text-text-high flex w-full cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-start transition-colors duration-200"
>
<x-portal::articles.author-avatar :name="$author->name" :avatar="$author->avatar" size="size-7" />
<span class="min-w-0 flex-1 truncate text-xs font-medium">{{ $author->name }}</span>
<span class="text-text-medium shrink-0 font-mono text-xs tabular-nums">
{{ $author->articleCount }}
<span class="text-text-low mx-0.5" aria-hidden="true">·</span>
{{ $author->reactions }}
</span>
</button>
</li>
@endforeach
</ul>
<div class="text-text-low mt-2 flex items-center justify-end gap-2 pe-2 font-medium text-[0.7rem]">
<span class="flex w-14 items-center justify-end gap-1">
<x-heroicon-o-document-text class="size-3" />
artigos
</span>
<span class="flex w-14 items-center justify-end gap-1">
<x-heroicon-o-heart class="text-primary dark:text-purple-400 size-3" />
reações
</span>
</div>

<p class="text-text-low border-outline-low border-t pt-3 font-mono text-[0.65rem]">
{{ count($authors) }} pessoas no acervo
</p>
<div class="bg-elevation-02dp flex flex-col gap-2 rounded-lg p-3">
<ul class="flex flex-col">
@foreach ($authors as $author)
<li x-bind:style="{ order: authorSort === 'reactions' ? {{ $reactionRank[$author->username] }} : {{ $loop->index }} }">
<button
type="button"
x-on:click="toggleAuthor(@js($author->username))"
x-bind:aria-pressed="author === @js($author->username) ? 'true' : 'false'"
x-bind:class="{ 'bg-primary/16': author === @js($author->username) }"
class="hover:bg-primary/10 text-text-high flex w-full cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-start transition-colors duration-200"
>
<x-portal::articles.author-avatar :name="$author->name" :avatar="$author->avatar" size="size-7" />
<span class="min-w-0 flex-1 truncate text-xs font-medium">{{ $author->name }}</span>
<span class="flex shrink-0 items-center gap-0.5 font-mono font-medium text-xs tabular-nums">
<span class="text-text-low w-14 text-end">{{ $author->articleCount }}</span>
<span class="text-primary dark:text-purple-400 w-14 text-end">{{ $author->reactions }}</span>
</span>
</button>
</li>
@endforeach
</ul>

<p class="text-text-low border-outline-low border-t pt-3 font-mono text-[0.65rem]">
{{ count($authors) }} pessoas no acervo
</p>
</div>
</aside>
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,24 @@

<article
x-show="isVisible({{ $index }})"
class="border-outline-low bg-elevation-01dp hover:border-primary relative flex flex-col gap-3 rounded-lg border p-4 transition-[border-color,transform] duration-300 hover:scale-[1.02] motion-reduce:transition-none motion-reduce:hover:scale-100 [.is-list_&]:flex-row [.is-list_&]:items-start [.is-list_&]:gap-4 [.is-list_&]:hover:scale-100"
class="bg-elevation-02dp border-primary/16 has-[a:focus-visible]:ring-primary relative flex flex-col overflow-hidden rounded-l-none rounded-r-lg border-l-2 shadow-sm shadow-text-high/8 transition-[background-color,box-shadow,transform] duration-200 ease-out hover:-translate-y-0.75 hover:bg-elevation-03dp hover:shadow-md has-[a:focus-visible]:ring-2 motion-reduce:transition-none motion-reduce:hover:translate-y-0 [.is-list_&]:flex-row"
>
@if ($article->coverImage)
<img
src="{{ $article->coverImage }}"
alt=""
loading="lazy"
decoding="async"
class="aspect-video w-full shrink-0 rounded-sm object-cover [.is-list_&]:w-28"
/>
@else
<x-portal::articles.cover-fallback class="aspect-video w-full shrink-0 rounded-sm [.is-list_&]:w-28" />
@endif

<div class="flex min-w-0 flex-1 flex-col gap-2">
@if ($article->tags !== [])
<ul class="flex flex-wrap gap-1.5">
@foreach (array_slice($article->tags, 0, 2) as $tag)
<li
class="border-primary/32 bg-primary/5 text-text-medium rounded-lg border px-2 py-0.5 font-mono text-[0.65rem]"
>
#{{ $tag }}
</li>
@endforeach
</ul>
<div class="shrink-0 [.is-list_&]:w-40 sm:[.is-list_&]:w-56">
@if ($article->coverImage)
<img
src="{{ $article->coverImage }}"
alt=""
loading="lazy"
decoding="async"
class="aspect-video w-full object-cover [.is-list_&]:aspect-auto [.is-list_&]:h-full"
/>
@else
<x-portal::articles.cover-fallback class="aspect-video w-full [.is-list_&]:aspect-auto [.is-list_&]:h-full" />
@endif
</div>

<h3 class="text-text-high line-clamp-3 text-sm leading-snug font-semibold">
<div class="flex min-w-0 flex-1 flex-col px-4 pt-3.5 pb-4">
<h3 class="text-text-high line-clamp-3 text-sm leading-snug font-medium">
<a
href="{{ $article->url }}"
target="_blank"
Expand All @@ -44,17 +34,38 @@ class="after:absolute after:inset-0 focus-visible:outline-none"
</h3>

{{-- A descrição já vem truncada da fonte; o clamp evita que o "…" dela pareça quebra de layout. --}}
<p class="text-text-medium line-clamp-2 text-xs leading-relaxed">{{ $article->description }}</p>
<p class="text-text-medium mt-1 line-clamp-2 text-xs leading-relaxed">{{ $article->description }}</p>

<div class="text-text-medium mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 pt-1 text-[0.7rem]">
<span class="flex min-w-0 items-center gap-1.5">
<x-portal::articles.author-avatar :name="$article->authorName" :avatar="$article->authorAvatar" size="size-4" />
<span class="text-text-high truncate font-medium">{{ $article->authorName }}</span>
</span>
<span class="ms-auto flex items-center gap-2.5 font-mono tabular-nums">
<span title="reações">♥ {{ $article->reactions }}</span>
<span title="comentários">💬 {{ $article->comments }}</span>
<span title="tempo de leitura">{{ $article->readingMinutes }} min</span>
@if ($article->tags !== [])
<ul class="mt-2.5 flex flex-wrap gap-1.5">
@foreach (array_slice($article->tags, 0, 2) as $tag)
<li
class="bg-text-high/6 text-text-medium rounded-md px-2 py-1 font-mono text-[0.75rem] leading-none"
>
#{{ $tag }}
</li>
@endforeach
</ul>
@endif

{{-- O pt-4 garante respiro claro entre as tags e o rodapé; o mt-auto alinha o rodapé entre cards de alturas diferentes. --}}
<div class="mt-auto flex items-center gap-2 pt-4 text-[0.7rem] font-medium">
<x-portal::articles.author-avatar :name="$article->authorName" :avatar="$article->authorAvatar" size="size-4" />
<span class="text-text-medium truncate font-medium">{{ $article->authorName }}</span>

<span class="text-text-medium ms-auto flex shrink-0 items-center gap-2.5 font-mono tabular-nums">
<span title="reações" class="flex items-center gap-1">
<x-heroicon-o-heart class="text-icon-medium size-3.5" />
{{ $article->reactions }}
</span>
<span title="comentários" class="flex items-center gap-1">
<x-heroicon-o-chat-bubble-left-ellipsis class="text-icon-medium size-3.5" />
{{ $article->comments }}
</span>
<span title="tempo de leitura" class="flex items-center gap-1">
<x-heroicon-o-clock class="text-icon-medium size-3.5" />
{{ $article->readingMinutes }} min
</span>
</span>
</div>
</div>
Expand Down
Loading
Loading