ads-nuxt 0.1.4 → 0.2.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 -21
- package/README.md +573 -577
- package/app/app.config.ts +25 -25
- package/app/assets/ads/checkbox-check.svg +5 -5
- package/app/assets/ads/checkbox-minus.svg +5 -5
- package/app/assets/brand/farmarcas.svg +6 -6
- package/app/assets/brand/radar-symbol.svg +9 -0
- package/app/assets/brand/radar.svg +9 -9
- package/app/assets/css/ads-colors.css +257 -246
- package/app/assets/css/component-tokens.css +367 -403
- package/app/assets/css/main.css +624 -617
- package/app/components/AdsBadge.vue +47 -48
- package/app/components/AdsBroadcast.vue +24 -45
- package/app/components/AdsButton.vue +539 -569
- package/app/components/AdsButtonGroup.vue +39 -39
- package/app/components/AdsButtonMenu.vue +48 -48
- package/app/components/AdsCard.vue +188 -117
- package/app/components/AdsCardHint.vue +22 -0
- package/app/components/AdsCardPeriod.vue +43 -0
- package/app/components/AdsCardVariation.vue +31 -0
- package/app/components/AdsCharttip.vue +78 -78
- package/app/components/AdsCheckbox.vue +77 -77
- package/app/components/AdsDatePicker.vue +492 -479
- package/app/components/AdsDropdownMenu.vue +30 -19
- package/app/components/AdsEmptyState.vue +58 -58
- package/app/components/AdsFeatureCard.vue +210 -219
- package/app/components/AdsFileCard.vue +98 -101
- package/app/components/AdsFooter.vue +25 -25
- package/app/components/AdsHeavyAccountCell.vue +59 -0
- package/app/components/AdsHeavyHeaderCell.vue +70 -0
- package/app/components/AdsHeavyTable.vue +135 -0
- package/app/components/AdsInput.vue +147 -143
- package/app/components/AdsLoading.vue +217 -109
- package/app/components/AdsMenuBar.vue +103 -103
- package/app/components/AdsMetricCard.vue +216 -119
- package/app/components/AdsModal.vue +157 -157
- package/app/components/AdsMonthPicker.vue +80 -80
- package/app/components/AdsNavbarApp.vue +67 -67
- package/app/components/AdsNavbarDesk.vue +62 -62
- package/app/components/AdsNotabilityPill.vue +24 -27
- package/app/components/AdsNumberInput.vue +173 -166
- package/app/components/AdsPagination.vue +91 -91
- package/app/components/AdsPanelCard.vue +99 -0
- package/app/components/AdsPill.vue +144 -92
- package/app/components/AdsProductTag.vue +61 -61
- package/app/components/AdsRadio.vue +70 -70
- package/app/components/AdsSearchInput.vue +122 -113
- package/app/components/AdsSegmentedTabs.vue +62 -28
- package/app/components/{AdsFilterSelect.vue → AdsSelect.vue} +266 -203
- package/app/components/AdsSelectItem.vue +128 -0
- package/app/components/AdsSelectPanel.vue +150 -0
- package/app/components/AdsSideMenu.vue +101 -101
- package/app/components/AdsSmalltip.vue +44 -44
- package/app/components/AdsStepper.vue +222 -0
- package/app/components/AdsSteptip.vue +101 -101
- package/app/components/AdsSwitch.vue +59 -59
- package/app/components/AdsTable.vue +161 -100
- package/app/components/AdsTableHeaderCell.vue +80 -0
- package/app/components/AdsTableSkeleton.vue +113 -0
- package/app/components/AdsTableToolbar.vue +44 -44
- package/app/components/AdsTabs.vue +51 -51
- package/app/components/AdsTextarea.vue +116 -109
- package/app/components/AdsToast.vue +183 -181
- package/app/components/AdsTooltip.vue +73 -73
- package/app/components/OverlayLoading.vue +173 -173
- package/app/components/ProgressBarLoading.vue +235 -256
- package/app/composables/useOverlayLoading.ts +66 -66
- package/app/constants/ads-color-swatches.ts +240 -239
- package/app/locale/pt-br.ts +6 -6
- package/app/plugins/ads-toast.client.ts +24 -24
- package/app/theme/ads-theme.ts +374 -370
- package/app/theme/ads-tokens.ts +391 -379
- package/app/theme/component-tokens.json +366 -402
- package/app/theme/component-tokens.ts +807 -815
- package/app/types/overlay-loading.types.ts +26 -26
- package/app/utils/ads-filter-select.ts +191 -172
- package/app/utils/ads-table.ts +395 -204
- package/app/utils/calendar-date.ts +163 -163
- package/app/utils/category-role.ts +45 -45
- package/app/utils/money.ts +77 -77
- package/app/utils/notability.ts +8 -8
- package/app/utils/parser.ts +134 -134
- package/app/utils/percentage.ts +54 -54
- package/nuxt.config.ts +31 -31
- package/package.json +1 -1
- package/app/components/AdsFarmarcasPill.vue +0 -74
- package/app/components/AdsFilterDropdown.vue +0 -174
- package/app/components/AdsFilterOption.vue +0 -74
- package/app/components/AdsListDropdown.vue +0 -44
- package/app/components/AdsMiniPill.vue +0 -40
|
@@ -1,143 +1,147 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex w-full min-w-0 flex-col gap-0.5">
|
|
3
|
-
<div
|
|
4
|
-
v-if="label"
|
|
5
|
-
class="flex items-center gap-0.5 text-[length:var(--ads-input-label-size)] leading-[1.2]"
|
|
6
|
-
:class="supportClass"
|
|
7
|
-
>
|
|
8
|
-
<label :for="fieldId">{{ label }}</label>
|
|
9
|
-
<AdsTooltip v-if="info" :description="info" :show-title="false">
|
|
10
|
-
<span class="inline-flex">
|
|
11
|
-
<UIcon name="i-lucide-info" class="size-3 text-xs" />
|
|
12
|
-
</span>
|
|
13
|
-
</AdsTooltip>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div
|
|
17
|
-
class="flex h-[var(--ads-input-height)] items-center transition-colors gap-[var(--ads-input-gap)] rounded-[var(--ads-input-radius)] px-[var(--ads-input-padding-x)]"
|
|
18
|
-
:class="fieldClass"
|
|
19
|
-
:data-state="visualState"
|
|
20
|
-
>
|
|
21
|
-
<input
|
|
22
|
-
:id="fieldId"
|
|
23
|
-
:value="displayValue"
|
|
24
|
-
:type="type"
|
|
25
|
-
class="min-w-0 flex-1 bg-transparent text-[length:var(--ads-input-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
|
|
26
|
-
:class="type === 'number' ? '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none' : undefined"
|
|
27
|
-
:placeholder="placeholder"
|
|
28
|
-
:disabled="isDisabled"
|
|
29
|
-
:min="min"
|
|
30
|
-
:step="step"
|
|
31
|
-
:aria-invalid="error ? true : undefined"
|
|
32
|
-
:aria-describedby="supportText ? supportId : undefined"
|
|
33
|
-
@input="onInput"
|
|
34
|
-
@focus="emit('focus', $event)"
|
|
35
|
-
@blur="emit('blur', $event)"
|
|
36
|
-
>
|
|
37
|
-
<span v-if="suffix" class="shrink-0 text-[length:var(--ads-input-font-size)] leading-[1.3]">{{ suffix }}</span>
|
|
38
|
-
<UIcon v-if="icon" :name="icon" class="size-4 shrink-0 text-base" />
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<p
|
|
42
|
-
v-if="supportText"
|
|
43
|
-
:id="supportId"
|
|
44
|
-
class="text-xs leading-[1.2]"
|
|
45
|
-
:class="supportClass"
|
|
46
|
-
>
|
|
47
|
-
{{ supportText }}
|
|
48
|
-
</p>
|
|
49
|
-
</div>
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<script setup lang="ts">
|
|
53
|
-
import { computed, useId } from "vue";
|
|
54
|
-
import AdsTooltip from "./AdsTooltip.vue";
|
|
55
|
-
|
|
56
|
-
export type AdsInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
|
|
57
|
-
|
|
58
|
-
const props = withDefaults(
|
|
59
|
-
defineProps<{
|
|
60
|
-
label?: string;
|
|
61
|
-
hint?: string;
|
|
62
|
-
error?: string;
|
|
63
|
-
info?: string;
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
disabled?: boolean;
|
|
66
|
-
icon?: string;
|
|
67
|
-
type?: "text" | "number";
|
|
68
|
-
suffix?: string;
|
|
69
|
-
min?: string | number;
|
|
70
|
-
step?: string | number;
|
|
71
|
-
/** Estado congelado para a documentação. `null` segue o campo. */
|
|
72
|
-
state?: AdsInputState | null;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex w-full min-w-0 flex-col gap-0.5">
|
|
3
|
+
<div
|
|
4
|
+
v-if="label"
|
|
5
|
+
class="flex items-center gap-0.5 text-[length:var(--ads-input-label-size)] leading-[1.2]"
|
|
6
|
+
:class="supportClass"
|
|
7
|
+
>
|
|
8
|
+
<label :for="fieldId">{{ label }}</label>
|
|
9
|
+
<AdsTooltip v-if="info" :description="info" :show-title="false">
|
|
10
|
+
<span class="inline-flex">
|
|
11
|
+
<UIcon name="i-lucide-info" class="size-3 text-xs" />
|
|
12
|
+
</span>
|
|
13
|
+
</AdsTooltip>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class="flex h-[var(--ads-input-height)] items-center transition-colors gap-[var(--ads-input-gap)] rounded-[var(--ads-input-radius)] px-[var(--ads-input-padding-x)]"
|
|
18
|
+
:class="fieldClass"
|
|
19
|
+
:data-state="visualState"
|
|
20
|
+
>
|
|
21
|
+
<input
|
|
22
|
+
:id="fieldId"
|
|
23
|
+
:value="displayValue"
|
|
24
|
+
:type="type"
|
|
25
|
+
class="min-w-0 flex-1 bg-transparent text-[length:var(--ads-input-font-size)] leading-[1.3] outline-none placeholder:text-current disabled:cursor-not-allowed"
|
|
26
|
+
:class="type === 'number' ? '[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none' : undefined"
|
|
27
|
+
:placeholder="placeholder"
|
|
28
|
+
:disabled="isDisabled"
|
|
29
|
+
:min="min"
|
|
30
|
+
:step="step"
|
|
31
|
+
:aria-invalid="error ? true : undefined"
|
|
32
|
+
:aria-describedby="supportText ? supportId : undefined"
|
|
33
|
+
@input="onInput"
|
|
34
|
+
@focus="emit('focus', $event)"
|
|
35
|
+
@blur="emit('blur', $event)"
|
|
36
|
+
>
|
|
37
|
+
<span v-if="suffix" class="shrink-0 text-[length:var(--ads-input-font-size)] leading-[1.3]">{{ suffix }}</span>
|
|
38
|
+
<UIcon v-if="icon" :name="icon" class="size-4 shrink-0 text-base" />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<p
|
|
42
|
+
v-if="supportText"
|
|
43
|
+
:id="supportId"
|
|
44
|
+
class="text-xs leading-[1.2]"
|
|
45
|
+
:class="supportClass"
|
|
46
|
+
>
|
|
47
|
+
{{ supportText }}
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { computed, useId } from "vue";
|
|
54
|
+
import AdsTooltip from "./AdsTooltip.vue";
|
|
55
|
+
|
|
56
|
+
export type AdsInputState = "default" | "active" | "focus" | "error" | "disabled" | "ai";
|
|
57
|
+
|
|
58
|
+
const props = withDefaults(
|
|
59
|
+
defineProps<{
|
|
60
|
+
label?: string;
|
|
61
|
+
hint?: string;
|
|
62
|
+
error?: string;
|
|
63
|
+
info?: string;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
icon?: string;
|
|
67
|
+
type?: "text" | "number";
|
|
68
|
+
suffix?: string;
|
|
69
|
+
min?: string | number;
|
|
70
|
+
step?: string | number;
|
|
71
|
+
/** Estado congelado para a documentação. `null` segue o campo. */
|
|
72
|
+
state?: AdsInputState | null;
|
|
73
|
+
/** O valor veio de uma sugestão de IA. Quem usa limpa a marca quando a pessoa edita. */
|
|
74
|
+
aiSuggestion?: boolean;
|
|
75
|
+
}>(),
|
|
76
|
+
{
|
|
77
|
+
label: "",
|
|
78
|
+
hint: "",
|
|
79
|
+
error: "",
|
|
80
|
+
info: "",
|
|
81
|
+
placeholder: "",
|
|
82
|
+
disabled: false,
|
|
83
|
+
icon: "",
|
|
84
|
+
type: "text",
|
|
85
|
+
suffix: "",
|
|
86
|
+
state: null,
|
|
87
|
+
aiSuggestion: false,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const model = defineModel<string | number>({ default: "" });
|
|
92
|
+
|
|
93
|
+
const emit = defineEmits<{
|
|
94
|
+
focus: [event: FocusEvent];
|
|
95
|
+
blur: [event: FocusEvent];
|
|
96
|
+
}>();
|
|
97
|
+
|
|
98
|
+
const fieldId = useId();
|
|
99
|
+
const supportId = useId();
|
|
100
|
+
|
|
101
|
+
const displayValue = computed(() =>
|
|
102
|
+
model.value === undefined || model.value === null ? "" : String(model.value),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const onInput = (event: Event) => {
|
|
106
|
+
const value = (event.target as HTMLInputElement).value;
|
|
107
|
+
model.value = value;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const isDisabled = computed(() => props.disabled || props.state === "disabled");
|
|
111
|
+
|
|
112
|
+
const visualState = computed<AdsInputState>(() => {
|
|
113
|
+
if (isDisabled.value) return "disabled";
|
|
114
|
+
if (props.state) return props.state;
|
|
115
|
+
if (props.error) return "error";
|
|
116
|
+
if (props.aiSuggestion) return "ai";
|
|
117
|
+
return displayValue.value ? "active" : "default";
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const supportText = computed(() => props.error || props.hint);
|
|
121
|
+
const supportClass = computed(() =>
|
|
122
|
+
visualState.value === "disabled"
|
|
123
|
+
? "text-[var(--ads-text-tertiary)]"
|
|
124
|
+
: "text-[var(--ads-text-secondary)]",
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const fieldClass = computed(() => {
|
|
128
|
+
const interactiveFocus = props.state === null && !isDisabled.value && !props.error;
|
|
129
|
+
const focus = interactiveFocus
|
|
130
|
+
? "hover:not-focus-within:border-[var(--ads-input-hover-border)] focus-within:border-(length:--ads-border-width-slim) focus-within:border-[var(--ads-input-focus-border)]"
|
|
131
|
+
: "";
|
|
132
|
+
|
|
133
|
+
if (visualState.value === "disabled") {
|
|
134
|
+
return "border border-[var(--ads-input-disabled-border)] bg-[var(--ads-input-disabled-background)] text-[var(--ads-input-disabled-text)]";
|
|
135
|
+
}
|
|
136
|
+
if (visualState.value === "error") {
|
|
137
|
+
return `border-(length:--ads-border-width-slim) border-[var(--ads-input-error-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
138
|
+
}
|
|
139
|
+
if (visualState.value === "focus") {
|
|
140
|
+
return "border-(length:--ads-border-width-slim) border-[var(--ads-input-focus-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)]";
|
|
141
|
+
}
|
|
142
|
+
if (visualState.value === "ai") {
|
|
143
|
+
return `border border-[var(--ads-button-ia-border)] bg-[var(--ads-surface-ai)] text-[var(--ads-text-ai)] ${focus}`;
|
|
144
|
+
}
|
|
145
|
+
return `border border-[var(--ads-input-border)] bg-[var(--ads-input-background)] text-[var(--ads-input-text)] ${focus}`;
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
@@ -1,109 +1,217 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class="
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class="
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Shimmer sobre conteúdo existente (só no código): o pai precisa de relative e overflow-hidden -->
|
|
3
|
+
<div
|
|
4
|
+
v-if="variant === 'shimmer' && overlay"
|
|
5
|
+
class="ads-loading-shimmer pointer-events-none absolute inset-0 z-10 overflow-hidden"
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
/>
|
|
8
|
+
|
|
9
|
+
<!-- Shimmer do Figma: bloco cinza com brilho que atravessa -->
|
|
10
|
+
<div
|
|
11
|
+
v-else-if="variant === 'shimmer'"
|
|
12
|
+
class="relative w-full overflow-hidden rounded-[var(--ads-radius-sm)]"
|
|
13
|
+
:class="[shimmerHeightClass, skeletonColorClass]"
|
|
14
|
+
role="status"
|
|
15
|
+
aria-label="Carregando"
|
|
16
|
+
>
|
|
17
|
+
<div class="ads-loading-shimmer absolute inset-0" aria-hidden="true" />
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<span
|
|
21
|
+
v-else-if="variant === 'skeleton' && lines < 1"
|
|
22
|
+
class="block animate-pulse rounded-[var(--ads-loading-radius)] motion-reduce:animate-none"
|
|
23
|
+
:class="skeletonColorClass"
|
|
24
|
+
role="status"
|
|
25
|
+
aria-label="Carregando"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<div
|
|
29
|
+
v-else-if="variant === 'skeleton'"
|
|
30
|
+
class="flex w-full flex-col items-start gap-2"
|
|
31
|
+
role="status"
|
|
32
|
+
aria-label="Carregando"
|
|
33
|
+
>
|
|
34
|
+
<span
|
|
35
|
+
v-for="(width, index) in skeletonLines"
|
|
36
|
+
:key="index"
|
|
37
|
+
class="block animate-pulse rounded-[var(--ads-loading-radius)] motion-reduce:animate-none"
|
|
38
|
+
:class="[width, skeletonLineClass, skeletonColorClass]"
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
v-else-if="variant === 'logo'"
|
|
45
|
+
role="status"
|
|
46
|
+
:aria-label="label || 'Carregando'"
|
|
47
|
+
:class="logoRootClass"
|
|
48
|
+
>
|
|
49
|
+
<p v-if="label" :class="labelClass">{{ label }}</p>
|
|
50
|
+
<img
|
|
51
|
+
:src="radarLogoUrl"
|
|
52
|
+
alt=""
|
|
53
|
+
class="ads-loading-logo"
|
|
54
|
+
:class="[logoSizeClass, logoToneClass]"
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<div
|
|
60
|
+
v-else
|
|
61
|
+
role="status"
|
|
62
|
+
:aria-label="label ? undefined : 'Carregando'"
|
|
63
|
+
:class="spinnerRootClass"
|
|
64
|
+
>
|
|
65
|
+
<svg
|
|
66
|
+
class="shrink-0 animate-spin motion-reduce:animate-none"
|
|
67
|
+
:width="spinner.px"
|
|
68
|
+
:height="spinner.px"
|
|
69
|
+
:viewBox="`0 0 ${spinner.px} ${spinner.px}`"
|
|
70
|
+
fill="none"
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
>
|
|
73
|
+
<circle
|
|
74
|
+
:cx="spinner.px / 2"
|
|
75
|
+
:cy="spinner.px / 2"
|
|
76
|
+
:r="spinner.radius"
|
|
77
|
+
:stroke-width="spinner.stroke"
|
|
78
|
+
:class="tone === 'muted' ? 'stroke-[var(--ads-loading-skeleton)]' : 'stroke-[var(--ads-loading-spinner-track)]'"
|
|
79
|
+
/>
|
|
80
|
+
<!-- Arco de 3/8 da volta, começando no topo -->
|
|
81
|
+
<circle
|
|
82
|
+
:cx="spinner.px / 2"
|
|
83
|
+
:cy="spinner.px / 2"
|
|
84
|
+
:r="spinner.radius"
|
|
85
|
+
:stroke-width="spinner.stroke"
|
|
86
|
+
:stroke-dasharray="`${spinner.arc} ${spinner.circumference}`"
|
|
87
|
+
:transform="`rotate(-90 ${spinner.px / 2} ${spinner.px / 2})`"
|
|
88
|
+
:class="tone === 'muted' ? 'stroke-[var(--ads-border-icon-support)]' : 'stroke-[var(--ads-loading-spinner-color)]'"
|
|
89
|
+
/>
|
|
90
|
+
</svg>
|
|
91
|
+
<p v-if="label" :class="labelClass">{{ label }}</p>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<script setup lang="ts">
|
|
96
|
+
import { computed } from "vue";
|
|
97
|
+
import radarLogoUrl from "../assets/brand/radar-symbol.svg?url";
|
|
98
|
+
|
|
99
|
+
export type AdsLoadingVariant = "spinner" | "skeleton" | "shimmer" | "logo";
|
|
100
|
+
export type AdsLoadingSize = "sm" | "md" | "lg";
|
|
101
|
+
export type AdsLoadingTone = "primary" | "muted";
|
|
102
|
+
|
|
103
|
+
const props = withDefaults(
|
|
104
|
+
defineProps<{
|
|
105
|
+
/**
|
|
106
|
+
* spinner: área ainda vazia.
|
|
107
|
+
* skeleton: o formato da tela já é conhecido.
|
|
108
|
+
* shimmer: bloco cinza com brilho; com `overlay`, brilho sobre o conteúdo.
|
|
109
|
+
* logo: símbolo do Radar, para a página ou uma seção inteira.
|
|
110
|
+
*/
|
|
111
|
+
variant?: AdsLoadingVariant;
|
|
112
|
+
/** sm na tabela, md na seção, lg no modal. */
|
|
113
|
+
size?: AdsLoadingSize;
|
|
114
|
+
/** primary no dado principal, muted em áreas secundárias. */
|
|
115
|
+
tone?: AdsLoadingTone;
|
|
116
|
+
/** Centraliza o spinner ou o logo numa seção vazia. Só no código: o Figma não tem esse eixo. */
|
|
117
|
+
region?: boolean;
|
|
118
|
+
/** Rótulo: à direita do spinner, acima do logo. */
|
|
119
|
+
label?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Linhas do skeleton. Zero desenha um bloco só; altura e largura vêm da class.
|
|
122
|
+
* Só no código: o Figma define 3 linhas fixas.
|
|
123
|
+
*/
|
|
124
|
+
lines?: number;
|
|
125
|
+
/** Shimmer só com o brilho, por cima do conteúdo do pai. Só no código. */
|
|
126
|
+
overlay?: boolean;
|
|
127
|
+
}>(),
|
|
128
|
+
{
|
|
129
|
+
variant: "spinner",
|
|
130
|
+
size: "md",
|
|
131
|
+
tone: "primary",
|
|
132
|
+
region: false,
|
|
133
|
+
label: "",
|
|
134
|
+
lines: 3,
|
|
135
|
+
overlay: false,
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
/** Anel do Figma: 16, 24 e 40 px, com trilha de 2, 3 e 4 px. */
|
|
140
|
+
const SPINNER = {
|
|
141
|
+
sm: { px: 16, stroke: 2 },
|
|
142
|
+
md: { px: 24, stroke: 3 },
|
|
143
|
+
lg: { px: 40, stroke: 4 },
|
|
144
|
+
} as const;
|
|
145
|
+
|
|
146
|
+
const spinner = computed(() => {
|
|
147
|
+
const { px, stroke } = SPINNER[props.size];
|
|
148
|
+
const radius = (px - stroke) / 2;
|
|
149
|
+
const circumference = 2 * Math.PI * radius;
|
|
150
|
+
return { px, stroke, radius, circumference, arc: circumference * 0.375 };
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
/** Larguras do Figma: 240, 192 e 144 px num bloco de 240. */
|
|
154
|
+
const skeletonWidths = ["w-full", "w-4/5", "w-3/5"] as const;
|
|
155
|
+
|
|
156
|
+
const skeletonLines = computed(() =>
|
|
157
|
+
Array.from({ length: props.lines }, (_, index) => skeletonWidths[index % skeletonWidths.length]),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const skeletonLineClass = computed(() => {
|
|
161
|
+
if (props.size === "sm") return "h-2";
|
|
162
|
+
if (props.size === "lg") return "h-4";
|
|
163
|
+
return "h-[var(--ads-loading-bar)]";
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const skeletonColorClass = computed(() =>
|
|
167
|
+
props.tone === "muted" ? "bg-[var(--ads-loading-skeleton-muted)]" : "bg-[var(--ads-loading-skeleton)]",
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const shimmerHeightClass = computed(() => {
|
|
171
|
+
if (props.size === "sm") return "h-10";
|
|
172
|
+
if (props.size === "lg") return "h-30";
|
|
173
|
+
return "h-20";
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const logoSizeClass = computed(() => {
|
|
177
|
+
// Tamanhos do Figma: 66×41, 156×98 e 216×136.
|
|
178
|
+
if (props.size === "sm") return "h-[41px] w-auto";
|
|
179
|
+
if (props.size === "lg") return "h-[136px] w-auto";
|
|
180
|
+
return "h-[98px] w-auto";
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const logoToneClass = computed(() =>
|
|
184
|
+
props.tone === "muted" ? "opacity-40" : "opacity-100",
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const labelClass =
|
|
188
|
+
"text-[length:var(--ads-loading-label-size)] leading-[1.3] whitespace-nowrap text-[var(--ads-text-secondary)]";
|
|
189
|
+
|
|
190
|
+
const regionClass = "flex min-h-48 w-full items-center justify-center gap-2 py-10 text-center sm:py-12";
|
|
191
|
+
|
|
192
|
+
const logoRootClass = computed(() =>
|
|
193
|
+
props.region ? `${regionClass} flex-col` : "inline-flex flex-col items-center gap-2 text-center",
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const spinnerRootClass = computed(() =>
|
|
197
|
+
props.region ? regionClass : "inline-flex items-center gap-2",
|
|
198
|
+
);
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<style scoped>
|
|
202
|
+
.ads-loading-logo {
|
|
203
|
+
animation: ads-loading-logo-pulse 1.6s ease-in-out infinite;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@keyframes ads-loading-logo-pulse {
|
|
207
|
+
0%, 100% { opacity: 1; }
|
|
208
|
+
50% { opacity: 0.25; }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@media (prefers-reduced-motion: reduce) {
|
|
212
|
+
.ads-loading-logo {
|
|
213
|
+
animation: none;
|
|
214
|
+
opacity: 0.5;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
</style>
|