@adatechnology/content-ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -2
- package/dist/index.d.ts +600 -0
- package/dist/index.js +1497 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +607 -0
- package/dist/styles.css.map +1 -0
- package/package.json +44 -3
package/README.md
CHANGED
|
@@ -1,3 +1,113 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adatechnology/content-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Telas de **blog / novidades / notícias** para React 18+: painel (lista e editor com Markdown, prévia
|
|
4
|
+
ao vivo, capa, tags, SEO, agendamento) e site público (card, lista com paginação e filtro de tag,
|
|
5
|
+
página do post com compartilhamento). Pareado com `@adatechnology/content-module`, mas não faz
|
|
6
|
+
`fetch`: o host injeta a API.
|
|
7
|
+
|
|
8
|
+
## Instalação
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bun add @adatechnology/content-ui @adatechnology/content-contracts
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import '@adatechnology/content-ui/styles.css'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Painel
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { ContentProvider, ContentWorkspace, type ContentAdminApi } from '@adatechnology/content-ui'
|
|
22
|
+
|
|
23
|
+
const adminApi: ContentAdminApi = {
|
|
24
|
+
listPosts: (params) => http.get('/v1/content/posts', { params }), // → { data, pagination }
|
|
25
|
+
getPost: (id) => http.get(`/v1/content/posts/${id}`).then((r) => r.data),
|
|
26
|
+
createPost: (input) => http.post('/v1/content/posts', input).then((r) => r.data),
|
|
27
|
+
updatePost: (id, input) => http.patch(`/v1/content/posts/${id}`, input).then((r) => r.data),
|
|
28
|
+
publishPost: (id, input) => http.post(`/v1/content/posts/${id}/publish`, input).then((r) => r.data),
|
|
29
|
+
unpublishPost: (id) => http.post(`/v1/content/posts/${id}/unpublish`).then((r) => r.data),
|
|
30
|
+
archivePost: (id) => http.delete(`/v1/content/posts/${id}`),
|
|
31
|
+
listTags: () => http.get('/v1/content/posts/tags').then((r) => r.data), // opcional
|
|
32
|
+
uploadCoverImage: (file) => http.post('/v1/content/posts/cover-images', file, { // opcional
|
|
33
|
+
headers: { 'Content-Type': file.type },
|
|
34
|
+
}).then((r) => r.data),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
<ContentProvider adminApi={adminApi} locale="pt-BR" messages={{ listTitle: 'Novidades' }}>
|
|
38
|
+
<ContentWorkspace newPostDefaults={{ authorName: user.name }} />
|
|
39
|
+
</ContentProvider>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`ContentWorkspace` é a tela composta (lista ↔ editor). As peças também saem soltas:
|
|
43
|
+
|
|
44
|
+
| Componente | Props |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `PostList` | `onSelect(post)`, `onCreate?()`, `pageSize?`, `reloadKey?` |
|
|
47
|
+
| `PostEditor` | `postId?`, `defaults?`, `onSaved?(post)`, `onArchived?(post)`, `onClose?()` |
|
|
48
|
+
| `StatusChip` | `status` |
|
|
49
|
+
| `TagsInput` | `value`, `onChange`, `suggestions?`, `label` |
|
|
50
|
+
|
|
51
|
+
O editor protege alterações não salvas (aviso do navegador ao fechar a aba e confirmação no botão
|
|
52
|
+
Voltar), valida com o mesmo schema do servidor, gera o slug do título enquanto o autor não o edita
|
|
53
|
+
e esconde o upload quando a API não tem `uploadCoverImage`.
|
|
54
|
+
|
|
55
|
+
## Site público
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { ContentProvider, PostListPage, PostPage, buildPostMeta, type ContentPublicApi } from '@adatechnology/content-ui'
|
|
59
|
+
|
|
60
|
+
const publicApi: ContentPublicApi = {
|
|
61
|
+
listPublishedPosts: (params) => fetchJson('/v1/content/public/posts', params),
|
|
62
|
+
getPublishedPost: (slug) => fetchJson(`/v1/content/public/posts/${slug}`).then((r) => r.data),
|
|
63
|
+
listTags: () => fetchJson('/v1/content/public/tags').then((r) => r.data), // opcional
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
<ContentProvider publicApi={publicApi} renderLink={({ href, ...props }) => <Link to={href} {...props} />}>
|
|
67
|
+
<PostListPage
|
|
68
|
+
page={page}
|
|
69
|
+
tag={tag}
|
|
70
|
+
title="Novidades"
|
|
71
|
+
getPostHref={(slug) => `/blog/${slug}`}
|
|
72
|
+
getListHref={({ page, tag }) => `/blog?page=${page}${tag ? `&tag=${encodeURIComponent(tag)}` : ''}`}
|
|
73
|
+
/>
|
|
74
|
+
<PostPage slug={slug} getTagHref={(tag) => `/blog?tag=${tag}`} onLoaded={(post) => setHead(buildPostMeta(post, { url }))} />
|
|
75
|
+
</ContentProvider>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
| Componente | Props |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `PostListPage` | `page?`, `tag?`, `pageSize?`, `getPostHref(slug)`, `getListHref({ page, tag? })`, `title?` |
|
|
81
|
+
| `PostPage` | `slug`, `shareUrl?`, `shareNetworks?`, `getTagHref?`, `onLoaded?(post)`, `renderNotFound?()` |
|
|
82
|
+
| `PostCard` | `post`, `href`, `headingLevel?` |
|
|
83
|
+
| `ShareButtons` | `url`, `title`, `networks?` (`whatsapp`, `facebook`, `x`, `linkedin`) |
|
|
84
|
+
| `MarkdownContent` | `markdown`, `headingLevelOffset?` |
|
|
85
|
+
|
|
86
|
+
O corpo é renderizado do AST do `content-contracts` direto em elementos React — **sem
|
|
87
|
+
`dangerouslySetInnerHTML`**. Compartilhar usa só URLs das redes (nenhum script de terceiro), mais
|
|
88
|
+
"Copiar link" e o Web Share nativo quando o navegador tem.
|
|
89
|
+
|
|
90
|
+
## Tema
|
|
91
|
+
|
|
92
|
+
Sem cor própria: sobrescreva as variáveis no escopo do host.
|
|
93
|
+
|
|
94
|
+
```css
|
|
95
|
+
:root {
|
|
96
|
+
--adc-accent: #0f766e;
|
|
97
|
+
--adc-surface: #ffffff;
|
|
98
|
+
--adc-text: #0f172a;
|
|
99
|
+
--adc-muted: #64748b;
|
|
100
|
+
--adc-border: #e2e8f0;
|
|
101
|
+
--adc-radius-base: 12px;
|
|
102
|
+
--adc-font-title: 'Space Grotesk', system-ui;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Responsivo a partir de 375px (uma coluna; 2 em 640px; 3 e editor lado a lado em 1024px), áreas de
|
|
107
|
+
toque de 44px, `prefers-reduced-motion` respeitado.
|
|
108
|
+
|
|
109
|
+
## Textos
|
|
110
|
+
|
|
111
|
+
`pt-BR` (padrão) e `en`. `messages` sobrescreve chaves pontuais. Camada headless: `usePostEditor`,
|
|
112
|
+
`usePostList`, `useUnsavedChangesGuard`, mais os utilitários puros (`buildShareLinks`,
|
|
113
|
+
`buildPostMeta`, `draftToInput`, `validateDraft`, `buildPageItems`).
|