mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-27 13:40:31 +00:00
src 结构调整, 添加 functions
This commit is contained in:
140
src/types/color.ts
Normal file
140
src/types/color.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
const num = {
|
||||
num1: null,
|
||||
num2: null,
|
||||
num3: null,
|
||||
num4: null,
|
||||
num5: null,
|
||||
num6: null,
|
||||
num7: null,
|
||||
};
|
||||
|
||||
const alpha = {
|
||||
num10: null,
|
||||
num20: null,
|
||||
num30: null,
|
||||
num40: null,
|
||||
num50: null,
|
||||
num60: null,
|
||||
num70: null,
|
||||
num80: null,
|
||||
num90: null,
|
||||
};
|
||||
|
||||
export const primary = {
|
||||
self: null,
|
||||
contrast: null,
|
||||
dark: num,
|
||||
light: num,
|
||||
alpha: alpha,
|
||||
hover: null,
|
||||
active: null,
|
||||
};
|
||||
|
||||
export const secondary = {
|
||||
self: null,
|
||||
dark: {
|
||||
num8: null,
|
||||
num9: null,
|
||||
num10: null,
|
||||
num11: null,
|
||||
num12: null,
|
||||
num13: null,
|
||||
...num,
|
||||
},
|
||||
light: {
|
||||
num1: null,
|
||||
num2: null,
|
||||
num3: null,
|
||||
num4: null,
|
||||
},
|
||||
alpha: alpha,
|
||||
};
|
||||
|
||||
const baseColor = {
|
||||
self: null,
|
||||
light: null,
|
||||
dark: {
|
||||
num1: null,
|
||||
num2: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const self = {
|
||||
red: baseColor,
|
||||
orange: baseColor,
|
||||
yellow: baseColor,
|
||||
olive: baseColor,
|
||||
green: baseColor,
|
||||
teal: baseColor,
|
||||
blue: baseColor,
|
||||
violet: baseColor,
|
||||
purple: baseColor,
|
||||
pink: baseColor,
|
||||
brown: baseColor,
|
||||
black: baseColor,
|
||||
grey: {
|
||||
self: null,
|
||||
light: null,
|
||||
},
|
||||
gold: null,
|
||||
white: null,
|
||||
};
|
||||
|
||||
const ansiColor = {
|
||||
black: null,
|
||||
red: null,
|
||||
green: null,
|
||||
yellow: null,
|
||||
blue: null,
|
||||
magenta: null,
|
||||
cyan: null,
|
||||
white: null,
|
||||
};
|
||||
|
||||
export const ansi = {
|
||||
bright: ansiColor,
|
||||
...ansiColor,
|
||||
};
|
||||
|
||||
export const console = {
|
||||
fg: {
|
||||
self: null,
|
||||
subtle: null,
|
||||
},
|
||||
bg: null,
|
||||
border: null,
|
||||
active: {
|
||||
bg: null,
|
||||
},
|
||||
hover: {
|
||||
bg: null,
|
||||
},
|
||||
menu: {
|
||||
bg: null,
|
||||
border: null,
|
||||
},
|
||||
};
|
||||
|
||||
const row = {
|
||||
bg: null,
|
||||
border: null,
|
||||
};
|
||||
|
||||
const line = {
|
||||
linenum: {
|
||||
bg: null,
|
||||
},
|
||||
row: row,
|
||||
word: {
|
||||
bg: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const diff = {
|
||||
added: line,
|
||||
moved: {
|
||||
row: row,
|
||||
},
|
||||
removed: line,
|
||||
inactive: null,
|
||||
};
|
||||
6
src/types/index.ts
Normal file
6
src/types/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { MapLeafNodes } from "src/core/types";
|
||||
import * as color from "./color";
|
||||
|
||||
export type Primary = MapLeafNodes<typeof color.primary, string>;
|
||||
export type Secondary = MapLeafNodes<typeof color.secondary, string>;
|
||||
export type Self = MapLeafNodes<typeof color.self, string>;
|
||||
29
src/types/vars.ts
Normal file
29
src/types/vars.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createGlobalThemeContract } from "@vanilla-extract/css";
|
||||
import * as color from "./color";
|
||||
|
||||
export function varMapper(value: string | null, path: string[]) {
|
||||
if (value === null) {
|
||||
path = path.filter(item => item !== "self");
|
||||
path = path.map(item => item.replace(/^num/, ""));
|
||||
return path.join("-");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
const vars = {
|
||||
/** 用于标识当前是否为暗色主题: `"true"` 暗色 `"false"` 亮色 */
|
||||
isDarkTheme: "is-dark-theme",
|
||||
color: {
|
||||
blue: null,
|
||||
primary: color.primary,
|
||||
},
|
||||
};
|
||||
|
||||
const otherVars = {
|
||||
border: {
|
||||
radius: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const themeVars = createGlobalThemeContract(vars, varMapper);
|
||||
export const otherThemeVars = createGlobalThemeContract(otherVars, varMapper);
|
||||
Reference in New Issue
Block a user