diff --git a/globals.d.ts b/globals.d.ts new file mode 100644 index 0000000..6ddcb94 --- /dev/null +++ b/globals.d.ts @@ -0,0 +1 @@ +declare const tailwind: any; \ No newline at end of file diff --git a/src/components/Theme/ThemePrivider.tsx b/src/components/Theme/ThemePrivider.tsx index b964166..a034188 100644 --- a/src/components/Theme/ThemePrivider.tsx +++ b/src/components/Theme/ThemePrivider.tsx @@ -1,7 +1,34 @@ import { createContext, useContext, useEffect, useRef, useState } from "react"; +import { createTheme, reverseColor } from "../../utils/theme"; +import { getColorAsync } from "../../data/colors"; type ThemeSection = "dark" | "light" | "system"; +let themeLightId: string | null = null; +let themeDarkId: string | null = null; + +getColorAsync().then((color) => { + themeLightId = createTheme( + "theme-color-light", + color + ) + const rev = reverseColor(color) + themeDarkId = createTheme( + "theme-color-dark", + rev + ) +}) + +// 在退出的时候删除这两个主题 +window.addEventListener("beforeunload", () => { + if (themeLightId) { + document.getElementById(themeLightId)?.remove(); + } + if (themeDarkId) { + document.getElementById(themeDarkId)?.remove(); + } +}); + const themeMap: Record = { dark: "theme-color-dark", light: "theme-color-light", diff --git a/src/data/colors.ts b/src/data/colors.ts new file mode 100644 index 0000000..5fb48f0 --- /dev/null +++ b/src/data/colors.ts @@ -0,0 +1,94 @@ +const themeColorLight = { + "primary-7": "rgb(14, 66, 210)", + "primary-6": "rgb(22, 93, 255)", + "primary-5": "rgb(64, 128, 255)", + "primary-4": "rgb(106, 161, 255)", + "primary-3": "rgb(148, 191, 255)", + "primary-2": "rgb(190, 218, 255)", + "primary-1": "rgb(232, 243, 255)", + "success-7": "rgb(0, 154, 41)", + "success-6": "rgb(0, 180, 42)", + "success-5": "rgb(35, 195, 67)", + "success-4": "rgb(76, 210, 99)", + "success-3": "rgb(123, 225, 136)", + "success-2": "rgb(175, 240, 181)", + "success-1": "rgb(232, 255, 234)", + "warning-7": "rgb(210, 95, 0)", + "warning-6": "rgb(255, 125, 0)", + "warning-5": "rgb(255, 154, 46)", + "warning-4": "rgb(255, 182, 93)", + "warning-3": "rgb(255, 207, 139)", + "warning-2": "rgb(255, 228, 186)", + "warning-1": "rgb(255, 247, 232)", + "danger-7": "rgb(203, 39, 45)", + "danger-6": "rgb(245, 63, 63)", + "danger-5": "rgb(247, 101, 96)", + "danger-4": "rgb(249, 137, 129)", + "danger-3": "rgb(251, 172, 163)", + "danger-2": "rgb(253, 205, 197)", + "danger-1": "rgb(255, 236, 232)", + "link-7": "rgb(14, 66, 210)", + "link-6": "rgb(22, 93, 255)", + "link-5": "rgb(64, 128, 255)", + "link-4": "rgb(106, 161, 255)", + "link-3": "rgb(148, 191, 255)", + "link-2": "rgb(190, 218, 255)", + "link-1": "rgb(232, 243, 255)", + "data-1": "rgb(64, 128, 255)", + "data-2": "rgb(190, 218, 255)", + "data-3": "rgb(85, 197, 253)", + "data-4": "rgb(156, 220, 252)", + "data-5": "rgb(255, 125, 0)", + "data-6": "rgb(255, 207, 139)", + "data-7": "rgb(76, 210, 99)", + "data-8": "rgb(175, 240, 181)", + "data-9": "rgb(168, 113, 227)", + "data-10": "rgb(221, 190, 246)", + "data-11": "rgb(247, 186, 30)", + "data-12": "rgb(250, 220, 109)", + "data-13": "rgb(159, 219, 29)", + "data-14": "rgb(201, 233, 104)", + "data-15": "rgb(249, 121, 183)", + "data-16": "rgb(251, 157, 199)", + "data-17": "rgb(20, 201, 201)", + "data-18": "rgb(137, 233, 224)", + "data-19": "rgb(232, 101, 223)", + "data-20": "rgb(247, 186, 239)", + "color-border-1": "rgb(242, 243, 245)", + "color-border-2": "rgb(229, 230, 235)", + "color-border-3": "rgb(201, 205, 212)", + "color-border-4": "rgb(134, 144, 156)", + "color-border-5": "rgb(78, 89, 105)", + "color-border-6": "rgb(29, 33, 41)", + "color-border-7": "rgb(14, 16, 20)", + "color-fill-1": "rgb(247, 248, 250)", + "color-fill-2": "rgb(242, 243, 245)", + "color-fill-3": "rgb(229, 230, 235)", + "color-fill-4": "rgb(201, 205, 212)", + "color-fill-5": "rgb(134, 144, 156)", + "color-fill-6": "rgb(78, 89, 105)", + "color-fill-7": "rgb(29, 33, 41)", + "color-text-1": "rgb(29, 33, 41)", + "color-text-2": "rgb(78, 89, 105)", + "color-text-3": "rgb(134, 144, 156)", + "color-text-4": "rgb(201, 205, 212)", + "color-text-5": "rgb(229, 230, 235)", + "color-text-6": "rgb(242, 243, 245)", + "color-text-7": "rgb(247, 248, 250)", + "color-bg-1": "rgb(255, 255, 255)", + "color-bg-2": "rgb(255, 255, 255)", + "color-bg-3": "rgb(255, 255, 255)", + "color-bg-4": "rgb(255, 255, 255)", + "color-bg-5": "rgb(255, 255, 255)", + "color-bg-6": "rgb(255, 255, 255)", + "color-bg-7": "rgb(255, 255, 255)", + "color-bg-white": "rgb(255, 255, 255)", + "color-bg-black": "rgb(0, 0, 0)", + "color-shadow": "rgba(255, 255, 255, 0.5)", +}; + +export const getColorAsync = async () => { + return await Promise.resolve({ + ...themeColorLight, + }); +}; diff --git a/src/data/functionBlocks.ts b/src/data/functionBlocks.ts index 82b345e..4abb2b0 100644 --- a/src/data/functionBlocks.ts +++ b/src/data/functionBlocks.ts @@ -36,10 +36,10 @@ const Banner = (props: { return (
-

+

{props.title}

-

+

{props.subTitle}