@henriquepetrelli/hp-design-system 1.1.16 → 1.1.18
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.
|
@@ -1427,24 +1427,22 @@
|
|
|
1427
1427
|
|
|
1428
1428
|
const emit = __emit;
|
|
1429
1429
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
const applyTheme = (isDark) => {
|
|
1435
|
-
if (typeof document === 'undefined') return
|
|
1436
|
-
|
|
1437
|
-
const theme = isDark ? 'dark' : 'light';
|
|
1430
|
+
/**
|
|
1431
|
+
* 🔑 Fonte única da verdade
|
|
1432
|
+
*/
|
|
1433
|
+
const getInitialTheme = () => localStorage.getItem('theme') === 'dark';
|
|
1438
1434
|
|
|
1439
|
-
|
|
1440
|
-
document.documentElement.classList.add(theme);
|
|
1435
|
+
const isDarkMode = vue.ref(getInitialTheme());
|
|
1441
1436
|
|
|
1442
|
-
|
|
1437
|
+
const applyTheme = (isDark) => {
|
|
1438
|
+
document.documentElement.classList.toggle('dark', isDark);
|
|
1439
|
+
document.documentElement.classList.toggle('light', !isDark);
|
|
1440
|
+
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
|
1443
1441
|
};
|
|
1444
1442
|
|
|
1445
1443
|
const toggleTheme = () => {
|
|
1446
|
-
emit('update:modelValue', isDarkMode.value);
|
|
1447
1444
|
applyTheme(isDarkMode.value);
|
|
1445
|
+
emit('update:modelValue', isDarkMode.value);
|
|
1448
1446
|
};
|
|
1449
1447
|
|
|
1450
1448
|
const handleKeydown = () => {
|
|
@@ -1452,13 +1450,23 @@
|
|
|
1452
1450
|
toggleTheme();
|
|
1453
1451
|
};
|
|
1454
1452
|
|
|
1453
|
+
/**
|
|
1454
|
+
* ✅ Sincroniza o toggle com o tema real após F5
|
|
1455
|
+
*/
|
|
1456
|
+
vue.onMounted(() => {
|
|
1457
|
+
const isDark = getInitialTheme();
|
|
1458
|
+
isDarkMode.value = isDark;
|
|
1459
|
+
emit('update:modelValue', isDark);
|
|
1460
|
+
});
|
|
1461
|
+
|
|
1455
1462
|
vue.watch(
|
|
1456
1463
|
() => props.modelValue,
|
|
1457
1464
|
(value) => {
|
|
1458
|
-
isDarkMode.value
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1465
|
+
if (value !== isDarkMode.value) {
|
|
1466
|
+
isDarkMode.value = value;
|
|
1467
|
+
applyTheme(value);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1462
1470
|
);
|
|
1463
1471
|
|
|
1464
1472
|
const computedLightBorderColor = vue.computed(
|
|
@@ -1514,7 +1522,7 @@
|
|
|
1514
1522
|
}
|
|
1515
1523
|
|
|
1516
1524
|
};
|
|
1517
|
-
const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-
|
|
1525
|
+
const ThemeSwitcher = /*#__PURE__*/_export_sfc(_sfc_main$4, [['__scopeId',"data-v-f9bbbf36"]]);
|
|
1518
1526
|
|
|
1519
1527
|
const _hoisted_1$3 = { class: "input__fieldset" };
|
|
1520
1528
|
const _hoisted_2$3 = {
|