@pubinfo/config 2.0.0-beta.25 → 2.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/themes/index.d.mts +2 -4
- package/dist/themes/index.d.ts +2 -4
- package/dist/themes/index.mjs +17 -33
- package/dist/unocss/index.d.mts +4 -1
- package/dist/unocss/index.d.ts +4 -1
- package/dist/unocss/index.mjs +11 -6
- package/package.json +3 -2
- package/src/eslint/config/ignores.ts +10 -0
- package/src/eslint/config/stylistic.ts +21 -0
- package/src/eslint/config/vue.ts +54 -0
- package/src/eslint/factory.ts +20 -0
- package/src/eslint/globs.ts +86 -0
- package/src/eslint/index.ts +3 -0
- package/src/index.ts +4 -0
- package/src/stylelint.ts +135 -0
- package/src/themes/index.ts +3 -0
- package/src/themes/system/dark/dark.ts +47 -0
- package/src/themes/system/dark/dracula.ts +47 -0
- package/src/themes/system/dark/luxury.ts +47 -0
- package/src/themes/system/dark/night.ts +47 -0
- package/src/themes/system/dark/stone.ts +47 -0
- package/src/themes/system/dark/synthwave.ts +47 -0
- package/src/themes/system/light/barbie.ts +47 -0
- package/src/themes/system/light/classic.ts +47 -0
- package/src/themes/system/light/cyberpunk.ts +47 -0
- package/src/themes/system/light/light.ts +47 -0
- package/src/themes/system/light/naive.ts +47 -0
- package/src/themes/system/light/winter.ts +47 -0
- package/src/themes/theme.ts +18 -0
- package/src/themes/unocss-utils.ts +52 -0
- package/src/themes/utils.ts +81 -0
- package/src/unocss/index.ts +61 -0
- package/src/unocss/presetThemes.ts +57 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { hex2rgba } from './unocss-utils';
|
|
2
|
+
|
|
3
|
+
type CSSColorValue = string;
|
|
4
|
+
type manColor =
|
|
5
|
+
| 'bg'
|
|
6
|
+
| 'container-bg'
|
|
7
|
+
| 'border-color';
|
|
8
|
+
|
|
9
|
+
type headerColor =
|
|
10
|
+
| 'header-bg'
|
|
11
|
+
| 'header-color'
|
|
12
|
+
| 'header-menu-color'
|
|
13
|
+
| 'header-menu-hover-bg'
|
|
14
|
+
| 'header-menu-hover-color'
|
|
15
|
+
| 'header-menu-active-bg'
|
|
16
|
+
| 'header-menu-active-color';
|
|
17
|
+
|
|
18
|
+
type mainSidebarColor =
|
|
19
|
+
| 'main-sidebar-bg'
|
|
20
|
+
| 'main-sidebar-menu-color'
|
|
21
|
+
| 'main-sidebar-menu-hover-bg'
|
|
22
|
+
| 'main-sidebar-menu-hover-color'
|
|
23
|
+
| 'main-sidebar-menu-active-bg'
|
|
24
|
+
| 'main-sidebar-menu-active-color';
|
|
25
|
+
|
|
26
|
+
type subSidebarColor =
|
|
27
|
+
| 'sub-sidebar-bg'
|
|
28
|
+
| 'sub-sidebar-logo-bg'
|
|
29
|
+
| 'sub-sidebar-logo-color'
|
|
30
|
+
| 'sub-sidebar-menu-color'
|
|
31
|
+
| 'sub-sidebar-menu-hover-bg'
|
|
32
|
+
| 'sub-sidebar-menu-hover-color'
|
|
33
|
+
| 'sub-sidebar-menu-active-bg'
|
|
34
|
+
| 'sub-sidebar-menu-active-color';
|
|
35
|
+
|
|
36
|
+
type tabbarColor =
|
|
37
|
+
| 'tabbar-dividers-bg'
|
|
38
|
+
| 'tabbar-tab-color'
|
|
39
|
+
| 'tabbar-tab-hover-bg'
|
|
40
|
+
| 'tabbar-tab-hover-color'
|
|
41
|
+
| 'tabbar-tab-active-color';
|
|
42
|
+
|
|
43
|
+
type themeScheme = 'light' | 'dark';
|
|
44
|
+
type customColor = typeof customColorKey[number];
|
|
45
|
+
type benchmark = `--g-${manColor | headerColor | mainSidebarColor | subSidebarColor | tabbarColor}`;
|
|
46
|
+
export type cssVarKey = customColor | benchmark;
|
|
47
|
+
|
|
48
|
+
export type colorScheme = Record<cssVarKey, CSSColorValue> & { 'color-scheme': themeScheme } & { label?: string };
|
|
49
|
+
|
|
50
|
+
export interface themeOptions {
|
|
51
|
+
name: string
|
|
52
|
+
colors: colorScheme
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const customColorKey = ['--ui-primary', '--ui-text'] as const;
|
|
56
|
+
|
|
57
|
+
export interface globalTheme {
|
|
58
|
+
[key: string]: colorScheme
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let themeColorMap: globalTheme = {};
|
|
62
|
+
|
|
63
|
+
export function getThemes() {
|
|
64
|
+
return themeColorMap;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function normalizeColor(colors: colorScheme) {
|
|
68
|
+
for (const key of customColorKey) {
|
|
69
|
+
const colorValue = colors[key];
|
|
70
|
+
colors[key] = hex2rgba(colorValue)!.join(' ');
|
|
71
|
+
}
|
|
72
|
+
return colors;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function defineTheme(theme: themeOptions): globalTheme {
|
|
76
|
+
const { name, colors } = theme;
|
|
77
|
+
const colorScheme: globalTheme = Object.create(null);
|
|
78
|
+
colorScheme[name] = normalizeColor(colors);
|
|
79
|
+
themeColorMap = Object.assign(themeColorMap, colorScheme);
|
|
80
|
+
return colorScheme;
|
|
81
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { globalTheme } from '../themes';
|
|
2
|
+
import {
|
|
3
|
+
definePreset,
|
|
4
|
+
presetAttributify,
|
|
5
|
+
presetIcons,
|
|
6
|
+
presetTypography,
|
|
7
|
+
presetUno,
|
|
8
|
+
transformerDirectives,
|
|
9
|
+
} from 'unocss';
|
|
10
|
+
import { presetThemes } from './presetThemes';
|
|
11
|
+
|
|
12
|
+
export default definePreset<{ themes?: globalTheme[] }>((options) => {
|
|
13
|
+
return {
|
|
14
|
+
name: 'preset-pubinfo',
|
|
15
|
+
presets: [
|
|
16
|
+
presetThemes({ themes: options?.themes }),
|
|
17
|
+
presetUno(),
|
|
18
|
+
presetAttributify(),
|
|
19
|
+
presetTypography(),
|
|
20
|
+
presetIcons({
|
|
21
|
+
extraProperties: {
|
|
22
|
+
'display': 'inline-block',
|
|
23
|
+
'vertical-align': 'middle',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
transformers: [
|
|
28
|
+
transformerDirectives(),
|
|
29
|
+
],
|
|
30
|
+
shortcuts: [
|
|
31
|
+
{
|
|
32
|
+
'flex-center': 'flex justify-center items-center',
|
|
33
|
+
'flex-col-center': 'flex flex-col justify-center items-center',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
theme: {
|
|
37
|
+
colors: {
|
|
38
|
+
'ui-primary': 'rgb(var(--ui-primary))',
|
|
39
|
+
'ui-text': 'rgb(var(--ui-text))',
|
|
40
|
+
},
|
|
41
|
+
breakpoints: {
|
|
42
|
+
'sm': '768px',
|
|
43
|
+
'smd': '1024px',
|
|
44
|
+
'md': '1366px',
|
|
45
|
+
'lg': '1440px',
|
|
46
|
+
'xl': '1600px',
|
|
47
|
+
'2xl': '1920px',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// TOFIX 此文件中该配置不生效
|
|
52
|
+
content: {
|
|
53
|
+
pipeline: {
|
|
54
|
+
include: [
|
|
55
|
+
/\.(vue|svelte|[jt]sx|mdx?|astro|elm|php|phtml|html)($|\?)/,
|
|
56
|
+
'src/routes/**/*.ts',
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { globalTheme } from '../themes';
|
|
2
|
+
import { definePreset, entriesToCss, toArray } from '@unocss/core';
|
|
3
|
+
import { getThemes } from '../themes';
|
|
4
|
+
|
|
5
|
+
type colorScheme = 'light' | 'dark';
|
|
6
|
+
|
|
7
|
+
const suffix = [['', ' *', '::before', '::after'], ['::backdrop']];
|
|
8
|
+
|
|
9
|
+
function createCssVar(key: colorScheme, themeName: string) {
|
|
10
|
+
function createSuffixScheme(preSuffix: string, suffixMap = suffix) {
|
|
11
|
+
return suffixMap.reduce<string[]>((acc, suffix) => acc.concat(suffix.map(s => `${preSuffix}${s}`).join(',')), []);
|
|
12
|
+
}
|
|
13
|
+
const map = {
|
|
14
|
+
light(key: string) {
|
|
15
|
+
const preSuffix = `[data-theme="${key}"]`;
|
|
16
|
+
return createSuffixScheme(preSuffix);
|
|
17
|
+
},
|
|
18
|
+
dark(key: string) {
|
|
19
|
+
const preSuffix = `html.dark [data-theme="${key}"]`;
|
|
20
|
+
return createSuffixScheme(preSuffix);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return map[key](themeName);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function mergeTheme(themes: globalTheme[]): globalTheme {
|
|
27
|
+
const themeColor = Object.assign({}, ...themes);
|
|
28
|
+
return themeColor;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizePreflights(_themes: globalTheme[] = []) {
|
|
32
|
+
return {
|
|
33
|
+
getCSS: () => {
|
|
34
|
+
const injectionCss: string[] = [];
|
|
35
|
+
const themes = Object.assign(getThemes(), mergeTheme(_themes));
|
|
36
|
+
Object.keys(themes).forEach((key) => {
|
|
37
|
+
delete themes[key].label;
|
|
38
|
+
const css = entriesToCss(Object.entries(themes[key]));
|
|
39
|
+
const themeColorScheme = themes[key]['color-scheme'] as colorScheme;
|
|
40
|
+
const roots = toArray(
|
|
41
|
+
createCssVar(themeColorScheme, key),
|
|
42
|
+
);
|
|
43
|
+
injectionCss.push(roots.map(root => `${root}{${css}}`).join(''));
|
|
44
|
+
});
|
|
45
|
+
return injectionCss.join('');
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const presetThemes = definePreset<{ themes?: globalTheme[] }>((options) => {
|
|
51
|
+
return {
|
|
52
|
+
name: '@wsys/preset-themes',
|
|
53
|
+
preflights: [
|
|
54
|
+
normalizePreflights(options?.themes),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
});
|