newcp-theme 1.0.0

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.
@@ -0,0 +1,70 @@
1
+ // ==================== 变量定义 ====================
2
+
3
+ // 全局padding
4
+ $padding: 10px;
5
+ //阴影色
6
+ $shadow-color: rgba(0, 0, 0, 0.1);
7
+ //蒙板色
8
+ $mask-color: #000;
9
+
10
+ // 主背景色
11
+ $bg-color: #ffffff;
12
+ // 文字主色
13
+ $fore-color: #303030;
14
+ // 边框颜色
15
+ $border-color: #dcdfe6;
16
+
17
+ //主题前景色
18
+ $theme-fore: #ffffff;
19
+ // 主题颜色
20
+ $colmap: (
21
+ primary: #409eff,
22
+ success: #67c23a,
23
+ warning: #e6a23c,
24
+ danger: #f56c6c,
25
+ info: #909399,
26
+ );
27
+
28
+ $disabled-text-color: var(--nc-bg-color-9);
29
+
30
+ $disabled-border-color: var(--nc-bg-color-3);
31
+
32
+ $bg-colhover: var(--nc-bg-color-2);
33
+
34
+ //border
35
+ $border-width: 1px;
36
+ $border-radius: 4px;
37
+ $border-radius-round: 20px;
38
+
39
+ $border-style: solid;
40
+
41
+ //字体大小
42
+ $font-size: 10px;
43
+
44
+ //zindex
45
+ $popup-zindex: 1000;
46
+ $modal-zindex: 1000;
47
+ $drawer-zindex: 1000;
48
+ $notification-zindex: 1000;
49
+ $message-zindex: 1001;
50
+ $pop-zindex: 1002;
51
+
52
+ // 字体
53
+ $font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, 微软雅黑, Arial, sans-serif;
54
+ $font-weight: 400;
55
+
56
+ // 动画
57
+ $transition-duration: 0.2s;
58
+ $transition-function-ease-in-out-bezier: cubic-bezier(0.645, 0.045, 0.355, 1);
59
+ $transition-function-fast-bezier: cubic-bezier(0.23, 1, 0.32, 1);
60
+
61
+ $transition-all: all $transition-duration $transition-function-ease-in-out-bezier;
62
+ $transition-fade: opacity $transition-duration $transition-function-fast-bezier;
63
+ $transition-md-fade: transform $transition-duration $transition-function-fast-bezier, opacity $transition-duration $transition-function-fast-bezier;
64
+ $transition-fade-linear: opacity $transition-duration linear;
65
+ $transition-border: border-color $transition-duration $transition-function-ease-in-out-bezier;
66
+ $transition-box-shadow: box-shadow $transition-duration $transition-function-ease-in-out-bezier;
67
+ $transition-color: color $transition-duration $transition-function-ease-in-out-bezier;
68
+
69
+ // scrollbar
70
+ $scrollbar-width: 3px;
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "newcp-theme",
3
+ "version": "1.0.0",
4
+ "description": "原生web component组件库-样式主题配置工具",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "newcp-theme": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc && mkdir dist\\internal-scss 2>nul && xcopy src\\internal-scss\\* dist\\internal-scss\\ /E /H /Y /Q && xcopy src\\default-config.ts dist\\ /Y",
11
+ "start": "node dist/index.js"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "type": "commonjs",
17
+ "dependencies": {
18
+ "commander": "^14.0.3",
19
+ "sass": "^1.98.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^25.5.0",
23
+ "@types/sass": "^1.43.1",
24
+ "typescript": "^6.0.2"
25
+ }
26
+ }
@@ -0,0 +1,60 @@
1
+ // NC UI 主题默认配置
2
+ // 所有可自定义的 SCSS 变量均在此处,修改后执行编译命令即可生效,请勿修改变量名
3
+ export const defaultConfig = {
4
+ // ==================== 基础样式变量 ====================
5
+ "$padding": "10px", // 全局默认内边距
6
+ "$shadow-color": "rgba(0, 0, 0, 0.1)", // 全局阴影颜色
7
+ "$mask-color": "#000", // 全局遮罩层背景色
8
+ "$bg-color": "#ffffff", // 页面/组件主背景色
9
+ "$fore-color": "#303030", // 页面/组件主文字色
10
+ "$border-color": "#dcdfe6", // 全局基础边框色
11
+ "$theme-fore": "#ffffff", // 主题文字前景色
12
+
13
+ // ==================== 五大主题色:主色、成功、警告、危险、信息 ====================
14
+ "$colmap": `(
15
+ primary: #409eff,
16
+ success: #67c23a,
17
+ warning: #e6a23c,
18
+ danger: #f56c6c,
19
+ info: #909399,
20
+ )`,
21
+
22
+ // ==================== 禁用状态 ====================
23
+ "$disabled-text-color": "var(--nc-bg-color-9)", // 禁用状态文字颜色
24
+ "$disabled-border-color": "var(--nc-bg-color-3)", // 禁用状态边框颜色
25
+ "$bg-colhover": "var(--nc-bg-color-2)", // 元素hover背景色
26
+
27
+ // ==================== 边框相关 ====================
28
+ "$border-width": "1px", // 全局边框宽度
29
+ "$border-radius": "4px", // 基础圆角大小
30
+ "$border-radius-round": "20px", // 圆形/胶囊形圆角
31
+ "$border-style": "solid", // 全局边框样式(实线/虚线等)
32
+
33
+ // ==================== 字体相关 ====================
34
+ "$font-size": "10px", // 基础字号(基准值)
35
+ "$font-family": "Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, 微软雅黑, Arial, sans-serif", // 全局字体
36
+ "$font-weight": 400, // 基础字重
37
+
38
+ // ==================== z-index 层级 ====================
39
+ "$popup-zindex": 1000, // 弹出层基础层级
40
+ "$modal-zindex": 1000, // 模态框层级
41
+ "$drawer-zindex": 1000, // 抽屉弹窗层级
42
+ "$notification-zindex": 1000, // 通知提示层级
43
+ "$message-zindex": 1001, // 消息提示层级
44
+ "$pop-zindex": 1002, // 气泡/弹出框层级
45
+
46
+ // ==================== 动画 / 过渡 ====================
47
+ "$transition-duration": "0.2s", // 基础过渡动画时长
48
+ "$transition-function-ease-in-out-bezier": "cubic-bezier(0.645, 0.045, 0.355, 1)", // 缓动函数(先慢后快再慢)
49
+ "$transition-function-fast-bezier": "cubic-bezier(0.23, 1, 0.32, 1)", // 快速缓动函数
50
+ "$transition-all": "all $transition-duration $transition-function-ease-in-out-bezier", // 全局统一过渡动画
51
+ "$transition-fade": "opacity $transition-duration $transition-function-fast-bezier", // 淡入淡出动画
52
+ "$transition-md-fade": "transform $transition-duration $transition-function-fast-bezier, opacity $transition-duration $transition-function-fast-bezier", // 位移+淡入淡出组合动画
53
+ "$transition-fade-linear": "opacity $transition-duration linear", // 线性淡入淡出
54
+ "$transition-border": "border-color $transition-duration $transition-function-ease-in-out-bezier", // 边框色过渡动画
55
+ "$transition-box-shadow": "box-shadow $transition-duration $transition-function-ease-in-out-bezier", // 阴影过渡动画
56
+ "$transition-color": "color $transition-duration $transition-function-ease-in-out-bezier", // 文字色过渡动画
57
+
58
+ // ==================== 滚动条 ====================
59
+ "$scrollbar-width": "3px", // 滚动条宽度
60
+ };
package/src/index.ts ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { execSync } from 'child_process';
6
+
7
+ const program = new Command();
8
+
9
+ program
10
+ .name('newcp-theme')
11
+ .version('1.0.0')
12
+ .description('NC 主题编译 CLI 工具');
13
+
14
+ // ==============================================
15
+ // 1. init 命令:生成 theme.config.ts
16
+ // ==============================================
17
+ program
18
+ .command('init')
19
+ .description('生成主题配置文件 theme.config.ts')
20
+ .action(() => {
21
+ // 1. 读取默认配置文件的原始内容
22
+ const templatePath = path.resolve(__dirname, 'default-config.ts');
23
+ let content = fs.readFileSync(templatePath, 'utf8');
24
+
25
+ // 2. 把 export const 改成 export default (给用户用)
26
+ content = content.replace('export const defaultConfig =', 'export default');
27
+
28
+ // 3. 写入到用户目录
29
+ const targetPath = path.resolve(process.cwd(), 'theme.config.ts');
30
+ fs.writeFileSync(targetPath, content, 'utf8');
31
+
32
+ console.log('✅ 主题配置文件 theme.config.ts 生成成功!\n');
33
+ console.log('🔧 修改主题配置文件后执行:newcp-theme build 可生成专属你的CSS样式文件!');
34
+ });
35
+
36
+ // ==============================================
37
+ // 2. build 命令
38
+ // ==============================================
39
+ program
40
+ .command('build')
41
+ .description('编译主题变量并生成 CSS')
42
+ .action(async () => {
43
+ const cwd = process.cwd();
44
+ const internalScssDir = path.resolve(__dirname, 'internal-scss');
45
+ const tempDir = path.resolve(cwd, '.newcp-temp');
46
+
47
+ try {
48
+ console.log('📖 读取主题配置...\n');
49
+
50
+ // 1. 创建临时目录
51
+ if (!fs.existsSync(tempDir)) {
52
+ fs.mkdirSync(tempDir);
53
+ }
54
+
55
+ // 2. 复制所有内置 SCSS 到临时目录
56
+ const scssFiles = fs.readdirSync(internalScssDir);
57
+ for (const file of scssFiles) {
58
+ const src = path.join(internalScssDir, file);
59
+ const dest = path.join(tempDir, file);
60
+ fs.copyFileSync(src, dest);
61
+ }
62
+
63
+ // 3. 读取用户配置
64
+ const configPath = path.join(cwd, 'theme.config.ts');
65
+ if (!fs.existsSync(configPath)) {
66
+ console.log('❌ 错误:未找到主题配置文件theme.config.ts,请先执行 newcp-theme init');
67
+ return;
68
+ }
69
+
70
+ // ==============================================
71
+ // 安全读取 TS 文件
72
+ // ==============================================
73
+ const content = fs.readFileSync(configPath, 'utf8');
74
+ const match = content.match(/export default([\s\S]*);/);
75
+ const userConfig = eval('(' + match[1] + ')');
76
+
77
+ // 4. 读取内置 variables.scss
78
+ const scssFilePath = path.join(tempDir, 'variables.scss');
79
+ let scssContent = fs.readFileSync(scssFilePath, 'utf8');
80
+
81
+ console.log('🔁 正在替换SCSS样式文件中变量的值...\n');
82
+
83
+ // 5. 变量替换逻辑
84
+ let flag = 0;
85
+ for (const [key, newValue] of Object.entries(userConfig)) {
86
+ const regex = new RegExp(`\\${key}:\\s*([\\s\\S]*?);`);
87
+ const match = regex.exec(scssContent);
88
+
89
+ if (match) {
90
+ let oldValue = match[1].trim();
91
+ let newStr = String(newValue).trim();
92
+ const oldClean = oldValue.replace(/\s+/g, '');
93
+ const newClean = newStr.replace(/\s+/g, '');
94
+
95
+ if (oldClean !== newClean) {
96
+ flag = 1;
97
+ console.log(`✅ 已修改的变量:${key}`);
98
+ console.log(` 旧值:${oldValue}`);
99
+ console.log(` 新值:${newValue}\n`);
100
+ scssContent = scssContent.replace(regex, `${key}: ${newValue};`);
101
+ }
102
+ }
103
+ }
104
+ if (flag===0) {
105
+ console.log("✅ 暂无变量进行了修改!\n");
106
+ }
107
+
108
+ // 6. 写入修改后的 variables.scss
109
+ fs.writeFileSync(scssFilePath, scssContent, 'utf8');
110
+ console.log('✅ SCSS样式文件更新完成!\n');
111
+
112
+ // 7. 编译
113
+ console.log('🔨 正在编译SCSS样式文件 ...\n');
114
+ execSync('sass cssvariables.scss variables.css', {
115
+ stdio: 'inherit',
116
+ cwd: tempDir,
117
+ });
118
+
119
+ // 8. 把生成的 variables.css 移到用户目录
120
+ const generatedCss = path.join(tempDir, 'variables.css');
121
+ const targetCss = path.join(cwd, 'variables.css');
122
+ fs.copyFileSync(generatedCss, targetCss);
123
+
124
+ console.log('🎉 编译成功!CSS样式文件 variables.css 已生成!');
125
+ } catch (err) {
126
+ console.error('❌ 编译失败:', err);
127
+ } finally {
128
+ // 强制清理临时文件夹,无论成功失败
129
+ if (fs.existsSync(tempDir)) {
130
+ fs.rmSync(tempDir, { recursive: true, force: true });
131
+ }
132
+ }
133
+ });
134
+
135
+ program.parse();
@@ -0,0 +1,48 @@
1
+ // _animations.scss(动画模块)
2
+
3
+ // fadeIn
4
+ @mixin fadeIn {
5
+ // 封装动画调用(可选,推荐)
6
+ animation: fadeIn var(--nc-transition-duration-1) ease;
7
+ }
8
+
9
+ // 定义淡入动画
10
+ @keyframes fadeIn {
11
+ from {
12
+ opacity: 0;
13
+ transform: translateY(4px);
14
+ }
15
+ to {
16
+ opacity: 1;
17
+ transform: translateY(0);
18
+ }
19
+ }
20
+
21
+ @mixin fadeOut {
22
+ animation: fadeOut var(--nc-transition-duration-1) ease;
23
+ }
24
+ // fadeOut
25
+ @keyframes fadeOut {
26
+ from {
27
+ opacity: 1;
28
+ }
29
+ to {
30
+ opacity: 0;
31
+ }
32
+ }
33
+
34
+ @mixin slideIn {
35
+ // 封装动画调用(可选,推荐)
36
+ animation: slideIn var(--nc-transition-duration-1) ease;
37
+ }
38
+ // slideIn
39
+ @keyframes slideIn {
40
+ from {
41
+ transform: translateX(-10px);
42
+ opacity: 0;
43
+ }
44
+ to {
45
+ transform: translateX(0);
46
+ opacity: 1;
47
+ }
48
+ }
@@ -0,0 +1,139 @@
1
+ @use "./variables.scss" as v;
2
+ @use "./function.scss" as f;
3
+ @use "./global.scss" as g;
4
+
5
+ /**
6
+ * 颜色说明:
7
+ * placeholder:
8
+ * color:var(--nc--fore-color-5);
9
+ * disabled:
10
+ * background-color: var(--nc-bg-color-2);
11
+ * border-color: var(--nc-bg-color-3);
12
+ * color: var(--nc-bg-color-9);
13
+ * hover:
14
+ * background-color: var(--nc-bg-color-5);
15
+ * color: var(--nc--fore-color-0);
16
+ * selected:
17
+ * background-color:var(--nc-primary-light-9);
18
+ * color:var(--nc-primary-light-0);
19
+ */
20
+ :root {
21
+ //阴影色
22
+ --nc-shadow-color: #{v.$shadow-color};
23
+ //蒙板色
24
+ --nc-mask-color: #{v.$mask-color};
25
+ //1-10级背景色、前景色
26
+ @for $i from 0 through 9 {
27
+ $bg: v.$bg-color;
28
+ $fore: v.$fore-color;
29
+ @if f.is-darktheme() {
30
+ $bg: f.getcolor(v.$bg-color, l, 0.2 * $i);
31
+ $fore: f.getcolor(v.$fore-color, d, 0.5 * $i);
32
+ } @else {
33
+ $bg: f.getcolor(v.$bg-color, d, 0.2 * $i);
34
+ $fore: f.getcolor(v.$fore-color, l, 0.5 * $i);
35
+ }
36
+ --nc-bg-color-#{$i}: #{$bg};
37
+ --nc-fore-color-#{$i}: #{$fore};
38
+ }
39
+
40
+ --nc-theme-fore: #{v.$theme-fore};
41
+ //1-10级 primary、success、warn、danger、info theme light和dark
42
+ $themes: primary success warning danger info;
43
+ @each $theme in $themes {
44
+ @for $i from 0 through 9 {
45
+ --nc-#{$theme}-light-#{$i}: #{f.getthemecolor($theme, l, $i)};
46
+ --nc-#{$theme}-dark-#{$i}: #{f.getthemecolor($theme, d, $i)};
47
+ }
48
+ }
49
+
50
+ //font family
51
+ --nc-font-family: #{v.$font-family};
52
+ //字体大小 基础10px,依次增加2px,10-28px
53
+ // 0号 小字体
54
+ // 1号 正常字体
55
+ @for $i from 0 through 9 {
56
+ --nc-font-size-#{$i}: #{v.$font-size + 2 * $i};
57
+ }
58
+
59
+ // 字体加粗 1-5级
60
+ @for $i from 0 through 5 {
61
+ --nc-font-weight-#{$i}: #{v.$font-weight + 100 * $i};
62
+ }
63
+
64
+ // border
65
+ --nc-border-width: #{v.$border-width};
66
+
67
+ // border radius
68
+ --nc-border-radius-base: #{v.$border-radius};
69
+ --nc-border-radius-larger: #{v.$border-radius + 2};
70
+ --nc-border-radius-largest: #{v.$border-radius + 4};
71
+
72
+ --nc-border-radius-round: #{v.$border-radius-round};
73
+ --nc-border-radius-round: 50%;
74
+ //0-4级边框色、实线边框、虚线边框
75
+ @for $i from 0 through 4 {
76
+ $color: v.$border-color;
77
+ @if f.is-darktheme() {
78
+ $color: #{f.getcolor(v.$border-color, l, $i * 0.2)};
79
+ }
80
+ else {
81
+ $color: #{f.getcolor(v.$border-color, d, $i * 0.2)};
82
+ }
83
+ --nc-border-color-#{$i}: #{$color};
84
+ --nc-border-solid-#{$i}: #{v.$border-width} #{$color} solid;
85
+ --nc-border-dash-#{$i}: #{v.$border-width} #{$color} dashed;
86
+ }
87
+
88
+ //padding
89
+ --nc-padding: #{v.$padding};
90
+
91
+ //duration 1-5级 0.2-0.6
92
+ @for $i from 0 through 4 {
93
+ --nc-transition-duration-#{$i}: #{v.$transition-duration + 0.1 * $i};
94
+ }
95
+ --nc-transition-ease-in-out-bezier: #{v.$transition-function-ease-in-out-bezier};
96
+ --nc-transition-function-fast-bezier: #{v.$transition-function-fast-bezier};
97
+
98
+ --nc-scrollbar-width: #{v.$scrollbar-width};
99
+
100
+ //zindex
101
+ --nc-popup-zindex: #{v.$popup-zindex};
102
+ --nc-modal-zindex: #{v.$modal-zindex};
103
+ --nc-drawer-zindex: #{v.$drawer-zindex};
104
+ --nc-notification-zindex: #{v.$notification-zindex};
105
+ --nc-message-zindex: #{v.$message-zindex};
106
+ --nc-pop-zindex: #{v.$pop-zindex};
107
+ //超链接
108
+ a {
109
+ @extend %a;
110
+ }
111
+
112
+ //字体
113
+ * {
114
+ font-family: v.$font-family;
115
+ }
116
+ }
117
+
118
+ /* 整个滚动条 */
119
+ ::-webkit-scrollbar {
120
+ width: var(--nc-scrollbar-width); /* 垂直滚动条宽度 */
121
+ height: var(--nc-scrollbar-width); /* 水平滚动条高度 */
122
+ }
123
+
124
+ /* 滚动条轨道(背景) */
125
+ ::-webkit-scrollbar-track {
126
+ background: var(--nc-bg-color-1);
127
+ border-radius: var(--nc-scrollbar-width);
128
+ }
129
+
130
+ /* 滚动条滑块(可拖动部分) */
131
+ ::-webkit-scrollbar-thumb {
132
+ background: var(--nc-bg-color-9);
133
+ border-radius: var(--nc-scrollbar-width);
134
+ }
135
+
136
+ /* 滑块悬停效果 */
137
+ ::-webkit-scrollbar-thumb:hover {
138
+ background: var(--nc-fore-color-9);
139
+ }
@@ -0,0 +1,43 @@
1
+ @use "./variables.scss" as v;
2
+ @use "sass:color";
3
+ @use "sass:map";
4
+ @use "sass:math";
5
+ /**** 颜色函数 ****/
6
+ /**
7
+ * 获取颜色
8
+ * @param $color - 颜色
9
+ * @param $type - 类型:l(light,颜色变浅),d(dark,颜色逐渐变深),为空则返回$color
10
+ * @param $level - 变轻或变深的程度,按照10%*$level 变化
11
+ */
12
+ @function getcolor($color, $type: null, $level: null) {
13
+ @if $type ==null {
14
+ @return $color;
15
+ }
16
+
17
+ $lightness: math.percentage(math.div($level, 10));
18
+
19
+ @if $type == "l" {
20
+ @return color.mix(#fff, $color, $lightness);
21
+ } @else {
22
+ @return color.mix(#000, $color, $lightness);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * 获取主题颜色
28
+ * @param $name - 颜色名,primary,success,warning,danger,info
29
+ * @param $type - 类型:l(light,颜色变浅),d(dark,颜色逐渐变深),默认l
30
+ * @param $level - 变轻或变深的程度,按照10%*$level 变化
31
+ */
32
+ @function getthemecolor($name, $type: null, $level: null) {
33
+ $color: map.get(v.$colmap, $name);
34
+ @return getcolor($color, $type, $level);
35
+ }
36
+
37
+ /**
38
+ * 判断是否为深色主题
39
+ */
40
+ @function is-darktheme() {
41
+ $color: color.channel(v.$bg-color, "lightness", $space: hsl);
42
+ @return $color < 50%;
43
+ }
@@ -0,0 +1,14 @@
1
+ %a {
2
+ color: var(--nc-primary-light-0);
3
+ text-decoration: none;
4
+
5
+ &:hover,
6
+ &:focus {
7
+ color: var(--nc-primary-light-3);
8
+ }
9
+
10
+ &:active {
11
+ color: var(--nc-primary-dark-2);
12
+ }
13
+ }
14
+
@@ -0,0 +1,6 @@
1
+ @forward "./src/variables.scss";
2
+ @forward "./src/mixins.scss";
3
+ @forward "./src/function.scss";
4
+ // @forward "./src/cssvariables.scss";
5
+ @forward "./src/global.scss";
6
+ @forward "./src/animation.scss";
@@ -0,0 +1,140 @@
1
+ @use "sass:math";
2
+ // ==================== 混入定义 ====================
3
+
4
+ // 尺寸混入
5
+ @mixin size-variant($padding, $font-size) {
6
+ padding: $padding;
7
+ font-size: $font-size;
8
+ }
9
+
10
+ // 文本溢出省略
11
+ @mixin text-ellipsis {
12
+ overflow: hidden;
13
+ text-overflow: ellipsis;
14
+ white-space: nowrap;
15
+ }
16
+
17
+ // 居中混入用于 flex 布局居中
18
+ @mixin center-flex {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ }
23
+
24
+ // 居中混入 -- 用于 position 居中 -- 注意将父元素设置为 position: relative
25
+ @mixin center-position {
26
+ position: absolute;
27
+ top: 50%;
28
+ left: 50%;
29
+ transform: translate(-50%, -50%);
30
+ }
31
+
32
+ /**
33
+ * 箭头
34
+ * @size - 字体大小
35
+ */
36
+ @mixin arrow($size) {
37
+ display: inline-block;
38
+
39
+ &::after {
40
+ content: "";
41
+ display: inline-block;
42
+ width: calc($size / 3);
43
+ height: calc($size / 3);
44
+ border: solid currentColor;
45
+ /* 对勾颜色 */
46
+ border-width: 0 1px 1px 0;
47
+ /* 只显示右下边框,模拟对勾 */
48
+ transform-origin: center;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * 对勾
54
+ * @size : 尺寸
55
+ */
56
+ @mixin check($size) {
57
+ content: "";
58
+ width: calc($size / 2 - 2px);
59
+ height: calc($size / 2 + 2px);
60
+ border: solid currentColor;
61
+ border-width: 0 2px 2px 0;
62
+ transform: rotate(45deg);
63
+ }
64
+
65
+ //disabled
66
+ @mixin disabled-box {
67
+ cursor: not-allowed;
68
+ background-color: var(--nc-bg-color-2);
69
+ border-color: var(--nc-bg-color-3);
70
+ color: var(--nc-bg-color-9);
71
+ }
72
+ //disabled(仅font)
73
+ @mixin disabled-font {
74
+ cursor: not-allowed;
75
+ color: var(--nc-bg-color-9);
76
+ }
77
+
78
+ //hover
79
+ @mixin item-hover {
80
+ background-color: var(--nc-bg-color-3);
81
+ color: var(--nc-fore-color-0);
82
+ }
83
+
84
+ // 带边框hover
85
+ @mixin item-hover-border {
86
+ border-color: var(--nc-primary-light-0);
87
+ color: var(--nc-primary-light-0);
88
+ }
89
+
90
+ // focus
91
+ @mixin focus-visible($color: var(--nc-primary-light-0)) {
92
+ outline: none;
93
+ box-shadow: 0 0 0 2px $color;
94
+ }
95
+
96
+ // selected
97
+ @mixin item-selected() {
98
+ background-color: var(--nc-primary-light-9);
99
+ color: var(--nc-primary-light-0);
100
+ }
101
+ // seleted font only
102
+ @mixin item-selected-text() {
103
+ color: var(--nc-primary-light-0);
104
+ }
105
+
106
+ // close 按钮
107
+ @mixin close-btn($size:var(--nc-font-size-0)) {
108
+ font-size: $size;
109
+ transition: color var(--nc-transition-duration-0) ease;
110
+ cursor: pointer;
111
+ &:hover {
112
+ color: var(--nc-danger-dark-2);
113
+ font-weight: var(--nc-font-weight-1);
114
+ }
115
+ &::after {
116
+ content: "✕";
117
+ }
118
+ }
119
+ // 圆底close按钮
120
+ @mixin circle-close-btn($size:var(--nc-font-size-1)) {
121
+ display:inline-block;
122
+ font-size: calc($size - 6px);
123
+ width:$size;
124
+ height:$size;
125
+ text-align:center;
126
+ line-height: $size;
127
+ border-radius:50%;
128
+ color:var(--nc-bg-color-1);
129
+ background-color:var(--nc-bg-color-9);
130
+ transition: all var(--nc-transition-duration-0) ease;
131
+ cursor: pointer;
132
+ &:hover {
133
+ background-color:var(--nc-fore-color-9);
134
+ }
135
+ &::after {
136
+ content: "✕";
137
+ }
138
+ }
139
+
140
+