浏览代码

[stdf]Update some colors and export type

dufu1991 1 年之前
父节点
当前提交
48ace56c06

+ 1 - 1
packages/stdf/src/data/themes/chameleon.ts

@@ -41,7 +41,7 @@ const Chameleon: ThemeProps = {
 		},
 		extend: [
 			{
-				color: 'oklch(0.754 0.139 232.661)', // #38bdf8 hsl(198, 93%, 60%)
+				color: 'oklch(0.746 0.16 232.661)', // #00bcff hsl(194, 100%, 44%)
 				alias: 'Tailwind'
 			},
 			{

+ 2 - 2
packages/stdf/src/lib/theme/index.ts

@@ -1,6 +1,6 @@
 import darkMode from './darkMode.js';
 import switchTheme from './switchTheme.js';
 import STDFTheme from './stdf.js';
-import type { ThemeProps } from './types.js';
+import type { ThemeProps, PrimaryAndDarkColor } from './types.js';
 
-export { darkMode, switchTheme, STDFTheme, type ThemeProps };
+export { darkMode, switchTheme, STDFTheme, type ThemeProps, type PrimaryAndDarkColor };

+ 9 - 8
packages/stdf/src/routes/+layout.svelte

@@ -7,6 +7,7 @@
 	import '../app.css';
 	import { menuList, type MenuListChild } from '../data/menuList.js';
 	import ThemeSwitch from './components/ThemeSwitch.svelte';
+	import { darkMode } from '$lib/theme/index.js';
 
 	let { children } = $props();
 
@@ -41,16 +42,16 @@
 	let showLeft = $derived(!(isIframe === '1' || $page.url.pathname === '/' || isComponentMode));
 
 	let theme = $state(localStorage.getItem('theme') === 'dark' ? 'dark' : 'light');
-	// 设置主题
-	// Set theme
+
+	// 设置亮暗模式
+	// Set light and dark mode
 	if (localStorage.getItem('theme') === 'dark') {
-		document.documentElement.classList.add('dark');
+		darkMode();
 	} else if (localStorage.getItem('theme') === 'light') {
-		document.documentElement.classList.remove('dark');
+		darkMode(false);
 	} else {
-		document.documentElement.classList.remove('dark');
+		darkMode(false);
 	}
-
 	//手动切换亮暗模式
 	// manually switch light and dark mode
 	const toggleFun = () => {
@@ -59,13 +60,13 @@
 			// switch to light
 			theme = 'light';
 			localStorage.setItem('theme', 'light');
-			document.documentElement.classList.remove('dark');
+			darkMode(false);
 		} else {
 			// 切换到 dark
 			// switch to dark
 			theme = 'dark';
 			localStorage.setItem('theme', 'dark');
-			document.documentElement.classList.add('dark');
+			darkMode();
 		}
 	};