ads-nuxt 0.4.2 → 0.5.1

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 CHANGED
@@ -222,7 +222,7 @@ const nome = ref("");
222
222
 
223
223
  ```vue
224
224
  <AdsButton type="filled" label="Salvar" />
225
- <AdsButton type="outline" color="success" label="Aprovar" />
225
+ <AdsButton type="outline" label="Aprovar" />
226
226
  <AdsButton type="unfilled" size="sm" label="Cancelar" />
227
227
  <AdsButton type="ia" label="Gerar com IA" leading icon="i-lucide-sparkles" />
228
228
  <AdsButton type="filled" label="Enviando" loading />
@@ -232,7 +232,6 @@ const nome = ref("");
232
232
  | Prop | Valores |
233
233
  | ------------ | ------- |
234
234
  | `type` | `filled` \| `outline` \| `unfilled` \| `secondary` \| `ia` |
235
- | `color` | `primary` \| `success` \| `attention` \| `warning` \| `new` \| `innovation` \| `blocked` \| `neutral` |
236
235
  | `size` | `md` \| `sm` |
237
236
  | `nativeType` | `button` \| `submit` \| `reset` (a prop `type` é o visual do ADS) |
238
237
 
@@ -255,7 +254,7 @@ Estados disponíveis via `state` (útil para documentação): `default`, `active
255
254
 
256
255
  ```vue
257
256
  <template>
258
- <AdsButton label="Excluir" color="warning" @click="aberto = true" />
257
+ <AdsButton label="Excluir" @click="aberto = true" />
259
258
 
260
259
  <AdsModal
261
260
  v-model:open="aberto"
@@ -38,13 +38,11 @@ import { NuxtLink } from "#components";
38
38
  export type AdsButtonType = "filled" | "outline" | "unfilled" | "secondary" | "ia";
39
39
  export type AdsButtonSize = "md" | "sm";
40
40
  export type AdsButtonState = "active" | "hover" | "pressed" | "disabled";
41
- export type AdsButtonColor = "primary" | "success" | "attention" | "warning" | "new" | "blocked" | "neutral";
42
41
 
43
42
  const props = withDefaults(
44
43
  defineProps<{
44
+ /** Filled, outline e unfilled são o primary do Figma. Secondary e IA são os outros visuais. */
45
45
  type?: AdsButtonType;
46
- /** Mesmas cores do badge, mais neutral para ação sem status. */
47
- color?: AdsButtonColor;
48
46
  size?: AdsButtonSize;
49
47
  label?: string;
50
48
  /** Ícone à esquerda. No Figma, o exemplo é sparkles. Sem rótulo, o ícone ocupa o botão sozinho. */
@@ -68,7 +66,6 @@ const props = withDefaults(
68
66
  }>(),
69
67
  {
70
68
  type: "filled",
71
- color: "primary",
72
69
  size: "md",
73
70
  label: "",
74
71
  leading: false,
@@ -133,9 +130,11 @@ const iconClass = computed(() =>
133
130
  : "size-[var(--ads-button-md-icon)] shrink-0 text-[length:var(--ads-button-md-icon)]",
134
131
  );
135
132
 
136
- const faceClass = computed(() => faceFor(props.type, props.color, visualState()));
133
+ const faceClass = computed(() => faceFor(props.type, visualState()));
137
134
  const focusClass = computed(() =>
138
- props.type === "ia" ? "focus-visible:outline-[var(--ads-button-ia-border)]" : focusFor[props.color],
135
+ props.type === "ia"
136
+ ? "focus-visible:outline-[var(--ads-button-ia-border)]"
137
+ : "focus-visible:outline-[var(--ads-text-brand)]",
139
138
  );
140
139
  /** Um brilho de gradiente gira em volta da borda do tipo IA. Hover, pressed e disabled seguram a borda fechada. */
141
140
  const iaMotion = computed(() => {
@@ -174,21 +173,9 @@ const visualState = (): AdsButtonState => {
174
173
  return "active";
175
174
  };
176
175
 
177
- const contrast = "text-[var(--ads-text-contrast)]";
178
- const ink = "text-[var(--ads-text-primary)]";
179
176
  const filledPrimaryText = "text-[var(--ads-button-primary-text)]";
180
177
  const secondaryText = "text-[var(--ads-button-secondary-text)]";
181
178
 
182
- const focusFor: Record<AdsButtonColor, string> = {
183
- primary: "focus-visible:outline-[var(--ads-text-brand)]",
184
- success: "focus-visible:outline-[var(--ads-status-success-700)]",
185
- attention: "focus-visible:outline-[var(--ads-status-attention-800)]",
186
- warning: "focus-visible:outline-[var(--ads-status-warning-600)]",
187
- new: "focus-visible:outline-[var(--ads-status-new-700)]",
188
- blocked: "focus-visible:outline-[var(--ads-status-void-800)]",
189
- neutral: "focus-visible:outline-[var(--ads-text-primary)]",
190
- };
191
-
192
179
  /** Fundo e cor da borda ficam em `.ads-button-ia-face`: a borda é pintada pelo fundo, na mesma espessura em todos os estados. */
193
180
  const iaFace = (state: AdsButtonState) => {
194
181
  const base =
@@ -202,13 +189,9 @@ const iaFace = (state: AdsButtonState) => {
202
189
  return base;
203
190
  };
204
191
 
205
- const faceFor = (type: AdsButtonType, color: AdsButtonColor, state: AdsButtonState) => {
192
+ const faceFor = (type: AdsButtonType, state: AdsButtonState) => {
206
193
  if (type === "ia") return iaFace(state);
207
- if (color === "primary") return primaryFace(type, state);
208
- if (type === "filled") return filledStatus(color, state);
209
- if (type === "outline") return outlineStatus(color, state);
210
- if (type === "unfilled") return unfilledStatus(color, state);
211
- return secondaryStatus(color, state);
194
+ return primaryFace(type, state);
212
195
  };
213
196
 
214
197
  const primaryFace = (type: AdsButtonType, state: AdsButtonState) => {
@@ -252,202 +235,6 @@ const secondaryPrimary = (state: AdsButtonState) => {
252
235
  return `bg-[var(--ads-button-secondary)] ${secondaryText} hover:bg-[var(--ads-button-secondary-hover)] active:bg-[var(--ads-button-secondary-pressed)]`;
253
236
  };
254
237
 
255
- /**
256
- * Sucesso, atenção e new usam texto primary no sólido 500: branco não chega no AA.
257
- * Warning e blocked seguram branco. Pressed escuro volta para o texto de contraste.
258
- */
259
- const filledStatus = (color: AdsButtonColor, state: AdsButtonState) => {
260
- if (color === "success") {
261
- if (state === "hover") return `bg-[var(--ads-status-success-600)] ${ink}`;
262
- if (state === "pressed") return `bg-[var(--ads-status-success-800)] ${contrast}`;
263
- if (state === "disabled") return "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-700)]";
264
- return `bg-[var(--ads-status-success-500)] ${ink} hover:bg-[var(--ads-status-success-600)] active:bg-[var(--ads-status-success-800)] active:text-[var(--ads-text-contrast)]`;
265
- }
266
- if (color === "attention") {
267
- if (state === "hover") return `bg-[var(--ads-status-attention-600)] ${ink}`;
268
- if (state === "pressed") return `bg-[var(--ads-status-attention-800)] ${contrast}`;
269
- if (state === "disabled") return "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]";
270
- return `bg-[var(--ads-status-attention-500)] ${ink} hover:bg-[var(--ads-status-attention-600)] active:bg-[var(--ads-status-attention-800)] active:text-[var(--ads-text-contrast)]`;
271
- }
272
- if (color === "warning") {
273
- if (state === "hover") return `bg-[var(--ads-status-warning-600)] ${contrast}`;
274
- if (state === "pressed") return `bg-[var(--ads-status-warning-800)] ${contrast}`;
275
- if (state === "disabled") return "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-800)]";
276
- return `bg-[var(--ads-status-warning-500)] ${contrast} hover:bg-[var(--ads-status-warning-600)] active:bg-[var(--ads-status-warning-800)]`;
277
- }
278
- if (color === "new") {
279
- if (state === "hover") return `bg-[var(--ads-status-new-600)] ${ink}`;
280
- if (state === "pressed") return `bg-[var(--ads-status-new-800)] ${contrast}`;
281
- if (state === "disabled") return "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-800)]";
282
- return `bg-[var(--ads-status-new-500)] ${ink} hover:bg-[var(--ads-status-new-600)] active:bg-[var(--ads-status-new-800)] active:text-[var(--ads-text-contrast)]`;
283
- }
284
- if (color === "neutral") {
285
- if (state === "hover") return `bg-[var(--color-neutral-800)] ${contrast}`;
286
- if (state === "pressed") return `bg-[var(--color-neutral-900)] ${contrast}`;
287
- if (state === "disabled") return "bg-[var(--color-neutral-100)] text-[var(--ads-text-tertiary)]";
288
- return `bg-[var(--color-neutral-700)] ${contrast} hover:bg-[var(--color-neutral-800)] active:bg-[var(--color-neutral-900)]`;
289
- }
290
- if (state === "hover") return `bg-[color-mix(in_srgb,var(--ads-status-void-800)_78%,white)] ${contrast}`;
291
- if (state === "pressed") return `bg-[color-mix(in_srgb,var(--ads-status-void-800)_70%,black)] ${contrast}`;
292
- if (state === "disabled") return "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-600)]";
293
- return `bg-[var(--ads-status-void-800)] ${contrast} hover:bg-[color-mix(in_srgb,var(--ads-status-void-800)_78%,white)] active:bg-[color-mix(in_srgb,var(--ads-status-void-800)_70%,black)]`;
294
- };
295
-
296
- const outlineStatus = (color: AdsButtonColor, state: AdsButtonState) => {
297
- const faces: Record<Exclude<AdsButtonColor, "primary">, Record<AdsButtonState, string>> = {
298
- success: {
299
- active:
300
- "border border-[var(--ads-status-success-700)] text-[var(--ads-status-success-700)] hover:bg-[var(--ads-status-success-100)] hover:shadow-[inset_0_0_0_1px_var(--ads-status-success-700)]",
301
- hover:
302
- "border border-[var(--ads-status-success-700)] bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-700)] shadow-[inset_0_0_0_1px_var(--ads-status-success-700)]",
303
- pressed:
304
- "border border-[var(--ads-status-success-700)] bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-700)] shadow-[inset_0_0_0_1px_var(--ads-status-success-700)]",
305
- disabled:
306
- "border border-[var(--ads-status-success-300)] bg-[color-mix(in_srgb,var(--ads-status-success-100)_50%,transparent)] text-[var(--ads-status-success-300)]",
307
- },
308
- attention: {
309
- active:
310
- "border border-[var(--ads-status-attention-800)] text-[var(--ads-status-attention-800)] hover:bg-[var(--ads-status-attention-100)] hover:shadow-[inset_0_0_0_1px_var(--ads-status-attention-800)]",
311
- hover:
312
- "border border-[var(--ads-status-attention-800)] bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)] shadow-[inset_0_0_0_1px_var(--ads-status-attention-800)]",
313
- pressed:
314
- "border border-[var(--ads-status-attention-800)] bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)] shadow-[inset_0_0_0_1px_var(--ads-status-attention-800)]",
315
- disabled:
316
- "border border-[var(--ads-status-attention-300)] bg-[color-mix(in_srgb,var(--ads-status-attention-100)_50%,transparent)] text-[var(--ads-status-attention-300)]",
317
- },
318
- warning: {
319
- active:
320
- "border border-[var(--ads-status-warning-600)] text-[var(--ads-status-warning-600)] hover:bg-[var(--ads-status-warning-100)] hover:shadow-[inset_0_0_0_1px_var(--ads-status-warning-600)]",
321
- hover:
322
- "border border-[var(--ads-status-warning-600)] bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-600)] shadow-[inset_0_0_0_1px_var(--ads-status-warning-600)]",
323
- pressed:
324
- "border border-[var(--ads-status-warning-600)] bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-600)] shadow-[inset_0_0_0_1px_var(--ads-status-warning-600)]",
325
- disabled:
326
- "border border-[var(--ads-status-warning-300)] bg-[color-mix(in_srgb,var(--ads-status-warning-100)_50%,transparent)] text-[var(--ads-status-warning-300)]",
327
- },
328
- new: {
329
- active:
330
- "border border-[var(--ads-status-new-700)] text-[var(--ads-status-new-700)] hover:bg-[var(--ads-status-new-100)] hover:shadow-[inset_0_0_0_1px_var(--ads-status-new-700)]",
331
- hover:
332
- "border border-[var(--ads-status-new-700)] bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-700)] shadow-[inset_0_0_0_1px_var(--ads-status-new-700)]",
333
- pressed:
334
- "border border-[var(--ads-status-new-700)] bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-700)] shadow-[inset_0_0_0_1px_var(--ads-status-new-700)]",
335
- disabled:
336
- "border border-[var(--ads-status-new-300)] bg-[color-mix(in_srgb,var(--ads-status-new-100)_50%,transparent)] text-[var(--ads-status-new-300)]",
337
- },
338
- blocked: {
339
- active:
340
- "border border-[var(--ads-status-void-800)] text-[var(--ads-status-void-800)] hover:bg-[var(--ads-status-void-100)] hover:shadow-[inset_0_0_0_1px_var(--ads-status-void-800)]",
341
- hover:
342
- "border border-[var(--ads-status-void-800)] bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)] shadow-[inset_0_0_0_1px_var(--ads-status-void-800)]",
343
- pressed:
344
- "border border-[var(--ads-status-void-800)] bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)] shadow-[inset_0_0_0_1px_var(--ads-status-void-800)]",
345
- disabled:
346
- "border border-[var(--ads-status-void-300)] bg-[color-mix(in_srgb,var(--ads-status-void-100)_50%,transparent)] text-[var(--ads-status-void-300)]",
347
- },
348
- neutral: {
349
- active:
350
- "border border-[var(--color-neutral-300)] text-[var(--ads-text-primary)] hover:bg-[var(--color-neutral-100)] hover:shadow-[inset_0_0_0_1px_var(--color-neutral-300)]",
351
- hover:
352
- "border border-[var(--color-neutral-300)] bg-[var(--color-neutral-100)] text-[var(--ads-text-primary)] shadow-[inset_0_0_0_1px_var(--color-neutral-300)]",
353
- pressed:
354
- "border border-[var(--color-neutral-300)] bg-[var(--color-neutral-100)] text-[var(--ads-text-primary)] shadow-[inset_0_0_0_1px_var(--color-neutral-300)]",
355
- disabled:
356
- "border border-[var(--color-neutral-300)] bg-[color-mix(in_srgb,var(--color-neutral-100)_50%,transparent)] text-[var(--ads-text-tertiary)]",
357
- },
358
- };
359
- return faces[color === "primary" ? "success" : color][state];
360
- };
361
-
362
- const unfilledStatus = (color: AdsButtonColor, state: AdsButtonState) => {
363
- const faces: Record<Exclude<AdsButtonColor, "primary">, Record<AdsButtonState, string>> = {
364
- success: {
365
- active: "text-[var(--ads-status-success-700)] hover:bg-[var(--ads-status-success-100)]",
366
- hover: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-700)]",
367
- pressed: "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-700)]",
368
- disabled: "text-[var(--ads-status-success-300)]",
369
- },
370
- attention: {
371
- active: "text-[var(--ads-status-attention-800)] hover:bg-[var(--ads-status-attention-100)]",
372
- hover: "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]",
373
- pressed: "bg-[var(--ads-status-attention-100)] text-[var(--ads-status-attention-800)]",
374
- disabled: "text-[var(--ads-status-attention-300)]",
375
- },
376
- warning: {
377
- active: "text-[var(--ads-status-warning-600)] hover:bg-[var(--ads-status-warning-100)]",
378
- hover: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-600)]",
379
- pressed: "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-600)]",
380
- disabled: "text-[var(--ads-status-warning-300)]",
381
- },
382
- new: {
383
- active: "text-[var(--ads-status-new-700)] hover:bg-[var(--ads-status-new-100)]",
384
- hover: "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-700)]",
385
- pressed: "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-700)]",
386
- disabled: "text-[var(--ads-status-new-300)]",
387
- },
388
- blocked: {
389
- active: "text-[var(--ads-status-void-800)] hover:bg-[var(--ads-status-void-100)]",
390
- hover: "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)]",
391
- pressed: "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)]",
392
- disabled: "text-[var(--ads-status-void-300)]",
393
- },
394
- neutral: {
395
- active: "text-[var(--ads-text-primary)] hover:bg-[var(--color-neutral-100)]",
396
- hover: "bg-[var(--color-neutral-100)] text-[var(--ads-text-primary)]",
397
- pressed: "bg-[var(--color-neutral-100)] text-[var(--ads-text-primary)]",
398
- disabled: "text-[var(--ads-text-tertiary)]",
399
- },
400
- };
401
- return faces[color === "primary" ? "success" : color][state];
402
- };
403
-
404
- const secondaryStatus = (color: AdsButtonColor, state: AdsButtonState) => {
405
- const faces: Record<Exclude<AdsButtonColor, "primary">, Record<AdsButtonState, string>> = {
406
- success: {
407
- active:
408
- "bg-[var(--ads-status-success-100)] text-[var(--ads-status-success-800)] hover:bg-[var(--ads-status-success-200)] active:bg-[var(--ads-status-success-300)]",
409
- hover: "bg-[var(--ads-status-success-200)] text-[var(--ads-status-success-800)]",
410
- pressed: "bg-[var(--ads-status-success-300)] text-[var(--ads-status-success-800)]",
411
- disabled: secondaryDisabled,
412
- },
413
- attention: {
414
- active:
415
- "bg-[var(--ads-status-attention-100)] text-[var(--ads-text-primary)] hover:bg-[var(--ads-status-attention-200)] active:bg-[var(--ads-status-attention-300)]",
416
- hover: "bg-[var(--ads-status-attention-200)] text-[var(--ads-text-primary)]",
417
- pressed: "bg-[var(--ads-status-attention-300)] text-[var(--ads-text-primary)]",
418
- disabled: secondaryDisabled,
419
- },
420
- warning: {
421
- active:
422
- "bg-[var(--ads-status-warning-100)] text-[var(--ads-status-warning-800)] hover:bg-[var(--ads-status-warning-200)] active:bg-[var(--ads-status-warning-300)]",
423
- hover: "bg-[var(--ads-status-warning-200)] text-[var(--ads-status-warning-800)]",
424
- pressed: "bg-[var(--ads-status-warning-300)] text-[var(--ads-status-warning-800)]",
425
- disabled: secondaryDisabled,
426
- },
427
- new: {
428
- active:
429
- "bg-[var(--ads-status-new-100)] text-[var(--ads-status-new-800)] hover:bg-[var(--ads-status-new-200)] active:bg-[var(--ads-status-new-300)]",
430
- hover: "bg-[var(--ads-status-new-200)] text-[var(--ads-status-new-800)]",
431
- pressed: "bg-[var(--ads-status-new-300)] text-[var(--ads-status-new-800)]",
432
- disabled: secondaryDisabled,
433
- },
434
- blocked: {
435
- active:
436
- "bg-[var(--ads-status-void-100)] text-[var(--ads-status-void-800)] hover:bg-[var(--ads-status-void-200)] active:bg-[var(--ads-status-void-300)]",
437
- hover: "bg-[var(--ads-status-void-200)] text-[var(--ads-status-void-800)]",
438
- pressed: "bg-[var(--ads-status-void-300)] text-[var(--ads-status-void-800)]",
439
- disabled: secondaryDisabled,
440
- },
441
- neutral: {
442
- active:
443
- "bg-[var(--color-neutral-100)] text-[var(--ads-text-primary)] hover:bg-[var(--color-neutral-200)] active:bg-[var(--color-neutral-300)]",
444
- hover: "bg-[var(--color-neutral-200)] text-[var(--ads-text-primary)]",
445
- pressed: "bg-[var(--color-neutral-300)] text-[var(--ads-text-primary)]",
446
- disabled: secondaryDisabled,
447
- },
448
- };
449
- return faces[color === "primary" ? "success" : color][state];
450
- };
451
238
  </script>
452
239
 
453
240
  <style>
@@ -3,7 +3,7 @@
3
3
  v-if="hasTrigger"
4
4
  arrow
5
5
  :delay-duration="delayDuration"
6
- :content="{ side: 'top', align: 'center', sideOffset: 4 }"
6
+ :content="{ side: 'top', align: 'center', sideOffset: 4, arrowPadding }"
7
7
  :ui="tooltipUi"
8
8
  >
9
9
  <slot />
@@ -36,6 +36,9 @@ withDefaults(
36
36
  const slots = useSlots();
37
37
  const hasTrigger = computed(() => Boolean(slots.default));
38
38
 
39
+ /** Igual a `--ads-tooltip-radius`. Sem isso, a seta no canto fica sobre a curva e solta do balão. */
40
+ const arrowPadding = 12;
41
+
39
42
  const tooltipUi = {
40
43
  content:
41
44
  "z-[70] rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-[var(--ads-tooltip-small-padding)] shadow-[var(--ads-shadow-level-1)] ring-0",
@@ -4,7 +4,7 @@
4
4
  arrow
5
5
  :delay-duration="delayDuration"
6
6
  :disabled="disabled"
7
- :content="{ side, align, sideOffset: 8 }"
7
+ :content="{ side, align, sideOffset: 8, arrowPadding }"
8
8
  :ui="tooltipUi"
9
9
  >
10
10
  <slot />
@@ -65,6 +65,9 @@ const side = computed(() => {
65
65
  return "top" as const;
66
66
  });
67
67
 
68
+ /** Igual a `--ads-tooltip-radius`. Sem isso, a seta no canto fica sobre a curva e solta do balão. */
69
+ const arrowPadding = 12;
70
+
68
71
  const tooltipUi = {
69
72
  content:
70
73
  "z-[70] h-auto max-w-[328px] rounded-[var(--ads-tooltip-radius)] bg-[var(--ads-tooltip-bg)] p-[var(--ads-tooltip-padding-x)] shadow-[var(--ads-shadow-level-1)] ring-0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-nuxt",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "license": "MIT",
5
5
  "description": "Alquimia Design System para Nuxt, construído sobre Nuxt UI",
6
6
  "repository": {