@henriquepetrelli/hp-design-system 1.1.2 → 1.1.4
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.
|
@@ -1286,7 +1286,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
1286
1286
|
const ToggleSwitch = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-14c54b46"]]);
|
|
1287
1287
|
|
|
1288
1288
|
const _hoisted_1$4 = { class: "theme-switcher-container" };
|
|
1289
|
-
const _hoisted_2$4 = ["id", "
|
|
1289
|
+
const _hoisted_2$4 = ["id", "aria-checked"];
|
|
1290
1290
|
const _hoisted_3$4 = ["for", "onKeydown"];
|
|
1291
1291
|
|
|
1292
1292
|
|
|
@@ -1324,6 +1324,37 @@ const props = __props;
|
|
|
1324
1324
|
|
|
1325
1325
|
const isDarkMode = ref(false);
|
|
1326
1326
|
|
|
1327
|
+
// Função para pegar variáveis CSS do projeto
|
|
1328
|
+
const getCSSVariable = (name, fallback) => {
|
|
1329
|
+
return (
|
|
1330
|
+
getComputedStyle(document.documentElement).getPropertyValue(name).trim() ||
|
|
1331
|
+
fallback
|
|
1332
|
+
)
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
// Computed para cores do switcher
|
|
1336
|
+
const computedLightBackgroundColor = computed(() => {
|
|
1337
|
+
return (
|
|
1338
|
+
props.lightBackgroundColor ||
|
|
1339
|
+
getCSSVariable('--color-background', '#96dcee')
|
|
1340
|
+
)
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
const computedLightBorderColor = computed(() => {
|
|
1344
|
+
return props.lightBorderColor || getCSSVariable('--color-primary', '#72cce3')
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
const computedDarkBackgroundColor = computed(() => {
|
|
1348
|
+
return (
|
|
1349
|
+
props.darkBackgroundColor || getCSSVariable('--color-background', '#1261a0')
|
|
1350
|
+
)
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
const computedDarkBorderColor = computed(() => {
|
|
1354
|
+
return props.darkBorderColor || getCSSVariable('--color-primary', '#072f5f')
|
|
1355
|
+
});
|
|
1356
|
+
|
|
1357
|
+
// Alterna tema baseado no valor atual de isDarkMode
|
|
1327
1358
|
const toggleTheme = () => {
|
|
1328
1359
|
if (isDarkMode.value) {
|
|
1329
1360
|
document.documentElement.classList.remove('light');
|
|
@@ -1336,11 +1367,13 @@ const toggleTheme = () => {
|
|
|
1336
1367
|
}
|
|
1337
1368
|
};
|
|
1338
1369
|
|
|
1370
|
+
// Alterna tema via teclado
|
|
1339
1371
|
const handleKeydown = () => {
|
|
1340
1372
|
isDarkMode.value = !isDarkMode.value;
|
|
1341
1373
|
toggleTheme();
|
|
1342
1374
|
};
|
|
1343
1375
|
|
|
1376
|
+
// Inicializa o tema baseado no localStorage ou preferência do sistema
|
|
1344
1377
|
onMounted(() => {
|
|
1345
1378
|
const savedTheme =
|
|
1346
1379
|
localStorage.getItem('theme') ||
|
|
@@ -1354,22 +1387,6 @@ onMounted(() => {
|
|
|
1354
1387
|
document.documentElement.classList.add('light');
|
|
1355
1388
|
}
|
|
1356
1389
|
});
|
|
1357
|
-
|
|
1358
|
-
const computedLightBorderColor = computed(() => {
|
|
1359
|
-
return props.lightBorderColor || '#72cce3'
|
|
1360
|
-
});
|
|
1361
|
-
|
|
1362
|
-
const computedLightBackgroundColor = computed(() => {
|
|
1363
|
-
return props.lightBackgroundColor || '#96dcee'
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
const computedDarkBorderColor = computed(() => {
|
|
1367
|
-
return props.darkBorderColor || '#072f5f'
|
|
1368
|
-
});
|
|
1369
|
-
|
|
1370
|
-
const computedDarkBackgroundColor = computed(() => {
|
|
1371
|
-
return props.darkBackgroundColor || '#1261a0'
|
|
1372
|
-
});
|
|
1373
1390
|
|
|
1374
1391
|
return (_ctx, _cache) => {
|
|
1375
1392
|
return (openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
@@ -1378,7 +1395,6 @@ return (_ctx, _cache) => {
|
|
|
1378
1395
|
id: __props.id,
|
|
1379
1396
|
class: "toggle--checkbox",
|
|
1380
1397
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((isDarkMode).value = $event)),
|
|
1381
|
-
checked: __props.modelValue,
|
|
1382
1398
|
onChange: toggleTheme,
|
|
1383
1399
|
role: "switch",
|
|
1384
1400
|
"aria-checked": isDarkMode.value,
|
|
@@ -1410,7 +1426,7 @@ return (_ctx, _cache) => {
|
|
|
1410
1426
|
}
|
|
1411
1427
|
|
|
1412
1428
|
};
|
|
1413
|
-
const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-
|
|
1429
|
+
const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-d1afbbb3"]]);
|
|
1414
1430
|
|
|
1415
1431
|
const _hoisted_1$3 = { class: "input__fieldset" };
|
|
1416
1432
|
const _hoisted_2$3 = {
|