diff --git a/.github/workflows/pr-spelling.template.yml b/.github/workflows/pr-spelling.template.yml new file mode 100644 index 0000000..93e138e --- /dev/null +++ b/.github/workflows/pr-spelling.template.yml @@ -0,0 +1,12 @@ +# force copy from tencent/tdesign +name: pr-spell-check +on: [pull_request] + +jobs: + run: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check spelling + uses: crate-ci/typos@master diff --git a/package.json b/package.json index 6dca4bd..7d92301 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "axios": "^0.26.0", "dayjs": "^1.10.6", "echarts": "~5.1.2", - "hex-to-hsl": "^1.0.2", "nprogress": "^0.2.0", "pinia": "^2.0.11", "qrcode.vue": "^3.2.2", @@ -29,7 +28,6 @@ "tdesign-vue-next": "~0.11.2", "tvision-color": "^1.3.1", "vue": "^3.2.31", - "vue-color-kit": "^1.0.5", "vue-router": "^4.0.11", "vue-clipboard3": "^1.0.0" }, diff --git a/src/config/color.ts b/src/config/color.ts index a3ae8b2..b7f05ac 100644 --- a/src/config/color.ts +++ b/src/config/color.ts @@ -1,5 +1,6 @@ -import hexToHsl from 'hex-to-hsl'; /* eslint-disable indent */ +import { Color } from 'tvision-color'; + export type TColorToken = Record; export type TColorSeries = Record; @@ -24,59 +25,6 @@ export const defaultDarkColor = [ '#ab87d5', ]; -export const BACKGROUND_TOKEN: TColorSeries = { - BLUE_GREY: { - '@gray-color-1': '#F1F2F5', - '@gray-color-2': '#EBEDF1', - '@gray-color-3': '#E3E6EB', - '@gray-color-4': '#D6DBE3', - '@gray-color-5': '#BCC4D0', - '@gray-color-6': '#97A3B7', - '@gray-color-7': '#7787A2', - '@gray-color-8': '#5F7292', - '@gray-color-9': '#4B5B76', - '@gray-color-10': '#3C485C', - '@gray-color-11': '#2C3645', - '@gray-color-12': '#232A35', - '@gray-color-13': '#1C222B', - '@gray-color-14': '#13161B', - }, - NEUTRAL_GREY: { - '@gray-color-1': '#F3F3F3', - '@gray-color-2': '#EEEEEE', - '@gray-color-3': '#E7E7E7', - '@gray-color-4': '#DCDCDC', - '@gray-color-5': '#C5C5C5', - '@gray-color-6': '#A6A6A6', - '@gray-color-7': '#8B8B8B', - '@gray-color-8': '#777777', - '@gray-color-9': '#5E5E5E', - '@gray-color-10': '#4B4B4B', - '@gray-color-11': '#383838', - '@gray-color-12': '#2C2C2C', - '@gray-color-13': '#242424', - '@gray-color-14': '#181818', - }, -}; - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export const NEUTRAL_GREY_TOKEN: TColorToken = { - '@gray-color-1': '#F3F3F3', - '@gray-color-2': '#EEEEEE', - '@gray-color-3': '#E7E7E7', - '@gray-color-4': '#DCDCDC', - '@gray-color-5': '#C5C5C5', - '@gray-color-6': '#A6A6A6', - '@gray-color-7': '#8B8B8B', - '@gray-color-8': '#777777', - '@gray-color-9': '#5E5E5E', - '@gray-color-10': '#4B4B4B', - '@gray-color-11': '#383838', - '@gray-color-12': '#2C2C2C', - '@gray-color-13': '#242424', - '@gray-color-14': '#181818', -}; - export const COLOR_TOKEN: TColorSeries = { DEFAULT: { '@brand-color': '#0052D9', @@ -205,11 +153,6 @@ function toUnderline(name: string): string { return name.replace(/([A-Z])/g, '_$1').toUpperCase(); } -export function getGreyColor(type: string): TColorToken { - const name = toUnderline(type); - return BACKGROUND_TOKEN[name] || {}; -} - export function getBrandColor(type: string, colorList: TColorSeries): TColorToken { const name = /^#[A-F\d]{6}$/i.test(type) ? type : toUnderline(type); return colorList[name || 'DEFAULT']; @@ -221,19 +164,6 @@ export function getColorList(colorArray: Array): Array { return pureColorList; } -// inspired by https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex -export function hslToHex(h: number, s: number, l: number) { - l /= 100; - const a = (s * Math.min(l, 1 - l)) / 100; - const f = (n: number) => { - const k = (n + h / 30) % 12; - const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1); - return Math.round(255 * color) - .toString(16) - .padStart(2, '0'); - }; - return `#${f(0)}${f(8)}${f(4)}`; -} export function generateColorMap(theme: string, colorPalette: Array, mode: 'light' | 'dark') { const isDarkMode = mode === 'dark'; @@ -242,8 +172,8 @@ export function generateColorMap(theme: string, colorPalette: Array, mod if (isDarkMode) { // eslint-disable-next-line no-use-before-define colorPalette.reverse().map((color) => { - const [h, s, l] = hexToHsl(color); - return hslToHex(h, s - 4, l); + const [h, s, l] = Color.colorTransform(color, 'hex', 'hsl'); + return Color.colorTransform([h, Number(s) - 4, l], 'hsl', 'hex'); }); brandColorIdx = 5; colorPalette[0] = `${colorPalette[brandColorIdx]}20`; diff --git a/src/layouts/setting.vue b/src/layouts/setting.vue index b6546bf..7ac0088 100644 --- a/src/layouts/setting.vue +++ b/src/layouts/setting.vue @@ -22,7 +22,7 @@
主题色
- +