mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-26 13:00:31 +00:00
Compare commits
12 Commits
v1.24.0.25
...
59497be05e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59497be05e | ||
|
|
bedb8befa7 | ||
|
|
5ae1f2f634 | ||
|
|
16298f2b11 | ||
|
|
b5dc00e853 | ||
|
|
ac17e45069 | ||
|
|
f65338b227 | ||
|
|
711e01b66c | ||
|
|
9a070c5726 | ||
|
|
77fe50a4cc | ||
|
|
0f9ee02a7d | ||
|
|
55ac3af9b7 |
@@ -11,8 +11,6 @@ indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{css,scss,ts}]
|
||||
max_line_length = 120
|
||||
|
||||
# documentation, utils
|
||||
|
||||
4
.env.example
Normal file
4
.env.example
Normal file
@@ -0,0 +1,4 @@
|
||||
DEV_THEME=dark
|
||||
SSH_SERVER=localhost
|
||||
SSH_USER=root
|
||||
GITEA_THEME_PATH=/data/gitea/public/assets/css/
|
||||
2
.github/release-template.md
vendored
2
.github/release-template.md
vendored
@@ -4,4 +4,4 @@
|
||||
|
||||
## 🎈 Perf
|
||||
|
||||
## 🐞 Fix
|
||||
## 🐞 Fix
|
||||
|
||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -11,13 +11,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: denoland/setup-deno@v2
|
||||
with:
|
||||
deno-version: v2.x
|
||||
- name: Build theme
|
||||
run: |
|
||||
npm install
|
||||
npm run build
|
||||
- name: Create release
|
||||
run: |
|
||||
export TZ=Asia/Shanghai
|
||||
TAG="v$(./build.ts).$(date +%y%m%d%H%M)"
|
||||
TAG="v$(npm run -s version).$(date +%y%m%d%H%M)"
|
||||
gh release create "$TAG" dist/* --notes-file .github/release.md --draft -t $TAG
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
dist
|
||||
node_modules
|
||||
package-lock.json
|
||||
package-lock.json
|
||||
.env
|
||||
@@ -1,5 +0,0 @@
|
||||
dist/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
deno.json
|
||||
deno.lock
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "avoid",
|
||||
"proseWrap": "always",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
9
.vscode/extensions.json
vendored
Normal file
9
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"usernamehw.errorlens",
|
||||
"mikestead.dotenv",
|
||||
"styled-components.vscode-styled-components"
|
||||
]
|
||||
}
|
||||
@@ -4,4 +4,4 @@
|
||||
| styles/components | 具体页面的元素单独风格 |
|
||||
| styles/public | 适用大部分页面的元素默认风格 |
|
||||
| themes | 颜色主题 |
|
||||
| themes/\<theme> | 具体颜色主题自己的颜色或风格 |
|
||||
| themes/\<theme> | 具体颜色主题自己的颜色或风格 |
|
||||
|
||||
26
README.md
26
README.md
@@ -1,6 +1,6 @@
|
||||
# gitea-github-theme
|
||||
|
||||
尽量保持与 GitHub Dark 相同样式的 Gitea 主题
|
||||
尽量保持与 GitHub 相同样式的 Gitea 主题
|
||||
|
||||
### 主题说明
|
||||
|
||||
@@ -42,30 +42,6 @@ THEMES = gitea-dark, github
|
||||
|
||||

|
||||
|
||||
## 构建
|
||||
|
||||
### 克隆仓库
|
||||
|
||||
```bash
|
||||
git clone https://github.com/lutinglt/gitea-github-theme.git
|
||||
cd gitea-github-theme
|
||||
```
|
||||
|
||||
### 使用 deno (推荐)
|
||||
|
||||
```bash
|
||||
deno run build
|
||||
```
|
||||
|
||||
### 使用 nodejs & npm
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
查看用于 Gitea 的主题文件: `dist/theme-github.css`
|
||||
|
||||
## 贡献
|
||||
|
||||
欢迎提交 Issue 或 Pull Request
|
||||
|
||||
34
build.js
34
build.js
@@ -1,34 +0,0 @@
|
||||
import * as process from "node:process";
|
||||
import * as fs from "node:fs";
|
||||
import * as sass from "sass";
|
||||
import * as yaml from "js-yaml";
|
||||
|
||||
async function compile(inputFile) {
|
||||
return (await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" })).css;
|
||||
}
|
||||
|
||||
async function generateTheme(themePath) {
|
||||
try {
|
||||
const fileContent = fs.readFileSync(themePath);
|
||||
const data = yaml.load(fileContent);
|
||||
console.log(data.gitea.version);
|
||||
|
||||
fs.mkdirSync("dist", { recursive: true });
|
||||
const styles = await compile("src/styles/styles.scss");
|
||||
for (const theme of data.gitea.themes) {
|
||||
const inputFile = `src/themes/${theme}.scss`;
|
||||
const outputFile = `dist/theme-github-${theme}.css`;
|
||||
const result = await compile(inputFile);
|
||||
fs.writeFileSync(outputFile, `${styles}${result}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let e = error;
|
||||
if (error instanceof Error) {
|
||||
e = error.message;
|
||||
}
|
||||
console.error("Build failed:", e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
generateTheme("theme.yml");
|
||||
43
build.ts
43
build.ts
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env -S deno run -A --allow-scripts -q
|
||||
|
||||
import * as sass from "npm:sass";
|
||||
import * as yaml from "npm:js-yaml";
|
||||
|
||||
interface Gitea {
|
||||
version: string;
|
||||
themes: [string];
|
||||
}
|
||||
|
||||
interface ThemeInfo {
|
||||
gitea: Gitea;
|
||||
}
|
||||
|
||||
async function compile(inputFile: string) {
|
||||
return (await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" })).css;
|
||||
}
|
||||
|
||||
async function generateTheme(themePath: string) {
|
||||
try {
|
||||
const fileContent = await Deno.readTextFile(themePath);
|
||||
const data: ThemeInfo = yaml.load(fileContent);
|
||||
console.log(data.gitea.version);
|
||||
|
||||
await Deno.mkdir("dist", { recursive: true });
|
||||
const styles = await compile("src/styles/styles.scss");
|
||||
for (const theme of data.gitea.themes) {
|
||||
const inputFile = `src/themes/${theme}.scss`;
|
||||
const outputFile = `dist/theme-github-${theme}.css`;
|
||||
const result = await compile(inputFile);
|
||||
await Deno.writeTextFile(outputFile, `${styles}${result}`);
|
||||
}
|
||||
} catch (error) {
|
||||
let e = error;
|
||||
if (error instanceof Error) {
|
||||
e = error.message;
|
||||
}
|
||||
console.error("Build failed:", e);
|
||||
Deno.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
generateTheme("theme.yml");
|
||||
11
deno.json
11
deno.json
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"nodeModulesDir": "auto",
|
||||
"fmt": {
|
||||
"options": {
|
||||
"lineWidth": 120
|
||||
}
|
||||
},
|
||||
"tasks": {
|
||||
"build": "deno -A --allow-scripts build.ts"
|
||||
}
|
||||
}
|
||||
170
deno.lock
generated
170
deno.lock
generated
@@ -1,170 +0,0 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:@types/node@*": "22.5.4",
|
||||
"npm:js-yaml@*": "4.1.0",
|
||||
"npm:js-yaml@^4.1.0": "4.1.0",
|
||||
"npm:sass@*": "1.84.0",
|
||||
"npm:sass@1.84.0": "1.84.0",
|
||||
"npm:sass@^1.83.0": "1.84.0"
|
||||
},
|
||||
"npm": {
|
||||
"@parcel/watcher-android-arm64@2.5.1": {
|
||||
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA=="
|
||||
},
|
||||
"@parcel/watcher-darwin-arm64@2.5.1": {
|
||||
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw=="
|
||||
},
|
||||
"@parcel/watcher-darwin-x64@2.5.1": {
|
||||
"integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg=="
|
||||
},
|
||||
"@parcel/watcher-freebsd-x64@2.5.1": {
|
||||
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ=="
|
||||
},
|
||||
"@parcel/watcher-linux-arm-glibc@2.5.1": {
|
||||
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA=="
|
||||
},
|
||||
"@parcel/watcher-linux-arm-musl@2.5.1": {
|
||||
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q=="
|
||||
},
|
||||
"@parcel/watcher-linux-arm64-glibc@2.5.1": {
|
||||
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w=="
|
||||
},
|
||||
"@parcel/watcher-linux-arm64-musl@2.5.1": {
|
||||
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg=="
|
||||
},
|
||||
"@parcel/watcher-linux-x64-glibc@2.5.1": {
|
||||
"integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A=="
|
||||
},
|
||||
"@parcel/watcher-linux-x64-musl@2.5.1": {
|
||||
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg=="
|
||||
},
|
||||
"@parcel/watcher-win32-arm64@2.5.1": {
|
||||
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw=="
|
||||
},
|
||||
"@parcel/watcher-win32-ia32@2.5.1": {
|
||||
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ=="
|
||||
},
|
||||
"@parcel/watcher-win32-x64@2.5.1": {
|
||||
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA=="
|
||||
},
|
||||
"@parcel/watcher@2.5.1": {
|
||||
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
|
||||
"dependencies": [
|
||||
"@parcel/watcher-android-arm64",
|
||||
"@parcel/watcher-darwin-arm64",
|
||||
"@parcel/watcher-darwin-x64",
|
||||
"@parcel/watcher-freebsd-x64",
|
||||
"@parcel/watcher-linux-arm-glibc",
|
||||
"@parcel/watcher-linux-arm-musl",
|
||||
"@parcel/watcher-linux-arm64-glibc",
|
||||
"@parcel/watcher-linux-arm64-musl",
|
||||
"@parcel/watcher-linux-x64-glibc",
|
||||
"@parcel/watcher-linux-x64-musl",
|
||||
"@parcel/watcher-win32-arm64",
|
||||
"@parcel/watcher-win32-ia32",
|
||||
"@parcel/watcher-win32-x64",
|
||||
"detect-libc",
|
||||
"is-glob",
|
||||
"micromatch",
|
||||
"node-addon-api"
|
||||
]
|
||||
},
|
||||
"@types/node@22.5.4": {
|
||||
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
|
||||
"dependencies": [
|
||||
"undici-types"
|
||||
]
|
||||
},
|
||||
"argparse@2.0.1": {
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"braces@3.0.3": {
|
||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||
"dependencies": [
|
||||
"fill-range"
|
||||
]
|
||||
},
|
||||
"chokidar@4.0.3": {
|
||||
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
||||
"dependencies": [
|
||||
"readdirp"
|
||||
]
|
||||
},
|
||||
"detect-libc@1.0.3": {
|
||||
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="
|
||||
},
|
||||
"fill-range@7.1.1": {
|
||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||
"dependencies": [
|
||||
"to-regex-range"
|
||||
]
|
||||
},
|
||||
"immutable@5.0.3": {
|
||||
"integrity": "sha512-P8IdPQHq3lA1xVeBRi5VPqUm5HDgKnx0Ru51wZz5mjxHr5n3RWhjIpOFU7ybkUxfB+5IToy+OLaHYDBIWsv+uw=="
|
||||
},
|
||||
"is-extglob@2.1.1": {
|
||||
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="
|
||||
},
|
||||
"is-glob@4.0.3": {
|
||||
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||
"dependencies": [
|
||||
"is-extglob"
|
||||
]
|
||||
},
|
||||
"is-number@7.0.0": {
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
|
||||
},
|
||||
"js-yaml@4.1.0": {
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dependencies": [
|
||||
"argparse"
|
||||
]
|
||||
},
|
||||
"micromatch@4.0.8": {
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"dependencies": [
|
||||
"braces",
|
||||
"picomatch"
|
||||
]
|
||||
},
|
||||
"node-addon-api@7.1.1": {
|
||||
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ=="
|
||||
},
|
||||
"picomatch@2.3.1": {
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="
|
||||
},
|
||||
"readdirp@4.1.1": {
|
||||
"integrity": "sha512-h80JrZu/MHUZCyHu5ciuoI0+WxsCxzxJTILn6Fs8rxSnFPh+UVHYfeIxK1nVGugMqkfC4vJcBOYbkfkwYK0+gw=="
|
||||
},
|
||||
"sass@1.84.0": {
|
||||
"integrity": "sha512-XDAbhEPJRxi7H0SxrnOpiXFQoUJHwkR2u3Zc4el+fK/Tt5Hpzw5kkQ59qVDfvdaUq6gCrEZIbySFBM2T9DNKHg==",
|
||||
"dependencies": [
|
||||
"@parcel/watcher",
|
||||
"chokidar",
|
||||
"immutable",
|
||||
"source-map-js"
|
||||
]
|
||||
},
|
||||
"source-map-js@1.2.1": {
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
|
||||
},
|
||||
"to-regex-range@5.0.1": {
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dependencies": [
|
||||
"is-number"
|
||||
]
|
||||
},
|
||||
"undici-types@6.19.8": {
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"packageJson": {
|
||||
"dependencies": [
|
||||
"npm:js-yaml@^4.1.0",
|
||||
"npm:sass@^1.83.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
24
eslint.config.js
Normal file
24
eslint.config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import js from "@eslint/js";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import reactRefresh from "eslint-plugin-react-refresh";
|
||||
import globals from "globals";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ["dist"] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
"react-hooks": reactHooks,
|
||||
"react-refresh": reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
},
|
||||
}
|
||||
);
|
||||
62
package.json
62
package.json
@@ -1,10 +1,66 @@
|
||||
{
|
||||
"name": "gitea-github-theme",
|
||||
"version": "1.24.2",
|
||||
"description": "A theme to make Gitea look and feel like GitHub",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node build.js"
|
||||
"dev": "vite build --mode dev",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"commit": "npm run lint && npm run format && npm run build",
|
||||
"version": "node scripts/version.cjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"js-yaml": "^4.1.0",
|
||||
"sass": "^1.83.0"
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
"@eslint/js": "^9.29.0",
|
||||
"@linaria/core": "^6.3.0",
|
||||
"@linaria/react": "^6.3.0",
|
||||
"@types/node": "^24.0.3",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@vanilla-extract/css": "^1.17.4",
|
||||
"@vanilla-extract/vite-plugin": "^5.0.6",
|
||||
"@vitejs/plugin-react": "^4.5.2",
|
||||
"@vitejs/plugin-react-swc": "^3.10.2",
|
||||
"@wyw-in-js/babel-preset": "^0.7.0",
|
||||
"@wyw-in-js/vite": "^0.7.0",
|
||||
"dotenv": "^17.0.0",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"globals": "^16.2.0",
|
||||
"lightningcss": "^1.30.1",
|
||||
"polished": "^4.3.1",
|
||||
"prettier": "3.5.3",
|
||||
"prettier-plugin-organize-imports": "^4.1.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"sass-embedded": "^1.89.2",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.34.1",
|
||||
"typescript-plugin-css-modules": "^5.1.0",
|
||||
"vite": "^6.3.5"
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "avoid",
|
||||
"proseWrap": "always",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"endOfLine": "lf",
|
||||
"plugins": [
|
||||
"prettier-plugin-organize-imports"
|
||||
],
|
||||
"organizeImportsSkipDestructiveCodeActions": false
|
||||
}
|
||||
}
|
||||
|
||||
8
scripts/version.cjs
Normal file
8
scripts/version.cjs
Normal file
@@ -0,0 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const pkgPath = path.join(__dirname, '..', 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
||||
|
||||
const version = pkg.version;
|
||||
console.log(version);
|
||||
324
src/core/color.ts
Normal file
324
src/core/color.ts
Normal file
@@ -0,0 +1,324 @@
|
||||
import { rgba } from "polished";
|
||||
import { scaleColorLight } from "src/functions";
|
||||
import type { Ansi, Based, Console, Diff, Message, Named, Primary, Secondary } from "src/types";
|
||||
import { themeVars } from "src/types/vars";
|
||||
import type { Theme } from "./theme";
|
||||
|
||||
interface ColorTheme {
|
||||
isDarkTheme: boolean;
|
||||
primary: string;
|
||||
primaryContrast: string;
|
||||
secondary: string;
|
||||
red: string;
|
||||
orange: string;
|
||||
yellow: string;
|
||||
olive: string;
|
||||
green: string;
|
||||
teal: string;
|
||||
blue: string;
|
||||
violet: string;
|
||||
purple: string;
|
||||
pink: string;
|
||||
brown: string;
|
||||
black: string;
|
||||
grey: string;
|
||||
gold: string;
|
||||
white: string;
|
||||
console: Console;
|
||||
diff: Diff;
|
||||
based: Based;
|
||||
}
|
||||
|
||||
/** 定义颜色, 用于生成颜色主题
|
||||
* @example
|
||||
* 文件名: `color-dark.css.ts`
|
||||
* import type { Primary } from "src/types";
|
||||
* import { defineTheme, themeVars } from "src";
|
||||
*
|
||||
* const primary: Primary = {
|
||||
* self: "#ffffff",
|
||||
* contrast: themeVars.color.white,
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* export default defineTheme({
|
||||
* isDarkTheme: "true",
|
||||
* color: {
|
||||
* primary,
|
||||
* ...
|
||||
* }
|
||||
* })
|
||||
*/
|
||||
export function defineTheme(theme: ColorTheme): Theme {
|
||||
const lighten = theme.isDarkTheme ? -1 : 1;
|
||||
|
||||
const primary: Primary = {
|
||||
self: theme.primary,
|
||||
contrast: theme.primaryContrast,
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.primary, -3 * lighten),
|
||||
num2: scaleColorLight(theme.primary, -6 * lighten),
|
||||
num3: scaleColorLight(theme.primary, -9 * lighten),
|
||||
num4: scaleColorLight(theme.primary, -12 * lighten),
|
||||
num5: scaleColorLight(theme.primary, -15 * lighten),
|
||||
num6: scaleColorLight(theme.primary, -18 * lighten),
|
||||
num7: scaleColorLight(theme.primary, -21 * lighten),
|
||||
},
|
||||
light: {
|
||||
num1: scaleColorLight(theme.primary, 3 * lighten),
|
||||
num2: scaleColorLight(theme.primary, 6 * lighten),
|
||||
num3: scaleColorLight(theme.primary, 9 * lighten),
|
||||
num4: scaleColorLight(theme.primary, 12 * lighten),
|
||||
num5: scaleColorLight(theme.primary, 15 * lighten),
|
||||
num6: scaleColorLight(theme.primary, 18 * lighten),
|
||||
num7: scaleColorLight(theme.primary, 21 * lighten),
|
||||
},
|
||||
alpha: {
|
||||
num10: rgba(theme.primary, 0.1),
|
||||
num20: rgba(theme.primary, 0.2),
|
||||
num30: rgba(theme.primary, 0.3),
|
||||
num40: rgba(theme.primary, 0.4),
|
||||
num50: rgba(theme.primary, 0.5),
|
||||
num60: rgba(theme.primary, 0.6),
|
||||
num70: rgba(theme.primary, 0.7),
|
||||
num80: rgba(theme.primary, 0.8),
|
||||
num90: rgba(theme.primary, 0.9),
|
||||
},
|
||||
hover: theme.isDarkTheme ? themeVars.color.primary.light.num1 : themeVars.color.primary.dark.num1,
|
||||
active: theme.isDarkTheme ? themeVars.color.primary.light.num2 : themeVars.color.primary.dark.num2,
|
||||
};
|
||||
|
||||
const secondary: Secondary = {
|
||||
self: theme.secondary,
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.secondary, -3 * lighten),
|
||||
num2: scaleColorLight(theme.secondary, -6 * lighten),
|
||||
num3: scaleColorLight(theme.secondary, -9 * lighten),
|
||||
num4: scaleColorLight(theme.secondary, -12 * lighten),
|
||||
num5: scaleColorLight(theme.secondary, -15 * lighten),
|
||||
num6: scaleColorLight(theme.secondary, -18 * lighten),
|
||||
num7: scaleColorLight(theme.secondary, -21 * lighten),
|
||||
num8: scaleColorLight(theme.secondary, -24 * lighten),
|
||||
num9: scaleColorLight(theme.secondary, -27 * lighten),
|
||||
num10: scaleColorLight(theme.secondary, -30 * lighten),
|
||||
num11: scaleColorLight(theme.secondary, -33 * lighten),
|
||||
num12: scaleColorLight(theme.secondary, -36 * lighten),
|
||||
num13: scaleColorLight(theme.secondary, -39 * lighten),
|
||||
},
|
||||
light: {
|
||||
num1: scaleColorLight(theme.secondary, 3 * lighten),
|
||||
num2: scaleColorLight(theme.secondary, 6 * lighten),
|
||||
num3: scaleColorLight(theme.secondary, 9 * lighten),
|
||||
num4: scaleColorLight(theme.secondary, 12 * lighten),
|
||||
},
|
||||
alpha: {
|
||||
num10: rgba(theme.secondary, 0.1),
|
||||
num20: rgba(theme.secondary, 0.2),
|
||||
num30: rgba(theme.secondary, 0.3),
|
||||
num40: rgba(theme.secondary, 0.4),
|
||||
num50: rgba(theme.secondary, 0.5),
|
||||
num60: rgba(theme.secondary, 0.6),
|
||||
num70: rgba(theme.secondary, 0.7),
|
||||
num80: rgba(theme.secondary, 0.8),
|
||||
num90: rgba(theme.secondary, 0.9),
|
||||
},
|
||||
button: themeVars.color.secondary.dark.num4,
|
||||
hover: theme.isDarkTheme ? themeVars.color.secondary.dark.num3 : themeVars.color.secondary.dark.num5,
|
||||
active: theme.isDarkTheme ? themeVars.color.secondary.dark.num2 : themeVars.color.secondary.dark.num6,
|
||||
};
|
||||
|
||||
const named: Named = {
|
||||
red: {
|
||||
self: theme.red,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.red, 10) : scaleColorLight(theme.red, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.red, -10),
|
||||
num2: scaleColorLight(theme.red, -20),
|
||||
},
|
||||
badge: {
|
||||
self: theme.red,
|
||||
bg: rgba(theme.red, 0.1),
|
||||
hover: {
|
||||
bg: rgba(theme.red, 0.3),
|
||||
},
|
||||
},
|
||||
},
|
||||
orange: {
|
||||
self: theme.orange,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.orange, 10) : scaleColorLight(theme.orange, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.orange, -10),
|
||||
num2: scaleColorLight(theme.orange, -20),
|
||||
},
|
||||
badge: {
|
||||
self: theme.orange,
|
||||
bg: rgba(theme.orange, 0.1),
|
||||
hover: {
|
||||
bg: rgba(theme.orange, 0.3),
|
||||
},
|
||||
},
|
||||
},
|
||||
yellow: {
|
||||
self: theme.yellow,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.yellow, 10) : scaleColorLight(theme.yellow, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.yellow, -10),
|
||||
num2: scaleColorLight(theme.yellow, -20),
|
||||
},
|
||||
badge: {
|
||||
self: theme.yellow,
|
||||
bg: rgba(theme.yellow, 0.1),
|
||||
hover: {
|
||||
bg: rgba(theme.yellow, 0.3),
|
||||
},
|
||||
},
|
||||
},
|
||||
olive: {
|
||||
self: theme.olive,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.olive, 10) : scaleColorLight(theme.olive, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.olive, -10),
|
||||
num2: scaleColorLight(theme.olive, -20),
|
||||
},
|
||||
},
|
||||
green: {
|
||||
self: theme.green,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.green, 10) : scaleColorLight(theme.green, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.green, -10),
|
||||
num2: scaleColorLight(theme.green, -20),
|
||||
},
|
||||
badge: {
|
||||
self: theme.green,
|
||||
bg: rgba(theme.green, 0.1),
|
||||
hover: {
|
||||
bg: rgba(theme.green, 0.3),
|
||||
},
|
||||
},
|
||||
},
|
||||
teal: {
|
||||
self: theme.teal,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.teal, 10) : scaleColorLight(theme.teal, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.teal, -10),
|
||||
num2: scaleColorLight(theme.teal, -20),
|
||||
},
|
||||
},
|
||||
blue: {
|
||||
self: theme.blue,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.blue, 10) : scaleColorLight(theme.blue, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.blue, -10),
|
||||
num2: scaleColorLight(theme.blue, -20),
|
||||
},
|
||||
},
|
||||
violet: {
|
||||
self: theme.violet,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.violet, 10) : scaleColorLight(theme.violet, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.violet, -10),
|
||||
num2: scaleColorLight(theme.violet, -20),
|
||||
},
|
||||
},
|
||||
purple: {
|
||||
self: theme.purple,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.purple, 10) : scaleColorLight(theme.purple, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.purple, -10),
|
||||
num2: scaleColorLight(theme.purple, -20),
|
||||
},
|
||||
},
|
||||
pink: {
|
||||
self: theme.pink,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.pink, 10) : scaleColorLight(theme.pink, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.pink, -10),
|
||||
num2: scaleColorLight(theme.pink, -20),
|
||||
},
|
||||
},
|
||||
brown: {
|
||||
self: theme.brown,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.brown, 10) : scaleColorLight(theme.brown, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.brown, -10),
|
||||
num2: scaleColorLight(theme.brown, -20),
|
||||
},
|
||||
},
|
||||
black: {
|
||||
self: theme.black,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.black, 10) : scaleColorLight(theme.black, 25),
|
||||
dark: {
|
||||
num1: scaleColorLight(theme.black, -10),
|
||||
num2: scaleColorLight(theme.black, -20),
|
||||
},
|
||||
},
|
||||
grey: {
|
||||
self: theme.grey,
|
||||
light: theme.isDarkTheme ? scaleColorLight(theme.grey, 10) : scaleColorLight(theme.grey, 25),
|
||||
},
|
||||
gold: theme.gold,
|
||||
white: theme.white,
|
||||
};
|
||||
|
||||
const message: Message = {
|
||||
error: {
|
||||
bg: {
|
||||
self: rgba(theme.red, 0.1),
|
||||
active: rgba(theme.red, 0.5),
|
||||
hover: rgba(theme.red, 0.3),
|
||||
},
|
||||
border: scaleColorLight(theme.red, 30 * lighten),
|
||||
text: theme.red,
|
||||
},
|
||||
success: {
|
||||
bg: rgba(theme.green, 0.1),
|
||||
border: scaleColorLight(theme.green, 30 * lighten),
|
||||
text: theme.green,
|
||||
},
|
||||
warning: {
|
||||
bg: rgba(theme.yellow, 0.1),
|
||||
border: scaleColorLight(theme.yellow, 30 * lighten),
|
||||
text: theme.yellow,
|
||||
},
|
||||
info: {
|
||||
bg: rgba(theme.blue, 0.1),
|
||||
border: scaleColorLight(theme.blue, 30 * lighten),
|
||||
text: theme.blue,
|
||||
},
|
||||
};
|
||||
|
||||
const ansi: Ansi = {
|
||||
black: themeVars.color.black.self,
|
||||
red: themeVars.color.red.self,
|
||||
green: themeVars.color.green.self,
|
||||
yellow: themeVars.color.yellow.self,
|
||||
blue: themeVars.color.blue.self,
|
||||
magenta: themeVars.color.pink.self,
|
||||
cyan: themeVars.color.teal.self,
|
||||
white: themeVars.color.console.fg.subtle,
|
||||
bright: {
|
||||
black: themeVars.color.black.light,
|
||||
red: themeVars.color.red.light,
|
||||
green: themeVars.color.green.light,
|
||||
yellow: themeVars.color.yellow.light,
|
||||
blue: themeVars.color.blue.light,
|
||||
magenta: themeVars.color.pink.light,
|
||||
cyan: themeVars.color.teal.light,
|
||||
white: themeVars.color.console.fg.self,
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
isDarkTheme: theme.isDarkTheme.toString(),
|
||||
color: {
|
||||
primary,
|
||||
secondary,
|
||||
...named,
|
||||
ansi,
|
||||
console: theme.console,
|
||||
diff: theme.diff,
|
||||
...message,
|
||||
...theme.based,
|
||||
},
|
||||
};
|
||||
}
|
||||
1
src/core/index.ts
Normal file
1
src/core/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { createTheme } from "./theme";
|
||||
27
src/core/theme.ts
Normal file
27
src/core/theme.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createGlobalTheme, globalStyle } from "@vanilla-extract/css";
|
||||
import { otherThemeVars, themeVars } from "src/types/vars";
|
||||
import type { MapLeafNodes, WithOptionalLayer } from "./types";
|
||||
|
||||
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 function createTheme(theme: Theme): void {
|
||||
createGlobalTheme(":root", themeVars, theme);
|
||||
createGlobalTheme(":root", otherThemeVars, {
|
||||
border: {
|
||||
radius: "6px",
|
||||
},
|
||||
});
|
||||
globalStyle(":root", {
|
||||
accentColor: themeVars.color.accent,
|
||||
colorScheme: stringToBoolean(theme.isDarkTheme, "isDarkTheme") ? "dark" : "light",
|
||||
});
|
||||
}
|
||||
12
src/core/types.ts
Normal file
12
src/core/types.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
type Primitive = string | boolean | number | null | undefined;
|
||||
type Tokens = { [key: string]: string | Tokens };
|
||||
|
||||
export type WithOptionalLayer<T extends Tokens> = T & { "@layer"?: string };
|
||||
|
||||
export type MapLeafNodes<Obj, LeafType> = {
|
||||
[Prop in keyof Obj]: Obj[Prop] extends Primitive
|
||||
? LeafType
|
||||
: Obj[Prop] extends Record<string | number, unknown>
|
||||
? MapLeafNodes<Obj[Prop], LeafType>
|
||||
: never;
|
||||
};
|
||||
115
src/core/vite.ts
Normal file
115
src/core/vite.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import type { Plugin } from "vite";
|
||||
|
||||
const suffix = ".css.tsx"
|
||||
|
||||
/**
|
||||
* 生成主题输入
|
||||
* @param outDir 输出目录与 vite 配置中的 outDir 一致, 用于生成临时目录
|
||||
* @param themeDir 颜色主题目录
|
||||
* @param devTheme 开发模式下的主题, 仅打包该主题
|
||||
* @param mode 模式, 开发模式为 dev `vite build --mode dev`
|
||||
* @returns vite.rollupOptions.input 的配置
|
||||
*/
|
||||
export function themeInput(
|
||||
outDir: string,
|
||||
themeDir: string,
|
||||
devTheme: string,
|
||||
mode: string
|
||||
): { [key: string]: string } {
|
||||
const hash = crypto.randomBytes(6).toString("hex");
|
||||
const tmpDir = `${outDir}/tmp-${hash}`; // 输出目录下的临时目录
|
||||
|
||||
fs.mkdirSync(tmpDir, { recursive: true });
|
||||
|
||||
const input: { [key: string]: string } = {};
|
||||
const themeEntries = fs.readdirSync(themeDir, { withFileTypes: true });
|
||||
|
||||
for (const entry of themeEntries) {
|
||||
// 目录下所有的 css.ts 文件都作为主题入口
|
||||
if (entry.isFile() && entry.name.endsWith(suffix)) {
|
||||
const fileName = entry.name.replace(suffix, "");
|
||||
// 开发模式只打包 devTheme 主题
|
||||
if (mode === "dev" && fileName !== devTheme) continue;
|
||||
// 创建颜色主题的 css.ts 文件, vanilla-extract 需要这个文件后缀名并生成 css
|
||||
const tmpCssTs = path.join(tmpDir, `${fileName}${suffix}`);
|
||||
const createImport = `import { createTheme } from "src/core";`;
|
||||
const themeImport = `import theme from "themes/${fileName}";`;
|
||||
const createFn = `createTheme(theme);`;
|
||||
fs.writeFileSync(tmpCssTs, `${createImport}\n${themeImport}\n${createFn}`);
|
||||
// 生成主题入口的 .ts 文件, 合并样式和颜色主题
|
||||
const tmpInputTs = path.join(tmpDir, `${fileName}.ts`);
|
||||
const stylesImport = `import "styles";`;
|
||||
const cssImport = `import "./${fileName}${suffix}";`;
|
||||
fs.writeFileSync(tmpInputTs, `${stylesImport}\n${cssImport}`);
|
||||
|
||||
input[fileName] = tmpInputTs;
|
||||
}
|
||||
}
|
||||
if (mode === "dev") {
|
||||
console.log("[themeInput] devTheme:", devTheme);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
const prefix = "theme-github-";
|
||||
|
||||
/**
|
||||
* 生成主题文件
|
||||
* @important vite.rollupOptions.output 配置 `assetFileNames: "[name].[ext]"`
|
||||
*/
|
||||
export function themePlugin(): Plugin {
|
||||
return {
|
||||
name: "themePlugin",
|
||||
generateBundle(this, _, bundle) {
|
||||
let styles = "";
|
||||
for (const [key, value] of Object.entries(bundle)) {
|
||||
if (value.type === "chunk") {
|
||||
delete bundle[key]; // 删除 chunk
|
||||
} else {
|
||||
// 样式文件是通过入口导入的, 没有原始文件名
|
||||
if (value.originalFileNames.length === 0) {
|
||||
// 收集所有的样式文件(逻辑上只有一个)
|
||||
// vite 会在尾部添加注释, 后续会合并到颜色主题, 此处需要删除注释
|
||||
styles += value.source.toString().replace("/*$vite$:1*/", "");
|
||||
delete bundle[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 生成所有的主题文件
|
||||
for (const [key, value] of Object.entries(bundle)) {
|
||||
// 仅为了类型检查, 逻辑上输出中全是 asset 类型
|
||||
if (value.type === "asset") {
|
||||
const name = `${prefix}${value.names[0]}`;
|
||||
const fileName = `${prefix}${value.fileName}`;
|
||||
const originalFileName = value.originalFileNames.pop();
|
||||
const type = value.type;
|
||||
const source = `${styles}${value.source.toString()}`;
|
||||
// 添加主题到输出
|
||||
this.emitFile({ name, fileName, source, type, originalFileName });
|
||||
delete bundle[key];
|
||||
}
|
||||
}
|
||||
},
|
||||
closeBundle() {
|
||||
const server = process.env.SSH_SERVER;
|
||||
const user = process.env.SSH_USER || "root";
|
||||
const path = process.env.GITEA_THEME_PATH;
|
||||
if (server && path) {
|
||||
const cmd = `scp dist/${prefix}*.css ${user}@${server}:${path}`;
|
||||
console.log("[themePlugin] exec:", cmd);
|
||||
try {
|
||||
execSync(cmd, { stdio: "inherit" });
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (_) {
|
||||
// continue regardless of error
|
||||
}
|
||||
} else {
|
||||
console.log("[themePlugin] no SSH_SERVER or GITEA_THEME_PATH, skip upload");
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
1
src/functions/index.ts
Normal file
1
src/functions/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { scaleColorLight } from "./scss";
|
||||
27
src/functions/scss.ts
Normal file
27
src/functions/scss.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { hsl, parseToHsl } from "polished";
|
||||
|
||||
/**
|
||||
* 改变颜色的亮度, 等同于 sass 中的 `color.scale` 函数
|
||||
* @param color 颜色值
|
||||
* @param lightnessScale 亮度变化比例,负数表示变暗,正数表示变亮
|
||||
* @returns 新的颜色值
|
||||
* @example
|
||||
* const newColor = scaleColorLight("#ff0000", 20); // 变亮
|
||||
* const newColor = scaleColorLight("#ff0000", -20); // 变暗
|
||||
* 等同于 sass `@use "sass:color"`;
|
||||
* color: color.scale(#ff0000, $lightness: 20%)
|
||||
* color: color.scale(#ff0000, $lightness: -20%)
|
||||
*/
|
||||
export function scaleColorLight(color: string, lightness: number) {
|
||||
const hslColor = parseToHsl(color);
|
||||
let newLightness;
|
||||
|
||||
if (lightness < 0) {
|
||||
newLightness = hslColor.lightness * (1 + lightness / 100); // 变暗
|
||||
} else {
|
||||
newLightness = hslColor.lightness + (1 - hslColor.lightness) * (lightness / 100); // 变亮
|
||||
}
|
||||
|
||||
newLightness = Math.min(1, Math.max(0, newLightness)); // 确保亮度值在 0 到 1 之间
|
||||
return hsl(hslColor.hue, hslColor.saturation, newLightness);
|
||||
}
|
||||
4
src/index.ts
Normal file
4
src/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export { css } from "@linaria/core";
|
||||
export { defineTheme } from "./core/color";
|
||||
export type { Based, Console, Diff } from "./types";
|
||||
export { themeVars } from "./types/vars";
|
||||
@@ -1,23 +0,0 @@
|
||||
// Made by Luting ^-^
|
||||
.emoji[aria-label='check\\ mark'],
|
||||
.emoji[aria-label='currency\\ exchange'],
|
||||
.emoji[aria-label='TOP\\ arrow'],
|
||||
.emoji[aria-label='END\\ arrow'],
|
||||
.emoji[aria-label='ON! arrow'],
|
||||
.emoji[aria-label='SOON\\ arrow'],
|
||||
.emoji[aria-label='heavy dollar sign'],
|
||||
.emoji[aria-label='copyright'],
|
||||
.emoji[aria-label='registered'],
|
||||
.emoji[aria-label='trade\\ mark'],
|
||||
.emoji[aria-label='multiply'],
|
||||
.emoji[aria-label='plus'],
|
||||
.emoji[aria-label='minus'],
|
||||
.emoji[aria-label='divide'],
|
||||
.emoji[aria-label='curly\\ loop'],
|
||||
.emoji[aria-label='double curly loop'],
|
||||
.emoji[aria-label='wavy\\ dash'],
|
||||
.emoji[aria-label='paw\\ prints'],
|
||||
.emoji[aria-label='musical\\ note'],
|
||||
.emoji[aria-label='musical\\ notes'] {
|
||||
filter: invert(100%) hue-rotate(180deg);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// Made by Luting ^-^
|
||||
@use "dark/github-dark.css"; // GitHub 变量(仅主题内部使用的变量)
|
||||
@use "dark/gitea-dark.css"; // Gitea 变量(元素默认使用的变量)
|
||||
@@ -1,254 +0,0 @@
|
||||
/* Made by Luting ^-^ */
|
||||
:root {
|
||||
--is-dark-theme: true;
|
||||
--border-radius: 6px;
|
||||
|
||||
--color-primary: var(--color-blue);
|
||||
--color-primary-contrast: #fff;
|
||||
--color-primary-dark-1: #739cb3;
|
||||
--color-primary-dark-2: #40aaff;
|
||||
--color-primary-dark-3: #92b4c4;
|
||||
--color-primary-dark-4: #a1bbcd;
|
||||
--color-primary-dark-5: #cfddc1;
|
||||
--color-primary-dark-6: #e7eee0;
|
||||
--color-primary-dark-7: #f8faf6;
|
||||
--color-primary-light-1: var(--color-blue);
|
||||
--color-primary-light-2: #437aad;
|
||||
--color-primary-light-3: #415b8b;
|
||||
--color-primary-light-4: #25425a;
|
||||
--color-primary-light-5: #223546;
|
||||
--color-primary-light-6: #131923;
|
||||
--color-primary-light-7: #06090b;
|
||||
--color-primary-alpha-10: #3683c019;
|
||||
--color-primary-alpha-20: #3683c033;
|
||||
--color-primary-alpha-30: #3683c04b;
|
||||
--color-primary-alpha-40: #3683c066;
|
||||
--color-primary-alpha-50: #3683c080;
|
||||
--color-primary-alpha-60: #3683c099;
|
||||
--color-primary-alpha-70: #3683c0b3;
|
||||
--color-primary-alpha-80: #3683c0cc;
|
||||
--color-primary-alpha-90: #3683c0e1;
|
||||
--color-primary-hover: var(--color-primary-light-1);
|
||||
--color-primary-active: var(--color-primary-light-2);
|
||||
|
||||
--color-secondary: #3d444d;
|
||||
--color-secondary-dark-1: #505665;
|
||||
--color-secondary-dark-2: #5b6273;
|
||||
--color-secondary-dark-3: #71798e;
|
||||
--color-secondary-dark-4: #7f8699;
|
||||
--color-secondary-dark-5: #8c93a4;
|
||||
--color-secondary-dark-6: #9aa0af;
|
||||
--color-secondary-dark-7: #a8adba;
|
||||
--color-secondary-dark-8: #c4c7d0;
|
||||
--color-secondary-dark-9: #dfe1e6;
|
||||
--color-secondary-dark-10: #edeef1;
|
||||
--color-secondary-dark-11: #fbfbfc;
|
||||
--color-secondary-dark-12: #eeeff2;
|
||||
--color-secondary-dark-13: #fbfbfc;
|
||||
--color-secondary-light-1: #373b46;
|
||||
--color-secondary-light-2: #292c34;
|
||||
--color-secondary-light-3: #1c1e23;
|
||||
--color-secondary-light-4: #0e0f11;
|
||||
--color-secondary-alpha-10: #2c2f35;
|
||||
--color-secondary-alpha-20: #2c2f3533;
|
||||
--color-secondary-alpha-30: #2c2f354b;
|
||||
--color-secondary-alpha-40: #2c2f3566;
|
||||
--color-secondary-alpha-50: #ffffff28;
|
||||
--color-secondary-alpha-60: #161b22;
|
||||
--color-secondary-alpha-70: #2c2f35b3;
|
||||
--color-secondary-alpha-80: #2c2f35cc;
|
||||
--color-secondary-alpha-90: #2c2f35e1;
|
||||
|
||||
--color-red: #da3737;
|
||||
--color-orange: #f17a2b;
|
||||
--color-yellow: #f3c640;
|
||||
--color-olive: #c8df36;
|
||||
--color-green: #39d353;
|
||||
--color-teal: #69d4cf;
|
||||
--color-blue: #4493f8;
|
||||
--color-violet: #754ad3;
|
||||
--color-purple: #8957e5;
|
||||
--color-pink: #e04b9f;
|
||||
--color-brown: #a86d45;
|
||||
--color-black: #141516;
|
||||
--color-grey: #797c85;
|
||||
--color-gold: #d4b74c;
|
||||
--color-white: #ffffff;
|
||||
|
||||
--color-red-light: #d15a5a;
|
||||
--color-orange-light: #f6a066;
|
||||
--color-yellow-light: #eaaf03;
|
||||
--color-olive-light: #abc016;
|
||||
--color-green-light: #93b373;
|
||||
--color-teal-light: #00b6ad;
|
||||
--color-blue-light: #4e96cc;
|
||||
--color-violet-light: #9b79e4;
|
||||
--color-purple-light: #ba6ad5;
|
||||
--color-pink-light: #d74397;
|
||||
--color-brown-light: #b08061;
|
||||
--color-black-light: #3f4555;
|
||||
|
||||
--color-red-dark-1: #c23636;
|
||||
--color-orange-dark-1: #f38236;
|
||||
--color-yellow-dark-1: #b88a03;
|
||||
--color-olive-dark-1: #839311;
|
||||
--color-green-dark-1: #238636;
|
||||
--color-teal-dark-1: #00837c;
|
||||
--color-blue-dark-1: #347cb3;
|
||||
--color-violet-dark-1: #7b4edb;
|
||||
--color-purple-dark-1: #a742c9;
|
||||
--color-pink-dark-1: #be297d;
|
||||
--color-brown-dark-1: #94674a;
|
||||
--color-black-dark-1: #292d38;
|
||||
|
||||
--color-red-dark-2: #ad3030;
|
||||
--color-orange-dark-2: #f16e17;
|
||||
--color-yellow-dark-2: #a37a02;
|
||||
--color-olive-dark-2: #74820f;
|
||||
--color-green-dark-2: #6c8c4c;
|
||||
--color-teal-dark-2: #00746e;
|
||||
--color-blue-dark-2: #2e6e9f;
|
||||
--color-violet-dark-2: #6733d6;
|
||||
--color-purple-dark-2: #9834b9;
|
||||
--color-pink-dark-2: #a9246f;
|
||||
--color-brown-dark-2: #835b42;
|
||||
--color-black-dark-2: #252832;
|
||||
|
||||
--color-ansi-black: var(--color-black);
|
||||
--color-ansi-red: var(--color-red);
|
||||
--color-ansi-green: var(--color-green);
|
||||
--color-ansi-yellow: var(--color-yellow);
|
||||
--color-ansi-blue: var(--color-blue);
|
||||
--color-ansi-magenta: var(--color-pink);
|
||||
--color-ansi-cyan: var(--color-teal);
|
||||
--color-ansi-white: var(--color-console-fg-subtle);
|
||||
--color-ansi-bright-black: var(--color-black-light);
|
||||
--color-ansi-bright-red: var(--color-red-light);
|
||||
--color-ansi-bright-green: var(--color-green-light);
|
||||
--color-ansi-bright-yellow: var(--color-yellow-light);
|
||||
--color-ansi-bright-blue: var(--color-blue-light);
|
||||
--color-ansi-bright-magenta: var(--color-pink-light);
|
||||
--color-ansi-bright-cyan: var(--color-teal-light);
|
||||
--color-ansi-bright-white: var(--color-console-fg);
|
||||
|
||||
--color-console-fg: #f0f6fc;
|
||||
--color-console-fg-subtle: #9198a1;
|
||||
--color-console-bg: #010409;
|
||||
--color-console-border: #2b3139;
|
||||
--color-console-active-bg: #2a313c;
|
||||
--color-console-hover-bg: #15191f;
|
||||
--color-console-menu-bg: var(--color-body);
|
||||
--color-console-menu-border: var(--color-light-border);
|
||||
|
||||
--color-grey: #505665;
|
||||
--color-grey-light: #a1a6b7;
|
||||
--color-gold: #b1983b;
|
||||
--color-white: #fff;
|
||||
|
||||
--color-diff-removed-word-bg: #792e2d;
|
||||
--color-diff-added-word-bg: #1d572d;
|
||||
--color-diff-removed-row-bg: #25171c;
|
||||
--color-diff-moved-row-bg: #818044;
|
||||
--color-diff-added-row-bg: #12261e;
|
||||
--color-diff-removed-row-border: #634343;
|
||||
--color-diff-moved-row-border: #bcca6f;
|
||||
--color-diff-added-row-border: #314a37;
|
||||
--color-diff-inactive: #353846;
|
||||
|
||||
--color-error-border: #792e2e;
|
||||
--color-error-bg: #26181d;
|
||||
--color-error-bg-active: #744;
|
||||
--color-error-bg-hover: #633;
|
||||
--color-error-text: #f85149;
|
||||
|
||||
--color-success-border: #1d572d;
|
||||
--color-success-bg: #12261e;
|
||||
--color-success-text: #39d353;
|
||||
|
||||
--color-warning-border: #624711;
|
||||
--color-warning-bg: #272115;
|
||||
--color-warning-text: #fbbd08;
|
||||
|
||||
--color-info-border: #214a81;
|
||||
--color-info-bg: #121d2f;
|
||||
--color-info-text: #4493f8;
|
||||
|
||||
--color-red-badge: #db2828;
|
||||
--color-red-badge-bg: #db28281a;
|
||||
--color-red-badge-hover-bg: #db28284d;
|
||||
|
||||
--color-green-badge: #39d353;
|
||||
--color-green-badge-bg: #12261e;
|
||||
--color-green-badge-hover-bg: #153d22;
|
||||
|
||||
--color-yellow-badge: #fbbd08;
|
||||
--color-yellow-badge-bg: #fbbd081a;
|
||||
--color-yellow-badge-hover-bg: #fbbd084d;
|
||||
|
||||
--color-orange-badge: #f2711c;
|
||||
--color-orange-badge-bg: #f2711c1a;
|
||||
--color-orange-badge-hover-bg: #f2711c4d;
|
||||
|
||||
--color-git: #f05133;
|
||||
--color-body: #0d1117;
|
||||
|
||||
--color-box-header: #151b23;
|
||||
--color-box-body: #0d1117;
|
||||
--color-box-body-highlight: #262c36;
|
||||
|
||||
--color-text-dark: #dbe0ea;
|
||||
--color-text: #dce2e7;
|
||||
--color-text-light: #a6aab5;
|
||||
--color-text-light-1: rgb(125, 133, 144);
|
||||
--color-text-light-2: #8a8e99;
|
||||
--color-text-light-3: #707687;
|
||||
|
||||
--color-footer: #010409;
|
||||
--color-timeline: #4c525e;
|
||||
|
||||
--color-input-text: #d5dbe6;
|
||||
--color-input-background: #2c2f35;
|
||||
--color-input-toggle-background: #454a57;
|
||||
--color-input-border: var(--color-light-border);
|
||||
--color-input-border-hover: var(--color-light-border);
|
||||
|
||||
--color-header-wrapper: #0d1117;
|
||||
--color-header-wrapper-transparent: #20243000;
|
||||
|
||||
--color-light: #00000028;
|
||||
--color-light-mimic-enabled: rgba(0, 0, 0, calc(40 / 255 * 222 / 255 / var(--opacity-disabled)));
|
||||
--color-light-border: #3d444d;
|
||||
--color-hover: #656c7633;
|
||||
--color-active: #161a21;
|
||||
--color-menu: #0d1117;
|
||||
--color-card: #0d1117;
|
||||
--color-markup-table-row: #ffffff06;
|
||||
--color-markup-code-block: #ffffff16;
|
||||
--color-button: #212830;
|
||||
--color-code-bg: #0d1117;
|
||||
--color-code-sidebar-bg: #232834;
|
||||
--color-shadow: #00000060;
|
||||
--color-secondary-bg: #ffffff26;
|
||||
--color-text-focus: #fff;
|
||||
--color-expand-button: #3c404d;
|
||||
--color-placeholder-text: #8a8e99;
|
||||
--color-editor-line-highlight: var(--color-primary-light-5);
|
||||
--color-project-board-bg: var(--color-secondary-light-2);
|
||||
--color-caret: var(--color-text);
|
||||
--color-reaction-bg: #ffffff12;
|
||||
--color-reaction-hover-bg: var(--color-primary-light-4);
|
||||
--color-reaction-active-bg: var(--color-primary-light-5);
|
||||
--color-tooltip-text: #fff;
|
||||
--color-tooltip-bg: #000000f0;
|
||||
--color-nav-bg: #010409;
|
||||
--color-nav-hover-bg: var(--color-hover);
|
||||
--color-label-text: #fff;
|
||||
--color-label-bg: #7c84974b;
|
||||
--color-label-hover-bg: #7c8497a0;
|
||||
--color-label-active-bg: #7c8497;
|
||||
--color-accent: var(--color-primary-light-1);
|
||||
--color-small-accent: var(--color-primary-light-5);
|
||||
--color-active-line: #534d1b;
|
||||
accent-color: var(--color-accent);
|
||||
color-scheme: dark;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
/* Made by Luting ^-^ */
|
||||
99
src/types/color/based.ts
Normal file
99
src/types/color/based.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
export const based = {
|
||||
/** 未知 */
|
||||
git: null,
|
||||
/** 主要背景色 */
|
||||
body: null,
|
||||
/** 页面底部状态栏背景色 */
|
||||
footer: null,
|
||||
/** Issue 等页面时间线的线颜色 */
|
||||
timeline: null,
|
||||
/** 一些盒子颜色, 比如仓库文件列表 */
|
||||
box: {
|
||||
header: null,
|
||||
body: {
|
||||
self: null,
|
||||
highlight: null,
|
||||
},
|
||||
},
|
||||
/** 文本 */
|
||||
text: {
|
||||
self: null,
|
||||
light: {
|
||||
self: null,
|
||||
num1: null,
|
||||
num2: null,
|
||||
num3: null,
|
||||
},
|
||||
dark: null,
|
||||
},
|
||||
/** 输入框 */
|
||||
input: {
|
||||
text: null,
|
||||
background: null,
|
||||
toggleBackgound: "color-input-toggle-background",
|
||||
border: {
|
||||
self: null,
|
||||
hover: null,
|
||||
},
|
||||
},
|
||||
light: {
|
||||
self: null,
|
||||
mimicEnabled: "color-light-mimic-enabled",
|
||||
border: null,
|
||||
},
|
||||
hover: {
|
||||
self: null,
|
||||
opaque: null,
|
||||
},
|
||||
active: null,
|
||||
menu: null,
|
||||
card: null,
|
||||
markup: {
|
||||
tableRow: "color-markup-table-row",
|
||||
code: {
|
||||
block: null,
|
||||
inline: null,
|
||||
},
|
||||
},
|
||||
button: null,
|
||||
codeBg: "color-code-bg",
|
||||
shadow: {
|
||||
self: null,
|
||||
opaque: null,
|
||||
},
|
||||
secondaryBg: "color-secondary-bg",
|
||||
expandButton: "color-expand-button",
|
||||
placeholderText: "color-placeholder-text",
|
||||
editorLineHighlight: "color-editor-line-highlight",
|
||||
projectColumnBg: "color-project-column-bg",
|
||||
caret: null,
|
||||
reaction: {
|
||||
bg: null,
|
||||
hoverBg: "color-reaction-hover-bg",
|
||||
activeBg: "color-reaction-active-bg",
|
||||
},
|
||||
tooltip: {
|
||||
text: null,
|
||||
bg: null,
|
||||
},
|
||||
nav: {
|
||||
bg: null,
|
||||
hoverBg: "color-nav-hover-bg",
|
||||
text: null,
|
||||
},
|
||||
secondaryNavBg: "color-secondary-nav-bg",
|
||||
/** 标签 */
|
||||
label: {
|
||||
text: null,
|
||||
bg: null,
|
||||
hoverBg: "color-label-hover-bg",
|
||||
activeBg: "color-label-active-bg",
|
||||
},
|
||||
accent: null,
|
||||
smallAccent: "color-small-accent",
|
||||
highlight: {
|
||||
bg: null,
|
||||
fg: null,
|
||||
},
|
||||
overlayBackdrop: "color-overlay-backdrop",
|
||||
};
|
||||
30
src/types/color/console.ts
Normal file
30
src/types/color/console.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
activeBg: "color-console-active-bg",
|
||||
hoverBg: "color-console-hover-bg",
|
||||
menu: {
|
||||
bg: null,
|
||||
border: null,
|
||||
},
|
||||
};
|
||||
23
src/types/color/diff.ts
Normal file
23
src/types/color/diff.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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/color/index.ts
Normal file
6
src/types/color/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export { based } from "./based";
|
||||
export { ansi, console } from "./console";
|
||||
export { diff } from "./diff";
|
||||
export { primary, secondary } from "./main";
|
||||
export { message } from "./message";
|
||||
export { named } from "./named";
|
||||
54
src/types/color/main.ts
Normal file
54
src/types/color/main.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
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,
|
||||
button: null,
|
||||
hover: null,
|
||||
active: null,
|
||||
};
|
||||
32
src/types/color/message.ts
Normal file
32
src/types/color/message.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
const msg = {
|
||||
bg: null,
|
||||
border: null,
|
||||
text: null,
|
||||
};
|
||||
|
||||
const error = {
|
||||
...msg,
|
||||
bg: {
|
||||
self: null,
|
||||
active: null,
|
||||
hover: null,
|
||||
},
|
||||
};
|
||||
|
||||
const success = {
|
||||
...msg,
|
||||
};
|
||||
|
||||
const warning = {
|
||||
...msg,
|
||||
};
|
||||
const info = {
|
||||
...msg,
|
||||
};
|
||||
|
||||
export const message = {
|
||||
error,
|
||||
success,
|
||||
warning,
|
||||
info,
|
||||
};
|
||||
59
src/types/color/named.ts
Normal file
59
src/types/color/named.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
const baseColor = {
|
||||
self: null,
|
||||
light: null,
|
||||
dark: {
|
||||
num1: null,
|
||||
num2: null,
|
||||
},
|
||||
};
|
||||
|
||||
const commitColor = {
|
||||
/** 提交哈希值颜色 */
|
||||
badge: {
|
||||
/** 边框色 */
|
||||
self: null,
|
||||
/** 背景色 */
|
||||
bg: null,
|
||||
/** 悬停时背景色 */
|
||||
hover: {
|
||||
bg: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const named = {
|
||||
/** 红色/提交警告签名颜色 */
|
||||
red: {
|
||||
...commitColor,
|
||||
...baseColor,
|
||||
},
|
||||
/** 橙色/提交未匹配签名颜色 */
|
||||
orange: {
|
||||
...commitColor,
|
||||
...baseColor,
|
||||
},
|
||||
/** 黄色/提交未信任签名颜色 */
|
||||
yellow: {
|
||||
...commitColor,
|
||||
...baseColor,
|
||||
},
|
||||
olive: baseColor,
|
||||
/** 绿色/提交信任签名颜色 */
|
||||
green: {
|
||||
...commitColor,
|
||||
...baseColor,
|
||||
},
|
||||
teal: baseColor,
|
||||
blue: baseColor,
|
||||
violet: baseColor,
|
||||
purple: baseColor,
|
||||
pink: baseColor,
|
||||
brown: baseColor,
|
||||
black: baseColor,
|
||||
grey: {
|
||||
self: null,
|
||||
light: null,
|
||||
},
|
||||
gold: null,
|
||||
white: null,
|
||||
};
|
||||
11
src/types/index.ts
Normal file
11
src/types/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
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 Named = MapLeafNodes<typeof color.named, string>;
|
||||
export type Message = MapLeafNodes<typeof color.message, string>;
|
||||
export type Ansi = MapLeafNodes<typeof color.ansi, string>;
|
||||
export type Console = MapLeafNodes<typeof color.console, string>;
|
||||
export type Diff = MapLeafNodes<typeof color.diff, string>;
|
||||
export type Based = MapLeafNodes<typeof color.based, string>;
|
||||
35
src/types/vars.ts
Normal file
35
src/types/vars.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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: {
|
||||
...color.message,
|
||||
...color.based,
|
||||
...color.named,
|
||||
primary: color.primary,
|
||||
secondary: color.secondary,
|
||||
ansi: color.ansi,
|
||||
console: color.console,
|
||||
diff: color.diff,
|
||||
},
|
||||
};
|
||||
|
||||
const otherVars = {
|
||||
border: {
|
||||
radius: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const themeVars = createGlobalThemeContract(vars, varMapper);
|
||||
export const otherThemeVars = createGlobalThemeContract(otherVars, varMapper);
|
||||
@@ -4,4 +4,4 @@
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,33 +18,33 @@
|
||||
|
||||
.vch__day__square,
|
||||
.vch__legend__wrapper rect {
|
||||
&[style='fill: var(--color-secondary-alpha-60);'] {
|
||||
&[style="fill: var(--color-secondary-alpha-60);"] {
|
||||
outline: 1px solid rgba(27, 31, 35, 0.06);
|
||||
background: #161b22;
|
||||
fill: #161b22 !important;
|
||||
}
|
||||
|
||||
&[style='fill: var(--color-primary-light-4);'] {
|
||||
&[style="fill: var(--color-primary-light-4);"] {
|
||||
background: #0e4429;
|
||||
fill: #0e4429 !important;
|
||||
}
|
||||
|
||||
&[style='fill: var(--color-primary-light-2);'] {
|
||||
&[style="fill: var(--color-primary-light-2);"] {
|
||||
background: #006d32;
|
||||
fill: #006d32 !important;
|
||||
}
|
||||
|
||||
&[style='fill: var(--color-primary);'] {
|
||||
&[style="fill: var(--color-primary);"] {
|
||||
background: #238636;
|
||||
fill: #238636 !important;
|
||||
}
|
||||
|
||||
&[style='fill: var(--color-primary-dark-2);'] {
|
||||
&[style="fill: var(--color-primary-dark-2);"] {
|
||||
background: #39d353;
|
||||
fill: #39d353 !important;
|
||||
}
|
||||
|
||||
&[style='fill: var(--color-primary-dark-4);'] {
|
||||
&[style="fill: var(--color-primary-dark-4);"] {
|
||||
background: #44ff61;
|
||||
fill: #44ff61 !important;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
%active-item-after-style {
|
||||
background: #1f6feb;
|
||||
border-radius: 0.375rem;
|
||||
content: '';
|
||||
content: "";
|
||||
height: 24px;
|
||||
left: calc(0.5rem * -1);
|
||||
position: absolute;
|
||||
@@ -134,17 +134,17 @@
|
||||
.ui.form input:not([type]),
|
||||
.ui.form select,
|
||||
.ui.form textarea,
|
||||
.ui.form input[type='date'],
|
||||
.ui.form input[type='datetime-local'],
|
||||
.ui.form input[type='email'],
|
||||
.ui.form input[type='file'],
|
||||
.ui.form input[type='number'],
|
||||
.ui.form input[type='password'],
|
||||
.ui.form input[type='search'],
|
||||
.ui.form input[type='tel'],
|
||||
.ui.form input[type='text'],
|
||||
.ui.form input[type='time'],
|
||||
.ui.form input[type='url'],
|
||||
.ui.form input[type="date"],
|
||||
.ui.form input[type="datetime-local"],
|
||||
.ui.form input[type="email"],
|
||||
.ui.form input[type="file"],
|
||||
.ui.form input[type="number"],
|
||||
.ui.form input[type="password"],
|
||||
.ui.form input[type="search"],
|
||||
.ui.form input[type="tel"],
|
||||
.ui.form input[type="text"],
|
||||
.ui.form input[type="time"],
|
||||
.ui.form input[type="url"],
|
||||
.ui.selection.dropdown {
|
||||
background: var(--color-box-header);
|
||||
}
|
||||
@@ -152,17 +152,17 @@
|
||||
.ui.form input:not([type]),
|
||||
.ui.form select,
|
||||
.ui.form textarea,
|
||||
.ui.form input[type='date'],
|
||||
.ui.form input[type='datetime-local'],
|
||||
.ui.form input[type='email'],
|
||||
.ui.form input[type='file'],
|
||||
.ui.form input[type='number'],
|
||||
.ui.form input[type='password'],
|
||||
.ui.form input[type='search'],
|
||||
.ui.form input[type='tel'],
|
||||
.ui.form input[type='text'],
|
||||
.ui.form input[type='time'],
|
||||
.ui.form input[type='url'] {
|
||||
.ui.form input[type="date"],
|
||||
.ui.form input[type="datetime-local"],
|
||||
.ui.form input[type="email"],
|
||||
.ui.form input[type="file"],
|
||||
.ui.form input[type="number"],
|
||||
.ui.form input[type="password"],
|
||||
.ui.form input[type="search"],
|
||||
.ui.form input[type="tel"],
|
||||
.ui.form input[type="text"],
|
||||
.ui.form input[type="time"],
|
||||
.ui.form input[type="url"] {
|
||||
padding: 7px 12px;
|
||||
}
|
||||
|
||||
0
styles/index.tsx
Normal file
0
styles/index.tsx
Normal file
@@ -22,7 +22,10 @@
|
||||
background: var(--color-box-header);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0px 0px 0px 0.5px #30363d, 0px 6px 12px -3px rgba(1, 4, 9, 0.4), 0px 6px 18px 0px rgba(1, 4, 9, 0.4);
|
||||
box-shadow:
|
||||
0px 0px 0px 0.5px #30363d,
|
||||
0px 6px 12px -3px rgba(1, 4, 9, 0.4),
|
||||
0px 6px 18px 0px rgba(1, 4, 9, 0.4);
|
||||
animation: 200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running overlay-appear;
|
||||
|
||||
.clone-panel-field {
|
||||
@@ -50,7 +53,7 @@
|
||||
}
|
||||
|
||||
&.active:after {
|
||||
content: '';
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
bottom: -8px;
|
||||
@@ -96,10 +99,13 @@
|
||||
margin-top: 3.75px !important;
|
||||
border-radius: 12px !important;
|
||||
overflow: hidden auto;
|
||||
box-shadow: 0px 0px 0px 0.5px #30363d, 0px 6px 12px -3px #01040966, 0px 6px 18px 0px #01040966;
|
||||
box-shadow:
|
||||
0px 0px 0px 0.5px #30363d,
|
||||
0px 6px 12px -3px #01040966,
|
||||
0px 6px 18px 0px #01040966;
|
||||
animation: 200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running overlay-appear;
|
||||
|
||||
>.item {
|
||||
> .item {
|
||||
padding: 8px 10px !important;
|
||||
}
|
||||
}
|
||||
@@ -181,7 +187,7 @@
|
||||
|
||||
// 分支菜单下划线
|
||||
&:before {
|
||||
content: ' ';
|
||||
content: " ";
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
23
styles/public/emoji.scss
Normal file
23
styles/public/emoji.scss
Normal file
@@ -0,0 +1,23 @@
|
||||
// Made by Luting ^-^
|
||||
.emoji[aria-label="check\\ mark"],
|
||||
.emoji[aria-label="currency\\ exchange"],
|
||||
.emoji[aria-label="TOP\\ arrow"],
|
||||
.emoji[aria-label="END\\ arrow"],
|
||||
.emoji[aria-label="ON! arrow"],
|
||||
.emoji[aria-label="SOON\\ arrow"],
|
||||
.emoji[aria-label="heavy dollar sign"],
|
||||
.emoji[aria-label="copyright"],
|
||||
.emoji[aria-label="registered"],
|
||||
.emoji[aria-label="trade\\ mark"],
|
||||
.emoji[aria-label="multiply"],
|
||||
.emoji[aria-label="plus"],
|
||||
.emoji[aria-label="minus"],
|
||||
.emoji[aria-label="divide"],
|
||||
.emoji[aria-label="curly\\ loop"],
|
||||
.emoji[aria-label="double curly loop"],
|
||||
.emoji[aria-label="wavy\\ dash"],
|
||||
.emoji[aria-label="paw\\ prints"],
|
||||
.emoji[aria-label="musical\\ note"],
|
||||
.emoji[aria-label="musical\\ notes"] {
|
||||
filter: invert(100%) hue-rotate(180deg);
|
||||
}
|
||||
@@ -5,17 +5,17 @@ textarea,
|
||||
.ui.form input:not([type]),
|
||||
.ui.form select,
|
||||
.ui.form textarea,
|
||||
.ui.form input[type='date'],
|
||||
.ui.form input[type='datetime-local'],
|
||||
.ui.form input[type='email'],
|
||||
.ui.form input[type='file'],
|
||||
.ui.form input[type='number'],
|
||||
.ui.form input[type='password'],
|
||||
.ui.form input[type='search'],
|
||||
.ui.form input[type='tel'],
|
||||
.ui.form input[type='text'],
|
||||
.ui.form input[type='time'],
|
||||
.ui.form input[type='url'],
|
||||
.ui.form input[type="date"],
|
||||
.ui.form input[type="datetime-local"],
|
||||
.ui.form input[type="email"],
|
||||
.ui.form input[type="file"],
|
||||
.ui.form input[type="number"],
|
||||
.ui.form input[type="password"],
|
||||
.ui.form input[type="search"],
|
||||
.ui.form input[type="tel"],
|
||||
.ui.form input[type="text"],
|
||||
.ui.form input[type="time"],
|
||||
.ui.form input[type="url"],
|
||||
.ui.selection.dropdown {
|
||||
background: unset;
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
.ui.form input:not([type]),
|
||||
.ui.form select,
|
||||
.ui.form textarea,
|
||||
.ui.form input[type='date'],
|
||||
.ui.form input[type='datetime-local'],
|
||||
.ui.form input[type='email'],
|
||||
.ui.form input[type='file'],
|
||||
.ui.form input[type='number'],
|
||||
.ui.form input[type='password'],
|
||||
.ui.form input[type='search'],
|
||||
.ui.form input[type='tel'],
|
||||
.ui.form input[type='text'],
|
||||
.ui.form input[type='time'],
|
||||
.ui.form input[type='url'],
|
||||
.ui.form input[type="date"],
|
||||
.ui.form input[type="datetime-local"],
|
||||
.ui.form input[type="email"],
|
||||
.ui.form input[type="file"],
|
||||
.ui.form input[type="number"],
|
||||
.ui.form input[type="password"],
|
||||
.ui.form input[type="search"],
|
||||
.ui.form input[type="tel"],
|
||||
.ui.form input[type="text"],
|
||||
.ui.form input[type="time"],
|
||||
.ui.form input[type="url"],
|
||||
.ui.selection.dropdown {
|
||||
&:focus,
|
||||
&:focus-visible {
|
||||
@@ -1,21 +1,20 @@
|
||||
// Made by Luting ^-^
|
||||
.ui {
|
||||
&.button,
|
||||
&.basic.buttons .button,
|
||||
&.basic.button,
|
||||
&.dropdown .menu,
|
||||
&.form input:not([type]),
|
||||
&.form input[type='date'],
|
||||
&.form input[type='datetime-local'],
|
||||
&.form input[type='email'],
|
||||
&.form input[type='number'],
|
||||
&.form input[type='password'],
|
||||
&.form input[type='search'],
|
||||
&.form input[type='tel'],
|
||||
&.form input[type='time'],
|
||||
&.form input[type='text'],
|
||||
&.form input[type='file'],
|
||||
&.form input[type='url'],
|
||||
&.form input[type="date"],
|
||||
&.form input[type="datetime-local"],
|
||||
&.form input[type="email"],
|
||||
&.form input[type="number"],
|
||||
&.form input[type="password"],
|
||||
&.form input[type="search"],
|
||||
&.form input[type="tel"],
|
||||
&.form input[type="time"],
|
||||
&.form input[type="text"],
|
||||
&.form input[type="file"],
|
||||
&.form input[type="url"],
|
||||
&.form textarea,
|
||||
&.input textarea,
|
||||
&.ui.input > input,
|
||||
@@ -42,7 +41,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 左边框圆角
|
||||
/* 左边框圆角 */
|
||||
.ui {
|
||||
&.action.input > .dropdown:first-child,
|
||||
&.action.input > .button:first-child,
|
||||
@@ -53,7 +52,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 右边框圆角
|
||||
/* 右边框圆角 */
|
||||
.ui {
|
||||
&.action.input > .dropdown:last-child,
|
||||
&.action.input > .button:last-child,
|
||||
@@ -64,7 +63,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 上边框圆角
|
||||
/* 上边框圆角 */
|
||||
.ui.secondary.pointing.menu {
|
||||
.active.item,
|
||||
.item:hover {
|
||||
@@ -78,13 +77,13 @@
|
||||
border-top-right-radius: var(--border-radius) !important;
|
||||
}
|
||||
|
||||
// 按钮边框圆角
|
||||
/* 按钮边框圆角 */
|
||||
.ui.active.selection.dropdown {
|
||||
border-bottom-left-radius: var(--border-radius) !important;
|
||||
border-bottom-right-radius: var(--border-radius) !important;
|
||||
}
|
||||
|
||||
.ui.segment[class*='bottom attached'] {
|
||||
.ui.segment[class*="bottom attached"] {
|
||||
border-radius: 0 0 var(--border-radius) var(--border-radius);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Made by Luting ^-^
|
||||
.text {
|
||||
.purple {
|
||||
color: #ab7df8 !important;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: #3fb950 !important;
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
.ui.selection.dropdown,
|
||||
.ui.checkbox label:before,
|
||||
.ui.checkbox input:checked ~ label:before,
|
||||
.ui.checkbox input:not([type='radio']):indeterminate ~ label:before,
|
||||
.ui.checkbox input:not([type="radio"]):indeterminate ~ label:before,
|
||||
.ui.selection.active.dropdown,
|
||||
.ui.selection.active.dropdown:hover,
|
||||
.ui.selection.active.dropdown .menu,
|
||||
@@ -42,4 +42,4 @@ textarea,
|
||||
.job-step-logs,
|
||||
.job-brief-item {
|
||||
animation: 200ms cubic-bezier(0.33, 1, 0.68, 1) 0s 1 normal none running overlay-appear;
|
||||
}
|
||||
}
|
||||
168
themes/dark.css.tsx
Normal file
168
themes/dark.css.tsx
Normal file
@@ -0,0 +1,168 @@
|
||||
import type { Based, Console, Diff } from "src";
|
||||
import { defineTheme, themeVars } from "src";
|
||||
|
||||
const console: Console = {
|
||||
fg: {
|
||||
self: "#f0f6fc",
|
||||
subtle: "#9198a1",
|
||||
},
|
||||
bg: "#010409",
|
||||
border: "#2b3139",
|
||||
activeBg: "#2a313c",
|
||||
hoverBg: "#15191f",
|
||||
menu: {
|
||||
bg: themeVars.color.body,
|
||||
border: themeVars.color.light.border,
|
||||
},
|
||||
};
|
||||
|
||||
const diff: Diff = {
|
||||
added: {
|
||||
linenum: {
|
||||
bg: "#1c4428",
|
||||
},
|
||||
row: {
|
||||
bg: "#12261e",
|
||||
border: "#314a37",
|
||||
},
|
||||
word: {
|
||||
bg: "#1d572d",
|
||||
},
|
||||
},
|
||||
removed: {
|
||||
linenum: {
|
||||
bg: "#542426",
|
||||
},
|
||||
row: {
|
||||
bg: "#25171c",
|
||||
border: "#634343",
|
||||
},
|
||||
word: {
|
||||
bg: "#792e2d",
|
||||
},
|
||||
},
|
||||
moved: {
|
||||
row: {
|
||||
bg: "#818044",
|
||||
border: "#bcca6f",
|
||||
},
|
||||
},
|
||||
inactive: "#353846",
|
||||
};
|
||||
|
||||
const based: Based = {
|
||||
git: "#f05133",
|
||||
body: "#0d1117",
|
||||
box: {
|
||||
header: "#151b23",
|
||||
body: {
|
||||
self: "#0d1117",
|
||||
highlight: "#262c36",
|
||||
},
|
||||
},
|
||||
text: {
|
||||
self: "#dce2e7",
|
||||
dark: "#dbe0ea",
|
||||
light: {
|
||||
self: "#a6aab5",
|
||||
num1: "rgb(125, 133, 144)",
|
||||
num2: "#8a8e99",
|
||||
num3: "#707687",
|
||||
},
|
||||
},
|
||||
footer: "#010409",
|
||||
timeline: "#4c525e",
|
||||
input: {
|
||||
text: "#d5dbe6",
|
||||
background: "#2c2f35",
|
||||
toggleBackgound: "#454a57",
|
||||
border: {
|
||||
self: themeVars.color.light.border,
|
||||
hover: themeVars.color.light.border,
|
||||
},
|
||||
},
|
||||
light: {
|
||||
self: "#00000028",
|
||||
mimicEnabled: "rgba(0, 0, 0, calc(40 / 255 * 222 / 255 / var(--opacity-disabled)))",
|
||||
border: "#3d444d",
|
||||
},
|
||||
hover: {
|
||||
self: "#656c7633",
|
||||
opaque: "#656c7666",
|
||||
},
|
||||
active: "#161a21",
|
||||
menu: "#0d1117",
|
||||
card: "#0d1117",
|
||||
markup: {
|
||||
tableRow: "#ffffff06",
|
||||
code: {
|
||||
block: "#ffffff16",
|
||||
inline: "#ffffff26",
|
||||
},
|
||||
},
|
||||
button: "#212830",
|
||||
codeBg: "#0d1117",
|
||||
shadow: {
|
||||
self: "#00000060",
|
||||
opaque: "#00000080",
|
||||
},
|
||||
secondaryBg: "#ffffff26",
|
||||
expandButton: "#3c404d",
|
||||
placeholderText: "#8a8e99",
|
||||
editorLineHighlight: themeVars.color.primary.light.num5,
|
||||
projectColumnBg: themeVars.color.secondary.light.num2,
|
||||
caret: themeVars.color.text.self,
|
||||
reaction: {
|
||||
bg: "#ffffff12",
|
||||
hoverBg: themeVars.color.primary.light.num4,
|
||||
activeBg: themeVars.color.primary.light.num5,
|
||||
},
|
||||
tooltip: {
|
||||
text: "#fff",
|
||||
bg: "#000000f0",
|
||||
},
|
||||
nav: {
|
||||
bg: "#010409",
|
||||
hoverBg: themeVars.color.hover.self,
|
||||
text: themeVars.color.text.self,
|
||||
},
|
||||
secondaryNavBg: "#181c20",
|
||||
label: {
|
||||
text: "#fff",
|
||||
bg: "#7c84974b",
|
||||
hoverBg: "#7c8497a0",
|
||||
activeBg: "#7c8497",
|
||||
},
|
||||
accent: themeVars.color.primary.light.num1,
|
||||
smallAccent: themeVars.color.primary.light.num5,
|
||||
highlight: {
|
||||
bg: "#87651e",
|
||||
fg: "#352c1c",
|
||||
},
|
||||
overlayBackdrop: "#080808c0",
|
||||
};
|
||||
|
||||
export default defineTheme({
|
||||
isDarkTheme: true,
|
||||
primary: "#4493f8",
|
||||
primaryContrast: "#fff",
|
||||
secondary: "#3d444d",
|
||||
red: "#da3737",
|
||||
orange: "#f17a2b",
|
||||
yellow: "#f3c640",
|
||||
olive: "#c8df36",
|
||||
green: "#39d353",
|
||||
teal: "#69d4cf",
|
||||
blue: "#4493f8",
|
||||
violet: "#754ad3",
|
||||
purple: "#8957e5",
|
||||
pink: "#e04b9f",
|
||||
brown: "#a86d45",
|
||||
black: "#141516",
|
||||
grey: "#505665",
|
||||
gold: "#b1983b",
|
||||
white: "#ffffff",
|
||||
console,
|
||||
diff,
|
||||
based,
|
||||
});
|
||||
38
tsconfig.json
Normal file
38
tsconfig.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"plugins": [
|
||||
{
|
||||
"name": "typescript-plugin-css-modules"
|
||||
}
|
||||
],
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"useDefineForClassFields": true,
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"src/*": ["src/*"],
|
||||
"styles/*": ["styles/*"],
|
||||
"themes/*": ["themes/*", "themes/*.css"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "styles", "themes", "vite.config.ts"]
|
||||
}
|
||||
64
vite.config.ts
Normal file
64
vite.config.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import linaria from "@wyw-in-js/vite";
|
||||
import * as dotenv from "dotenv";
|
||||
import { Features } from "lightningcss";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import * as sass from "sass-embedded";
|
||||
import { defineConfig } from "vite";
|
||||
import { themeInput, themePlugin } from "./src/core/vite";
|
||||
|
||||
dotenv.config({quiet: true});
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const devTheme = process.env.DEV_THEME || "dark"; // 开发模式仅打包单个颜色主题
|
||||
const outDir = "dist"; // 输出目录
|
||||
const themesDir = "themes"; // 颜色主题目录
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
return {
|
||||
resolve: {
|
||||
alias: {
|
||||
src: path.resolve(__dirname, "src"),
|
||||
styles: path.resolve(__dirname, "styles"),
|
||||
themes: path.resolve(__dirname, "themes"),
|
||||
},
|
||||
extensions: [".js", ".jsx", ".ts", ".tsx", ".css.tsx"],
|
||||
},
|
||||
css: {
|
||||
transformer: "lightningcss",
|
||||
lightningcss: {
|
||||
minify: true,
|
||||
exclude: Features.LightDark, // 不生成 lightningcss 的主题变量
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
linaria({
|
||||
include: ["**/*.{ts,tsx}"],
|
||||
babelOptions: {
|
||||
presets: ["@babel/preset-typescript", "@babel/preset-react"],
|
||||
},
|
||||
preprocessor: (_selector, cssText) => sass.compileString(cssText).css, // 默认为全局样式并使用 sass-embedded 预处理 css
|
||||
tagResolver: (source, tag) =>
|
||||
// 识别从 src 导出的 css 标签,使用 @linaria/core/processors/css 处理
|
||||
source === "src" && tag === "css" ? require.resolve("@linaria/core/processors/css") : null,
|
||||
}),
|
||||
react(),
|
||||
vanillaExtractPlugin(),
|
||||
themePlugin(),
|
||||
],
|
||||
build: {
|
||||
cssMinify: "lightningcss",
|
||||
cssCodeSplit: true,
|
||||
outDir: outDir,
|
||||
rollupOptions: {
|
||||
input: themeInput(outDir, themesDir, devTheme, mode),
|
||||
output: {
|
||||
assetFileNames: "[name].[ext]",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user