feat: apresentar guias educativos com imagem resumo e contexto

This commit is contained in:
2026-10-20 19:45:45 +02:00
parent 0e7d51f18f
commit 3258a25f76
15 changed files with 350 additions and 72 deletions
@@ -0,0 +1,73 @@
import { Link } from '@inertiajs/react';
export type EducationalArticle = {
title: string;
href: string;
summary: string;
author?: string;
image: { href: string; alt: string } | null;
opportunities_href?: string | null;
opportunities_label?: string | null;
has_opportunities?: boolean;
};
export default function EducationalArticleCard({
article,
}: {
article: EducationalArticle;
}) {
const focus =
'focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-emerald-800';
return (
<article className="flex min-w-0 flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white text-slate-900 shadow-sm">
{article.image && (
<img
className="aspect-[16/9] w-full object-cover"
src={article.image.href}
alt={article.image.alt}
loading="lazy"
width={800}
height={450}
/>
)}
<div className="flex flex-1 flex-col items-start gap-4 p-5 sm:p-6">
<p className="text-sm font-medium text-emerald-800">
Guia sectorial
</p>
<h3 className="text-2xl leading-tight font-bold">
<Link href={article.href} className={focus}>
{article.title}
</Link>
</h3>
{article.summary && (
<p className="text-base leading-relaxed text-slate-700">
{article.summary}
</p>
)}
{article.author && (
<p className="text-sm text-slate-600">
Por {article.author}
</p>
)}
<div className="mt-auto flex flex-wrap items-center gap-x-5 gap-y-3 pt-2">
<Link
href={article.href}
className={`inline-flex min-h-11 items-center rounded-lg bg-emerald-900 px-5 py-3 font-semibold text-white hover:bg-emerald-800 ${focus}`}
>
Ler o guia
</Link>
{article.has_opportunities &&
article.opportunities_href && (
<Link
href={article.opportunities_href}
className={`inline-flex min-h-11 items-center py-2 font-semibold text-emerald-900 underline underline-offset-4 ${focus}`}
>
{article.opportunities_label ??
'Ver oportunidades'}
</Link>
)}
</div>
</div>
</article>
);
}
@@ -0,0 +1,27 @@
import EducationalArticleCard, {
type EducationalArticle,
} from './educational-article-card';
export default function EducationalGuides({
articles,
}: {
articles: EducationalArticle[];
}) {
if (!articles.length) return null;
return (
<section
aria-label="Guias para preparar o investimento"
className="space-y-5"
>
<h2 className="text-2xl font-bold">Descubra onde investir</h2>
<div className="grid gap-6 md:grid-cols-2">
{articles.map((article) => (
<EducationalArticleCard
key={article.href}
article={article}
/>
))}
</div>
</section>
);
}
+6 -25
View File
@@ -1,11 +1,9 @@
import { Link } from '@inertiajs/react';
import EducationalArticleCard, {
type EducationalArticle,
} from './educational-article-card';
export type SectorEntryData = {
articles: {
title: string;
href: string;
image: { href: string; alt: string } | null;
scope: string;
}[];
articles: EducationalArticle[];
relations: {
id: string;
title: string;
@@ -66,9 +64,7 @@ export default function SectorEntry({ data }: { data: SectorEntryData }) {
perfil e a modalidade já autorizados; se ainda não tem perfil,
pode preparar a ideia e pedir o perfil de promotor.
</p>
<h2 className="text-xl font-bold">
Conteúdo e possibilidades de negócio
</h2>
<h2 className="text-xl font-bold">Descubra onde investir</h2>
{data.content_notice && <p>{data.content_notice}</p>}
{!data.articles.length && (
<p>
@@ -78,22 +74,7 @@ export default function SectorEntry({ data }: { data: SectorEntryData }) {
)}
<div className="grid gap-4 md:grid-cols-2">
{data.articles.map((a) => (
<article
className="min-w-0 rounded border p-4"
key={a.href}
>
{a.image && (
<img
className="mb-3 h-36 w-full object-cover"
src={a.image.href}
alt={a.image.alt}
/>
)}
<Link className="font-semibold underline" href={a.href}>
{a.title}
</Link>
<p>{a.scope}</p>
</article>
<EducationalArticleCard key={a.href} article={a} />
))}
</div>
{data.specialization_href && (
@@ -1,3 +1,5 @@
import EducationalGuides from '@/components/educational-guides';
import type { EducationalArticle } from '@/components/educational-article-card';
import OpportunitySearchFilters from '@/components/opportunity-search-filters';
import SearchState from '@/components/search-state';
import { Link, router, useForm, usePage } from '@inertiajs/react';
@@ -14,6 +16,7 @@ type Feature = {
properties: { id: number; title: string; location: string; url: string };
};
export default function Catalogue({
guides = [],
filters,
references,
results,
@@ -22,6 +25,7 @@ export default function Catalogue({
territorySelection,
catalogueUrl,
}: {
guides?: EducationalArticle[];
filters: Record<string, string | string[] | boolean>;
references: References;
results: {
@@ -712,6 +716,7 @@ export default function Catalogue({
</div>
</section>
)}
<EducationalGuides articles={guides} />
</Frame>
);
}
+5
View File
@@ -1,3 +1,5 @@
import EducationalGuides from '@/components/educational-guides';
import type { EducationalArticle } from '@/components/educational-article-card';
import { ClassificationSummary } from '@/components/opportunity-classification';
import { Link, router, usePage } from '@inertiajs/react';
import { useState } from 'react';
@@ -10,12 +12,14 @@ import TerritorialSources from '@/components/territorial-source-evidence';
import { Frame, card, button, money, groupLabels } from './shared';
import type { Opportunity, Context } from './shared';
export default function Detail({
guides = [],
record: r,
context: c,
zone_origin,
returnUrl = '/oportunidades',
dossierOrigin,
}: {
guides?: EducationalArticle[];
record: Opportunity;
context: Context;
zone_origin?: { id: string; name: string } | null;
@@ -309,6 +313,7 @@ export default function Detail({
</p>
)}
</section>
<EducationalGuides articles={guides} />
</Frame>
);
}
+12 -31
View File
@@ -1,6 +1,13 @@
import { Head, Link, useForm } from '@inertiajs/react';
import EducationalArticleCard, {
type EducationalArticle,
} from '@/components/educational-article-card';
export type LegacyArticle = {
summary: string;
opportunities_href?: string | null;
opportunities_label?: string | null;
has_opportunities?: boolean;
id: number;
title: string;
author: string;
@@ -13,12 +20,7 @@ export type LegacyArticle = {
landing_href: string;
start_href: string;
group: { label: string; heading: string };
related_articles: {
id: number;
slug: string;
title: string;
href: string;
}[];
related_articles: (EducationalArticle & { id: number })[];
html: string;
library_href: string;
image: { href: string; alt: string; source_url: string } | null;
@@ -153,29 +155,10 @@ export default function LegacySector({
{match ? (
<div className="grid gap-4 sm:grid-cols-2">
{articles.map((item) => (
<article
<EducationalArticleCard
key={item.id}
className="space-y-3 rounded-xl border bg-white p-5"
>
<h3 className="text-xl font-semibold">
<Link
className="underline"
href={item.href}
>
{item.title}
</Link>
</h3>
<p>
Conteúdo editorial preservado do portal
Tempo.
</p>
<Link
className="inline-block rounded bg-[#10352b] px-5 py-3 text-white"
href={item.href}
>
Ler o artigo
</Link>
</article>
article={item}
/>
))}
</div>
) : (
@@ -199,9 +182,7 @@ export default function LegacySector({
<ul className="grid gap-3 sm:grid-cols-2">
{article.related_articles.map((item) => (
<li key={item.id}>
<Link className="underline" href={item.href}>
{item.title}
</Link>
<EducationalArticleCard article={item} />
</li>
))}
</ul>