@juau/zuri 0.0.1 → 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 +16 -4
- package/fesm2022/juau-zuri.mjs +2048 -481
- package/fesm2022/juau-zuri.mjs.map +1 -1
- package/package.json +5 -1
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +79 -0
- package/schematics/ng-add/schema.json +13 -0
- package/schematics/package.json +3 -0
- package/styles/tokens.css +12 -1
- package/types/juau-zuri.d.ts +463 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juau/zuri",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Design system para Angular: componentes standalone, layouts de página e tema claro/escuro.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
42
|
+
"schematics": "./schematics/collection.json",
|
|
43
|
+
"ng-add": {
|
|
44
|
+
"save": "dependencies"
|
|
45
|
+
},
|
|
42
46
|
"publishConfig": {
|
|
43
47
|
"access": "public"
|
|
44
48
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Configura o Zuri: tokens, fonte Nunito Sans e estilo base do body.",
|
|
6
|
+
"factory": "./ng-add/index#ngAdd",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ngAdd = ngAdd;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
+
const TOKENS_IMPORT = "@import '@juau/zuri/styles/tokens.css';";
|
|
7
|
+
const FONT_HREF = 'https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;800&display=swap';
|
|
8
|
+
const FONT_LINKS = [
|
|
9
|
+
'<link rel="preconnect" href="https://fonts.googleapis.com" />',
|
|
10
|
+
'<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />',
|
|
11
|
+
`<link href="${FONT_HREF}" rel="stylesheet" />`,
|
|
12
|
+
];
|
|
13
|
+
const BODY_RULE = `
|
|
14
|
+
body {
|
|
15
|
+
margin: 0;
|
|
16
|
+
background: var(--zur-canvas);
|
|
17
|
+
color: var(--zur-body);
|
|
18
|
+
font: var(--zur-font-body);
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
/**
|
|
22
|
+
* `ng add @juau/zuri`: importa os tokens no styles global, aplica o estilo base do
|
|
23
|
+
* body e coloca a fonte Nunito Sans no index.html. Pode rodar mais de uma vez sem
|
|
24
|
+
* duplicar nada.
|
|
25
|
+
*/
|
|
26
|
+
function ngAdd(options) {
|
|
27
|
+
return async (tree, context) => {
|
|
28
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
29
|
+
const projectName = options.project ??
|
|
30
|
+
Array.from(workspace.projects.keys()).find((name) => workspace.projects.get(name)?.extensions['projectType'] === 'application');
|
|
31
|
+
const project = projectName ? workspace.projects.get(projectName) : undefined;
|
|
32
|
+
if (!project) {
|
|
33
|
+
throw new schematics_1.SchematicsException('Nenhuma aplicação encontrada. Use --project <nome>.');
|
|
34
|
+
}
|
|
35
|
+
const buildOptions = (project.targets.get('build')?.options ?? {});
|
|
36
|
+
const root = project.sourceRoot ?? `${project.root ? project.root + '/' : ''}src`;
|
|
37
|
+
// 1) styles global: tokens + estilo base do body
|
|
38
|
+
const styles = buildOptions['styles'] ?? [];
|
|
39
|
+
const stylePath = styles
|
|
40
|
+
.map((s) => (typeof s === 'string' ? s : s.input))
|
|
41
|
+
.find((s) => /\.(css|scss|sass|less)$/.test(s) && tree.exists(s)) ?? `${root}/styles.css`;
|
|
42
|
+
const current = tree.exists(stylePath) ? tree.readText(stylePath) : '';
|
|
43
|
+
if (current.includes('@juau/zuri/styles/tokens.css')) {
|
|
44
|
+
context.logger.info(`Tokens do Zuri já estavam em ${stylePath}.`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const body = current.includes('--zur-canvas') ? '' : BODY_RULE;
|
|
48
|
+
const next = `${TOKENS_IMPORT}\n${current.trimStart() ? '\n' + current.trimStart() : ''}${body}`;
|
|
49
|
+
if (tree.exists(stylePath))
|
|
50
|
+
tree.overwrite(stylePath, next);
|
|
51
|
+
else
|
|
52
|
+
tree.create(stylePath, next);
|
|
53
|
+
context.logger.info(`Tokens do Zuri importados em ${stylePath}.`);
|
|
54
|
+
}
|
|
55
|
+
// 2) index.html: fonte Nunito Sans
|
|
56
|
+
const indexOption = buildOptions['index'];
|
|
57
|
+
const indexPath = typeof indexOption === 'string'
|
|
58
|
+
? indexOption
|
|
59
|
+
: indexOption?.input ?? `${root}/index.html`;
|
|
60
|
+
if (!tree.exists(indexPath)) {
|
|
61
|
+
context.logger.warn(`Não achei ${indexPath}; adicione a fonte Nunito Sans à mão.`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const html = tree.readText(indexPath);
|
|
65
|
+
if (html.includes('Nunito+Sans')) {
|
|
66
|
+
context.logger.info(`A fonte Nunito Sans já estava em ${indexPath}.`);
|
|
67
|
+
}
|
|
68
|
+
else if (!html.includes('</head>')) {
|
|
69
|
+
context.logger.warn(`${indexPath} não tem </head>; adicione a fonte à mão.`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const links = FONT_LINKS.map((l) => ` ${l}`).join('\n');
|
|
73
|
+
tree.overwrite(indexPath, html.replace('</head>', `${links}\n </head>`));
|
|
74
|
+
context.logger.info(`Fonte Nunito Sans adicionada em ${indexPath}.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
context.logger.info("Pronto. Importe os componentes de '@juau/zuri' onde for usar, ex.: imports: [ZurButton].");
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "ZuriNgAdd",
|
|
4
|
+
"title": "Zuri ng-add",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Projeto que vai receber o Zuri. Padrão: a primeira aplicação do workspace.",
|
|
10
|
+
"$default": { "$source": "projectName" }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/styles/tokens.css
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
/* ── Texto ─────────────────────────────────────────────── */
|
|
26
26
|
--zur-ink: #15271f;
|
|
27
27
|
--zur-body: #3d4f47;
|
|
28
|
-
--zur-muted: #
|
|
28
|
+
--zur-muted: #5f6f67;
|
|
29
29
|
--zur-ink-inverse: #f3faf7;
|
|
30
30
|
|
|
31
31
|
/* ── Semânticas ────────────────────────────────────────── */
|
|
@@ -37,6 +37,12 @@
|
|
|
37
37
|
--zur-error-soft: #fde2e3;
|
|
38
38
|
--zur-info: #3b82f6;
|
|
39
39
|
--zur-info-soft: #dcebfe;
|
|
40
|
+
/* Texto sobre as cores semânticas (badge, alert, mensagens de erro): 4,5:1 sobre o
|
|
41
|
+
fundo soft e sobre o canvas. As cores-base acima ficam para ícones e bordas. */
|
|
42
|
+
--zur-success-text: #14794c;
|
|
43
|
+
--zur-warning-text: #a25904;
|
|
44
|
+
--zur-error-text: #c91d22;
|
|
45
|
+
--zur-info-text: #0b5ee7;
|
|
40
46
|
|
|
41
47
|
/* ── Tipografia (Nunito Sans — arredondada amigável) ───── */
|
|
42
48
|
--zur-font-family: 'Nunito Sans', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
|
|
@@ -134,6 +140,11 @@
|
|
|
134
140
|
--zur-error-soft: #3d1d20;
|
|
135
141
|
--zur-info: #60a5fa;
|
|
136
142
|
--zur-info-soft: #16293f;
|
|
143
|
+
/* no escuro as cores-base já passam de 4,5:1 sobre os fundos */
|
|
144
|
+
--zur-success-text: #34d08c;
|
|
145
|
+
--zur-warning-text: #f59e0b;
|
|
146
|
+
--zur-error-text: #f26d71;
|
|
147
|
+
--zur-info-text: #60a5fa;
|
|
137
148
|
|
|
138
149
|
/* sombra única mais pesada — sombras leves somem sobre fundo quase-preto */
|
|
139
150
|
--zur-shadow-float:
|