mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-28 15:20:30 +00:00
feat(chroma): 代码高亮重构
This commit is contained in:
@@ -57,7 +57,7 @@ type ThemeColor = {
|
|||||||
|
|
||||||
/** 定义颜色, 用于生成颜色主题
|
/** 定义颜色, 用于生成颜色主题
|
||||||
* @example
|
* @example
|
||||||
* 文件名: "dark.css.tsx"
|
* 文件名: "dark.css.ts"
|
||||||
* import type { Console, Diff, Other } from "src/types";
|
* import type { Console, Diff, Other } from "src/types";
|
||||||
* import { defineTheme, themeVars } from "src";
|
* import { defineTheme, themeVars } from "src";
|
||||||
*
|
*
|
||||||
@@ -70,7 +70,6 @@ type ThemeColor = {
|
|||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* ...
|
* ...
|
||||||
* // 会经过 lightningcss 打包处理生成最终的 CSS
|
|
||||||
* export default defineTheme({
|
* export default defineTheme({
|
||||||
* isDarkTheme: true,
|
* isDarkTheme: true,
|
||||||
* primary: "#0969da",
|
* primary: "#0969da",
|
||||||
|
|||||||
@@ -4,15 +4,6 @@ import type { MapLeafNodes, WithOptionalLayer } from "./types";
|
|||||||
|
|
||||||
export type Theme = WithOptionalLayer<MapLeafNodes<typeof themeVars, string>>;
|
export type Theme = WithOptionalLayer<MapLeafNodes<typeof themeVars, string>>;
|
||||||
|
|
||||||
function stringToBoolean(str: string, name: string): boolean {
|
|
||||||
try {
|
|
||||||
return JSON.parse(str);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
throw new Error(`Invalid boolean value(${name}): ${str}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const overlayAppearDown = "overlay-appear-down";
|
export const overlayAppearDown = "overlay-appear-down";
|
||||||
export const animationDown = `200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running ${overlayAppearDown}`;
|
export const animationDown = `200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running ${overlayAppearDown}`;
|
||||||
export const overlayAppearUp = "overlay-appear-up";
|
export const overlayAppearUp = "overlay-appear-up";
|
||||||
@@ -42,7 +33,7 @@ const emoji = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export function createTheme(theme: Theme): void {
|
export function createTheme(theme: Theme): void {
|
||||||
const isDarkTheme = stringToBoolean(theme.isDarkTheme, "isDarkTheme");
|
const isDarkTheme: boolean = JSON.parse(theme.isDarkTheme);
|
||||||
if (isDarkTheme) {
|
if (isDarkTheme) {
|
||||||
globalStyle(emoji, { filter: "invert(100%) hue-rotate(180deg)" });
|
globalStyle(emoji, { filter: "invert(100%) hue-rotate(180deg)" });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user