@salas-ds/cli 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/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/index.js +292 -0
- package/package.json +42 -0
- package/templates/angular/button/button.component.ts +176 -0
- package/templates/angular/button/button.module.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Salas Design System
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @salas-ds/cli
|
|
2
|
+
|
|
3
|
+
CLI para adicionar componentes do Salas Design System ao seu projeto Angular.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @salas-ds/cli@latest init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Uso
|
|
12
|
+
|
|
13
|
+
### Inicializar projeto
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx @salas-ds/cli@latest init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Isso criará:
|
|
20
|
+
- Diretório de componentes (`src/app/ui` por padrão)
|
|
21
|
+
- Arquivo `styles.css` com CSS variables
|
|
22
|
+
|
|
23
|
+
### Adicionar componentes
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @salas-ds/cli@latest add button
|
|
27
|
+
npx @salas-ds/cli@latest add input
|
|
28
|
+
npx @salas-ds/cli@latest add select
|
|
29
|
+
npx @salas-ds/cli@latest add autocomplete
|
|
30
|
+
npx @salas-ds/cli@latest add datepicker
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Opções
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Especificar caminho customizado
|
|
37
|
+
npx @salas-ds/cli@latest init --path src/components/ui
|
|
38
|
+
npx @salas-ds/cli@latest add button --path src/components/ui
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Componentes Disponíveis
|
|
42
|
+
|
|
43
|
+
- `button` - Botões
|
|
44
|
+
- `input` - Inputs de texto
|
|
45
|
+
- `select` - Select dropdown
|
|
46
|
+
- `autocomplete` - Autocomplete
|
|
47
|
+
- `datepicker` - Datepicker
|
|
48
|
+
|
|
49
|
+
## Próximos Passos
|
|
50
|
+
|
|
51
|
+
Após adicionar um componente:
|
|
52
|
+
|
|
53
|
+
1. Importe o módulo no seu componente ou módulo Angular
|
|
54
|
+
2. Use o componente no template
|
|
55
|
+
3. Customize conforme necessário (o código é seu!)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import chalk2 from 'chalk';
|
|
4
|
+
import fs2 from 'fs-extra';
|
|
5
|
+
import path2 from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
|
|
12
|
+
// src/theme-styles.ts
|
|
13
|
+
var THEME_CSS = `/* Salas Design System - Light & Dark theme */
|
|
14
|
+
/* Defina no <html>: data-theme="light" | "dark". Para seguir o sistema: use JS com prefers-color-scheme */
|
|
15
|
+
|
|
16
|
+
/* ========== Light (default) ========== */
|
|
17
|
+
:root,
|
|
18
|
+
[data-theme="light"] {
|
|
19
|
+
--salas-primary-50: #eff6ff;
|
|
20
|
+
--salas-primary-100: #dbeafe;
|
|
21
|
+
--salas-primary-200: #bfdbfe;
|
|
22
|
+
--salas-primary-300: #93c5fd;
|
|
23
|
+
--salas-primary-400: #60a5fa;
|
|
24
|
+
--salas-primary-500: #3b82f6;
|
|
25
|
+
--salas-primary-600: #2563eb;
|
|
26
|
+
--salas-primary-700: #1d4ed8;
|
|
27
|
+
--salas-primary-800: #1e40af;
|
|
28
|
+
--salas-primary-900: #1e3a8a;
|
|
29
|
+
--salas-primary-950: #172554;
|
|
30
|
+
--salas-success-50: #f0fdf4;
|
|
31
|
+
--salas-success-100: #dcfce7;
|
|
32
|
+
--salas-success-500: #22c55e;
|
|
33
|
+
--salas-success-600: #16a34a;
|
|
34
|
+
--salas-warning-50: #fffbeb;
|
|
35
|
+
--salas-warning-100: #fef3c7;
|
|
36
|
+
--salas-warning-500: #f59e0b;
|
|
37
|
+
--salas-warning-600: #d97706;
|
|
38
|
+
--salas-destructive-50: #fef2f2;
|
|
39
|
+
--salas-destructive-100: #fee2e2;
|
|
40
|
+
--salas-destructive-500: #ef4444;
|
|
41
|
+
--salas-destructive-600: #dc2626;
|
|
42
|
+
--salas-gray-50: #f9fafb;
|
|
43
|
+
--salas-gray-100: #f3f4f6;
|
|
44
|
+
--salas-gray-200: #e5e7eb;
|
|
45
|
+
--salas-gray-300: #d1d5db;
|
|
46
|
+
--salas-gray-400: #9ca3af;
|
|
47
|
+
--salas-gray-500: #6b7280;
|
|
48
|
+
--salas-gray-600: #4b5563;
|
|
49
|
+
--salas-gray-700: #374151;
|
|
50
|
+
--salas-gray-800: #1f2937;
|
|
51
|
+
--salas-gray-900: #111827;
|
|
52
|
+
--salas-gray-950: #030712;
|
|
53
|
+
--salas-bg: #ffffff;
|
|
54
|
+
--salas-bg-elevated: #ffffff;
|
|
55
|
+
--salas-text: #111827;
|
|
56
|
+
--salas-text-muted: #6b7280;
|
|
57
|
+
--salas-font-sans: ui-sans-serif, system-ui, sans-serif;
|
|
58
|
+
--salas-font-mono: ui-monospace, monospace;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ========== Dark (estilo shadcn: preto, branco e cinza) ========== */
|
|
62
|
+
[data-theme="dark"] {
|
|
63
|
+
--salas-primary-50: #172554;
|
|
64
|
+
--salas-primary-100: #1e3a8a;
|
|
65
|
+
--salas-primary-200: #1e40af;
|
|
66
|
+
--salas-primary-300: #1d4ed8;
|
|
67
|
+
--salas-primary-400: #2563eb;
|
|
68
|
+
--salas-primary-500: #3b82f6;
|
|
69
|
+
--salas-primary-600: #60a5fa;
|
|
70
|
+
--salas-primary-700: #93c5fd;
|
|
71
|
+
--salas-primary-800: #bfdbfe;
|
|
72
|
+
--salas-primary-900: #dbeafe;
|
|
73
|
+
--salas-primary-950: #eff6ff;
|
|
74
|
+
--salas-success-500: #22c55e;
|
|
75
|
+
--salas-success-600: #4ade80;
|
|
76
|
+
--salas-warning-500: #f59e0b;
|
|
77
|
+
--salas-warning-600: #fbbf24;
|
|
78
|
+
--salas-destructive-500: #ef4444;
|
|
79
|
+
--salas-destructive-600: #f87171;
|
|
80
|
+
--salas-gray-50: #18181b;
|
|
81
|
+
--salas-gray-100: #27272a;
|
|
82
|
+
--salas-gray-200: #3f3f46;
|
|
83
|
+
--salas-gray-300: #52525b;
|
|
84
|
+
--salas-gray-400: #71717a;
|
|
85
|
+
--salas-gray-500: #a1a1aa;
|
|
86
|
+
--salas-gray-600: #d4d4d8;
|
|
87
|
+
--salas-gray-700: #e4e4e7;
|
|
88
|
+
--salas-gray-800: #f4f4f5;
|
|
89
|
+
--salas-gray-900: #fafafa;
|
|
90
|
+
--salas-gray-950: #ffffff;
|
|
91
|
+
--salas-bg: #09090b;
|
|
92
|
+
--salas-bg-elevated: #18181b;
|
|
93
|
+
--salas-text: #fafafa;
|
|
94
|
+
--salas-text-muted: #a1a1aa;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-theme="dark"] .salas-autocomplete-dropdown,
|
|
98
|
+
[data-theme="dark"] .salas-autocomplete-no-results,
|
|
99
|
+
[data-theme="dark"] .salas-autocomplete-loading,
|
|
100
|
+
[data-theme="dark"] .salas-datepicker-calendar {
|
|
101
|
+
background-color: var(--salas-bg-elevated) !important;
|
|
102
|
+
}
|
|
103
|
+
[data-theme="dark"] .salas-input,
|
|
104
|
+
[data-theme="dark"] .salas-select,
|
|
105
|
+
[data-theme="dark"] .salas-autocomplete,
|
|
106
|
+
[data-theme="dark"] .salas-datepicker {
|
|
107
|
+
background-color: var(--salas-bg) !important;
|
|
108
|
+
border-color: var(--salas-gray-200);
|
|
109
|
+
color: var(--salas-text) !important;
|
|
110
|
+
}
|
|
111
|
+
[data-theme="dark"] .salas-input::placeholder,
|
|
112
|
+
[data-theme="dark"] .salas-datepicker { color: var(--salas-text-muted); }
|
|
113
|
+
[data-theme="dark"] .salas-autocomplete { color: var(--salas-text); }
|
|
114
|
+
[data-theme="dark"] .salas-autocomplete::placeholder { color: var(--salas-text-muted); }
|
|
115
|
+
[data-theme="dark"] button.salas-button--default {
|
|
116
|
+
background-color: #ffffff !important;
|
|
117
|
+
color: #09090b !important;
|
|
118
|
+
border: 1px solid #e4e4e7;
|
|
119
|
+
}
|
|
120
|
+
[data-theme="dark"] button.salas-button--default:hover:not(:disabled) {
|
|
121
|
+
background-color: #e4e4e7 !important;
|
|
122
|
+
}
|
|
123
|
+
[data-theme="dark"] button.salas-button--destructive {
|
|
124
|
+
background-color: #6a2622 !important;
|
|
125
|
+
color: #f1867d !important;
|
|
126
|
+
}
|
|
127
|
+
[data-theme="dark"] button.salas-button--destructive:hover:not(:disabled) {
|
|
128
|
+
background-color: #7e2f2a !important;
|
|
129
|
+
color: #f1867d !important;
|
|
130
|
+
}
|
|
131
|
+
[data-theme="dark"] button.salas-button--outline {
|
|
132
|
+
border: 1px solid #3f3f46 !important;
|
|
133
|
+
background-color: #18181b !important;
|
|
134
|
+
color: #e4e4e7 !important;
|
|
135
|
+
}
|
|
136
|
+
[data-theme="dark"] button.salas-button--outline:hover:not(:disabled) {
|
|
137
|
+
background-color: #27272a !important;
|
|
138
|
+
color: #fafafa !important;
|
|
139
|
+
}
|
|
140
|
+
[data-theme="dark"] button.salas-button--secondary {
|
|
141
|
+
background-color: #27272a !important;
|
|
142
|
+
color: #fafafa !important;
|
|
143
|
+
border: 1px solid #3f3f46;
|
|
144
|
+
}
|
|
145
|
+
[data-theme="dark"] button.salas-button--secondary:hover:not(:disabled) {
|
|
146
|
+
background-color: #3f3f46 !important;
|
|
147
|
+
color: #fafafa !important;
|
|
148
|
+
}
|
|
149
|
+
[data-theme="dark"] button.salas-button--ghost {
|
|
150
|
+
background-color: transparent !important;
|
|
151
|
+
color: var(--salas-text) !important;
|
|
152
|
+
}
|
|
153
|
+
[data-theme="dark"] button.salas-button--ghost:hover:not(:disabled) {
|
|
154
|
+
background-color: var(--salas-gray-100) !important;
|
|
155
|
+
}
|
|
156
|
+
[data-theme="dark"] button.salas-button--link {
|
|
157
|
+
color: var(--salas-text-muted) !important;
|
|
158
|
+
text-decoration: underline !important;
|
|
159
|
+
}
|
|
160
|
+
[data-theme="dark"] button.salas-button--link:hover:not(:disabled) {
|
|
161
|
+
color: var(--salas-text) !important;
|
|
162
|
+
}
|
|
163
|
+
[data-theme="dark"] .salas-datepicker-day { color: var(--salas-text); }
|
|
164
|
+
[data-theme="dark"] .salas-datepicker-day--other-month { color: var(--salas-gray-500); }
|
|
165
|
+
[data-theme="dark"] .salas-autocomplete-option { color: var(--salas-text); }
|
|
166
|
+
[data-theme="dark"] .salas-autocomplete-option:hover,
|
|
167
|
+
[data-theme="dark"] .salas-autocomplete-option--highlighted {
|
|
168
|
+
background-color: var(--salas-gray-200);
|
|
169
|
+
}
|
|
170
|
+
[data-theme="dark"] .salas-autocomplete-option--selected {
|
|
171
|
+
background-color: var(--salas-primary-600);
|
|
172
|
+
color: #ffffff;
|
|
173
|
+
}
|
|
174
|
+
[data-theme="dark"] .salas-autocomplete-no-results,
|
|
175
|
+
[data-theme="dark"] .salas-autocomplete-loading { color: var(--salas-text-muted); }
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
// src/commands/init.ts
|
|
179
|
+
var __filename$1 = fileURLToPath(import.meta.url);
|
|
180
|
+
path2.dirname(__filename$1);
|
|
181
|
+
async function initCommand(options) {
|
|
182
|
+
console.log(chalk2.blue("\u{1F680} Inicializando Salas Design System...\n"));
|
|
183
|
+
const projectRoot = process.cwd();
|
|
184
|
+
const componentsPath = path2.join(projectRoot, options.path);
|
|
185
|
+
try {
|
|
186
|
+
await fs2.ensureDir(componentsPath);
|
|
187
|
+
const cssPath = path2.join(componentsPath, "styles.css");
|
|
188
|
+
await fs2.writeFile(cssPath, THEME_CSS);
|
|
189
|
+
console.log(chalk2.green("\u2705 Salas Design System inicializado com sucesso!"));
|
|
190
|
+
console.log(chalk2.gray(` Componentes ser\xE3o adicionados em: ${options.path}`));
|
|
191
|
+
console.log(chalk2.gray(` CSS variables criado em: ${options.path}/styles.css
|
|
192
|
+
`));
|
|
193
|
+
console.log(chalk2.blue("\u{1F4A1} Pr\xF3ximos passos:"));
|
|
194
|
+
console.log(chalk2.gray(` npx @salas-ds/cli add button`));
|
|
195
|
+
console.log(chalk2.gray(` npx @salas-ds/cli add input`));
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.error(chalk2.red("\u274C Erro ao inicializar:"), error);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
202
|
+
var __dirname2 = path2.dirname(__filename2);
|
|
203
|
+
var COMPONENTS = ["button", "input", "select", "autocomplete", "datepicker"];
|
|
204
|
+
var DEFAULT_PATH = "src/components";
|
|
205
|
+
async function addCommand(componentName, options) {
|
|
206
|
+
if (!COMPONENTS.includes(componentName)) {
|
|
207
|
+
console.error(
|
|
208
|
+
chalk2.red(`\u274C Componente "${componentName}" n\xE3o encontrado.`)
|
|
209
|
+
);
|
|
210
|
+
console.log(chalk2.gray(`Componentes dispon\xEDveis: ${COMPONENTS.join(", ")}`));
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
console.log(chalk2.blue(`\u{1F4E6} Adicionando componente: ${componentName}
|
|
214
|
+
`));
|
|
215
|
+
const defaultPath = options.path ?? DEFAULT_PATH;
|
|
216
|
+
const { path: chosenPath } = await inquirer.prompt([
|
|
217
|
+
{
|
|
218
|
+
type: "input",
|
|
219
|
+
name: "path",
|
|
220
|
+
message: `Pasta onde o componente ser\xE1 criado (ser\xE1 criado: ${defaultPath}/${componentName})`,
|
|
221
|
+
default: defaultPath,
|
|
222
|
+
transformer: (input) => input.trim() || defaultPath
|
|
223
|
+
}
|
|
224
|
+
]);
|
|
225
|
+
const basePath = (chosenPath || defaultPath).trim();
|
|
226
|
+
const projectRoot = process.cwd();
|
|
227
|
+
const componentsPath = path2.join(projectRoot, basePath);
|
|
228
|
+
const componentPath = path2.join(componentsPath, componentName);
|
|
229
|
+
try {
|
|
230
|
+
const angularJsonPath = path2.join(projectRoot, "angular.json");
|
|
231
|
+
const isAngular = await fs2.pathExists(angularJsonPath);
|
|
232
|
+
if (!isAngular) {
|
|
233
|
+
console.error(chalk2.red("\u274C Projeto Angular n\xE3o detectado."));
|
|
234
|
+
console.log(chalk2.gray("Execute este comando em um projeto Angular."));
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
await fs2.ensureDir(componentPath);
|
|
238
|
+
const templatePath = path2.join(
|
|
239
|
+
__dirname2,
|
|
240
|
+
"..",
|
|
241
|
+
"..",
|
|
242
|
+
"templates",
|
|
243
|
+
"angular",
|
|
244
|
+
componentName
|
|
245
|
+
);
|
|
246
|
+
if (!await fs2.pathExists(templatePath)) {
|
|
247
|
+
console.error(chalk2.red(`\u274C Template n\xE3o encontrado para: ${componentName}`));
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
const templateFiles = await glob("**/*", {
|
|
251
|
+
cwd: templatePath,
|
|
252
|
+
dot: false,
|
|
253
|
+
ignore: ["node_modules/**"]
|
|
254
|
+
});
|
|
255
|
+
for (const file of templateFiles) {
|
|
256
|
+
const srcPath = path2.join(templatePath, file);
|
|
257
|
+
const destPath = path2.join(componentPath, file);
|
|
258
|
+
await fs2.ensureDir(path2.dirname(destPath));
|
|
259
|
+
let content = await fs2.readFile(srcPath, "utf-8");
|
|
260
|
+
content = content.replace(/{{COMPONENT_NAME}}/g, componentName);
|
|
261
|
+
content = content.replace(/{{COMPONENT_CLASS}}/g, toPascalCase(componentName));
|
|
262
|
+
await fs2.writeFile(destPath, content);
|
|
263
|
+
}
|
|
264
|
+
const relativePath = path2.relative(projectRoot, componentPath);
|
|
265
|
+
console.log(chalk2.green(`\u2705 Componente ${componentName} adicionado com sucesso!`));
|
|
266
|
+
console.log(chalk2.gray(` Localiza\xE7\xE3o: ${relativePath}
|
|
267
|
+
`));
|
|
268
|
+
console.log(chalk2.blue("\u{1F4A1} Pr\xF3ximos passos:"));
|
|
269
|
+
console.log(chalk2.gray(` 1. Importe o componente (ex.: no seu m\xF3dulo ou standalone):`));
|
|
270
|
+
const importPath = `./${path2.join(basePath, componentName, componentName).replace(/\\/g, "/")}.module`;
|
|
271
|
+
console.log(
|
|
272
|
+
chalk2.gray(
|
|
273
|
+
` import { Salas${toPascalCase(componentName)}Module } from '${importPath}';`
|
|
274
|
+
)
|
|
275
|
+
);
|
|
276
|
+
console.log(chalk2.gray(` 2. Use no template:`));
|
|
277
|
+
console.log(chalk2.gray(` <salas-${componentName}></salas-${componentName}>`));
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error(chalk2.red("\u274C Erro ao adicionar componente:"), error);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function toPascalCase(str) {
|
|
284
|
+
return str.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/index.ts
|
|
288
|
+
var program = new Command();
|
|
289
|
+
program.name("salas-ds").description("CLI para adicionar componentes do Salas Design System").version("0.1.0");
|
|
290
|
+
program.command("init").description("Inicializa o Salas Design System no projeto").option("-f, --framework <framework>", "Framework (angular)", "angular").option("-p, --path <path>", "Caminho para componentes", "src/app/ui").action(initCommand);
|
|
291
|
+
program.command("add").description("Adiciona um componente ao projeto").argument("<component>", "Nome do componente").option("-p, --path <path>", "Pasta onde o componente ser\xE1 criado (ex: src/components)", "src/components").action(addCommand);
|
|
292
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salas-ds/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI para adicionar componentes do Salas Design System ao projeto",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"salas-ds": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"templates"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"commander": "^11.1.0",
|
|
16
|
+
"chalk": "^5.3.0",
|
|
17
|
+
"fs-extra": "^11.2.0",
|
|
18
|
+
"glob": "^10.3.10",
|
|
19
|
+
"inquirer": "^9.2.12",
|
|
20
|
+
"prettier": "^3.2.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/fs-extra": "^11.0.4",
|
|
24
|
+
"@types/inquirer": "^9.0.7",
|
|
25
|
+
"@types/node": "^20.11.0",
|
|
26
|
+
"tsup": "^8.0.0",
|
|
27
|
+
"typescript": "~5.5.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"cli",
|
|
31
|
+
"design-system",
|
|
32
|
+
"angular",
|
|
33
|
+
"components"
|
|
34
|
+
],
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"dev": "tsup --watch",
|
|
40
|
+
"clean": "rm -rf dist"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
import { ButtonVariant, ButtonSize } from '@salas-ds/core';
|
|
3
|
+
import { cn } from '@salas-ds/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'salas-button',
|
|
7
|
+
standalone: true,
|
|
8
|
+
imports: [],
|
|
9
|
+
template: `
|
|
10
|
+
<button
|
|
11
|
+
[type]="type"
|
|
12
|
+
[disabled]="disabled || loading"
|
|
13
|
+
[class]="buttonClasses"
|
|
14
|
+
(click)="handleClick($event)"
|
|
15
|
+
[attr.aria-busy]="loading"
|
|
16
|
+
>
|
|
17
|
+
@if (loading) {
|
|
18
|
+
<span class="salas-button-loader" aria-hidden="true"></span>
|
|
19
|
+
}
|
|
20
|
+
<ng-content></ng-content>
|
|
21
|
+
</button>
|
|
22
|
+
`,
|
|
23
|
+
styles: [`
|
|
24
|
+
:host {
|
|
25
|
+
display: inline-block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.salas-button {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
gap: 0.5rem;
|
|
33
|
+
border-radius: 0.375rem;
|
|
34
|
+
font-weight: 500;
|
|
35
|
+
transition: all 0.2s;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
border: none;
|
|
38
|
+
outline: none;
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.salas-button:focus-visible {
|
|
43
|
+
outline: 2px solid var(--salas-primary-500);
|
|
44
|
+
outline-offset: 2px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.salas-button:disabled {
|
|
48
|
+
opacity: 0.5;
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.salas-button--default {
|
|
53
|
+
background-color: var(--salas-primary-500);
|
|
54
|
+
color: white;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.salas-button--default:hover:not(:disabled) {
|
|
58
|
+
background-color: var(--salas-primary-600);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.salas-button--destructive {
|
|
62
|
+
background-color: var(--salas-destructive-500);
|
|
63
|
+
color: white;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.salas-button--destructive:hover:not(:disabled) {
|
|
67
|
+
background-color: var(--salas-destructive-600);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.salas-button--outline {
|
|
71
|
+
border: 1px solid var(--salas-gray-300);
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
color: var(--salas-gray-900);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.salas-button--outline:hover:not(:disabled) {
|
|
77
|
+
background-color: var(--salas-gray-50);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.salas-button--secondary {
|
|
81
|
+
background-color: var(--salas-gray-100);
|
|
82
|
+
color: var(--salas-gray-900);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.salas-button--secondary:hover:not(:disabled) {
|
|
86
|
+
background-color: var(--salas-gray-200);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.salas-button--ghost {
|
|
90
|
+
background-color: transparent;
|
|
91
|
+
color: var(--salas-gray-900);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.salas-button--ghost:hover:not(:disabled) {
|
|
95
|
+
background-color: var(--salas-gray-100);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.salas-button--link {
|
|
99
|
+
background-color: transparent;
|
|
100
|
+
color: var(--salas-primary-500);
|
|
101
|
+
text-decoration: underline;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.salas-button--link:hover:not(:disabled) {
|
|
106
|
+
color: var(--salas-primary-600);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.salas-button--sm {
|
|
110
|
+
height: 2rem;
|
|
111
|
+
padding: 0 0.75rem;
|
|
112
|
+
font-size: 0.875rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.salas-button--default-size {
|
|
116
|
+
height: 2.5rem;
|
|
117
|
+
padding: 0 1rem;
|
|
118
|
+
font-size: 0.875rem;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.salas-button--lg {
|
|
122
|
+
height: 3rem;
|
|
123
|
+
padding: 0 1.5rem;
|
|
124
|
+
font-size: 1rem;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.salas-button--icon {
|
|
128
|
+
height: 2.5rem;
|
|
129
|
+
width: 2.5rem;
|
|
130
|
+
padding: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.salas-button--full-width {
|
|
134
|
+
width: 100%;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.salas-button-loader {
|
|
138
|
+
width: 1rem;
|
|
139
|
+
height: 1rem;
|
|
140
|
+
border: 2px solid currentColor;
|
|
141
|
+
border-top-color: transparent;
|
|
142
|
+
border-radius: 50%;
|
|
143
|
+
animation: spin 0.6s linear infinite;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes spin {
|
|
147
|
+
to {
|
|
148
|
+
transform: rotate(360deg);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`],
|
|
152
|
+
})
|
|
153
|
+
export class SalasButtonComponent {
|
|
154
|
+
@Input() variant: ButtonVariant = 'default';
|
|
155
|
+
@Input() size: ButtonSize = 'default';
|
|
156
|
+
@Input() disabled = false;
|
|
157
|
+
@Input() loading = false;
|
|
158
|
+
@Input() fullWidth = false;
|
|
159
|
+
@Input() type: 'button' | 'submit' | 'reset' = 'button';
|
|
160
|
+
@Output() clicked = new EventEmitter<MouseEvent>();
|
|
161
|
+
|
|
162
|
+
get buttonClasses(): string {
|
|
163
|
+
return cn(
|
|
164
|
+
'salas-button',
|
|
165
|
+
`salas-button--${this.variant}`,
|
|
166
|
+
this.size === 'default' ? 'salas-button--default-size' : `salas-button--${this.size}`,
|
|
167
|
+
this.fullWidth && 'salas-button--full-width'
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
handleClick(event: MouseEvent): void {
|
|
172
|
+
if (!this.disabled && !this.loading) {
|
|
173
|
+
this.clicked.emit(event);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|