eoss 0.1.0-alpha.4 → 0.1.0-alpha.5

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.
@@ -1,9 +1,10 @@
1
1
  @use '../common/var' as *;
2
+ @use '../mixins/function' as func;
2
3
 
3
4
  @mixin button-plain($color) {
4
5
  color: $color;
5
- background: mix($color-white, $color, 90%);
6
- border-color: mix($color-white, $color, 60%);
6
+ background: func.custom-mix($color-white, $color, 90%);
7
+ border-color: func.custom-mix($color-white, $color, 60%);
7
8
 
8
9
  &:hover,
9
10
  &:focus {
@@ -13,8 +14,16 @@
13
14
  }
14
15
 
15
16
  &:active {
16
- background: mix($color-black, $color, $button-active-shade-percent);
17
- border-color: mix($color-black, $color, $button-active-shade-percent);
17
+ background: func.custom-mix(
18
+ $color-black,
19
+ $color,
20
+ $button-active-shade-percent
21
+ );
22
+ border-color: func.custom-mix(
23
+ $color-black,
24
+ $color,
25
+ $button-active-shade-percent
26
+ );
18
27
  color: $color-white;
19
28
  outline: none;
20
29
  }
@@ -24,9 +33,9 @@
24
33
  &:hover,
25
34
  &:focus,
26
35
  &:active {
27
- color: mix($color-white, $color, 40%);
28
- background-color: mix($color-white, $color, 90%);
29
- border-color: mix($color-white, $color, 80%);
36
+ color: func.custom-mix($color-white, $color, 40%);
37
+ background-color: func.custom-mix($color-white, $color, 90%);
38
+ border-color: func.custom-mix($color-white, $color, 80%);
30
39
  }
31
40
  }
32
41
  }
@@ -38,22 +47,26 @@
38
47
 
39
48
  &:hover,
40
49
  &:focus {
41
- background: mix(
50
+ background: func.custom-mix(
42
51
  $color-white,
43
52
  $background-color,
44
53
  $button-hover-tint-percent
45
54
  );
46
- border-color: mix($color-white, $border-color, $button-hover-tint-percent);
55
+ border-color: func.custom-mix(
56
+ $color-white,
57
+ $border-color,
58
+ $button-hover-tint-percent
59
+ );
47
60
  color: $color;
48
61
  }
49
62
 
50
63
  &:active {
51
- background: mix(
64
+ background: func.custom-mix(
52
65
  $color-black,
53
66
  $background-color,
54
67
  $button-active-shade-percent
55
68
  );
56
- border-color: mix(
69
+ border-color: func.custom-mix(
57
70
  $color-black,
58
71
  $border-color,
59
72
  $button-active-shade-percent
@@ -63,12 +76,12 @@
63
76
  }
64
77
 
65
78
  &.is-active {
66
- background: mix(
79
+ background: func.custom-mix(
67
80
  $color-black,
68
81
  $background-color,
69
82
  $button-active-shade-percent
70
83
  );
71
- border-color: mix(
84
+ border-color: func.custom-mix(
72
85
  $color-black,
73
86
  $border-color,
74
87
  $button-active-shade-percent
@@ -82,8 +95,8 @@
82
95
  &:focus,
83
96
  &:active {
84
97
  color: $color-white;
85
- background-color: mix($background-color, $color-white);
86
- border-color: mix($border-color, $color-white);
98
+ background-color: func.custom-mix($background-color, $color-white);
99
+ border-color: func.custom-mix($border-color, $color-white);
87
100
  }
88
101
  }
89
102
 
@@ -1,6 +1,7 @@
1
1
  @use 'sass:math';
2
2
  @use 'sass:list';
3
3
  @use 'sass:string';
4
+ @use 'sass:color';
4
5
  // rgb 颜色转 hex
5
6
  @function rgbToHex($rgbColor) {
6
7
  $ieHexStr: ie-hex-str($rgbColor);
@@ -9,14 +10,14 @@
9
10
  // rgba 颜色转 hex ,该函数是根据背景颜色来计算的。默认背景色是白色
10
11
  @function rgbaToHex($rgbaColor, $background: rgb(255, 255, 255)) {
11
12
  @if ($rgbaColor) {
12
- $bgR: red($background);
13
- $bgG: green($background);
14
- $bgB: blue($background);
13
+ $bgR: color.red($background);
14
+ $bgG: color.green($background);
15
+ $bgB: color.blue($background);
15
16
 
16
- $colorRed: red($rgbaColor);
17
- $colorGreen: green($rgbaColor);
18
- $colorBlue: blue($rgbaColor);
19
- $colorAlpha: opacity($rgbaColor);
17
+ $colorRed: color.red($rgbaColor);
18
+ $colorGreen: color.green($rgbaColor);
19
+ $colorBlue: color.blue($rgbaColor);
20
+ $colorAlpha: color.opacity($rgbaColor);
20
21
 
21
22
  $rgbColor: rgb(
22
23
  (1 - $colorAlpha) * $bgR + $colorAlpha * $colorRed,
@@ -29,10 +30,10 @@
29
30
  }
30
31
  // 根据颜色获取对应的hsv,在tinycolor中首先进行了归一化处理,这里没有
31
32
  // 返回的结果h是0~360,代表的是色相的角度, sv的范围0-1
32
- @function rbgToHsv($color) {
33
- $red: red($color);
34
- $green: green($color);
35
- $blue: blue($color);
33
+ @function rgbToHsv($color) {
34
+ $red: color.red($color);
35
+ $green: color.green($color);
36
+ $blue: color.blue($color);
36
37
  $max: max($red, $green, $blue);
37
38
  $min: min($red, $green, $blue);
38
39
  $diff: $max - $min;
@@ -114,10 +115,12 @@
114
115
  }
115
116
  // 转换明度
116
117
  @function getValue($v, $i, $isLight) {
117
- $value: min(
118
- if($isLight, $v + $brightnessStep1 * $i, $v - $brightnessStep2 * $i),
119
- 1
118
+ $tempValue: if(
119
+ $isLight,
120
+ $v + $brightnessStep1 * $i,
121
+ $v - $brightnessStep2 * $i
120
122
  );
123
+ $value: min($tempValue, 1);
121
124
  @return toFixed($value, 2);
122
125
  }
123
126
  $hueStep: 2;
@@ -131,7 +134,7 @@ $darkColorCount: 4;
131
134
  // 根据颜色和对应的色板位置,计算出对应的色板颜色
132
135
  @function getColor($color, $index) {
133
136
  $isLight: if($index <= 6, true, false);
134
- $hsv: rbgToHsv($color);
137
+ $hsv: rgbToHsv($color);
135
138
  //这里将i转换成以主色为中心,两侧的i值逐渐增大
136
139
  $i: if(
137
140
  $isLight,
@@ -139,8 +142,8 @@ $darkColorCount: 4;
139
142
  $index - $lightColorCount - 1
140
143
  );
141
144
  @return hsvTorgb(
142
- getHue(nth($hsv, 1), $i, $isLight),
143
- getSaturation(nth($hsv, 2), $i, $isLight),
144
- getValue(nth($hsv, 3), $i, $isLight)
145
+ getHue(list.nth($hsv, 1), $i, $isLight),
146
+ getSaturation(list.nth($hsv, 2), $i, $isLight),
147
+ getValue(list.nth($hsv, 3), $i, $isLight)
145
148
  );
146
149
  }
@@ -1,44 +1,88 @@
1
- @use 'config' as *;
2
-
3
- /* BEM support Func
4
- -------------------------- */
5
- @function selectorToString($selector) {
6
- $selector: inspect($selector);
7
- $selector: str-slice($selector, 2, -2);
8
- @return $selector;
9
- }
10
-
11
- @function containsModifier($selector) {
12
- $selector: selectorToString($selector);
13
-
14
- @if str-index($selector, $modifier-separator) {
15
- @return true;
16
- } @else {
17
- @return false;
18
- }
19
- }
20
-
21
- @function containWhenFlag($selector) {
22
- $selector: selectorToString($selector);
23
-
24
- @if str-index($selector, '.' + $state-prefix) {
25
- @return true;
26
- } @else {
27
- @return false;
28
- }
29
- }
30
-
31
- @function containPseudoClass($selector) {
32
- $selector: selectorToString($selector);
33
-
34
- @if str-index($selector, ':') {
35
- @return true;
36
- } @else {
37
- @return false;
38
- }
39
- }
40
-
41
- @function hitAllSpecialNestRule($selector) {
42
- @return containsModifier($selector) or containWhenFlag($selector) or
43
- containPseudoClass($selector);
44
- }
1
+ @use 'config' as *;
2
+ @use 'sass:color';
3
+ @use 'sass:string';
4
+
5
+ /* BEM support Func
6
+ -------------------------- */
7
+ @function selectorToString($selector) {
8
+ $selector: inspect($selector);
9
+ $selector: string.slice($selector, 2, -2);
10
+ @return $selector;
11
+ }
12
+
13
+ @function containsModifier($selector) {
14
+ $selector: selectorToString($selector);
15
+
16
+ @if string.index($selector, $modifier-separator) {
17
+ @return true;
18
+ } @else {
19
+ @return false;
20
+ }
21
+ }
22
+
23
+ @function containWhenFlag($selector) {
24
+ $selector: selectorToString($selector);
25
+
26
+ @if string.index($selector, '.' + $state-prefix) {
27
+ @return true;
28
+ } @else {
29
+ @return false;
30
+ }
31
+ }
32
+
33
+ @function containPseudoClass($selector) {
34
+ $selector: selectorToString($selector);
35
+
36
+ @if string.index($selector, ':') {
37
+ @return true;
38
+ } @else {
39
+ @return false;
40
+ }
41
+ }
42
+
43
+ @function hitAllSpecialNestRule($selector) {
44
+ @return containsModifier($selector) or containWhenFlag($selector) or
45
+ containPseudoClass($selector);
46
+ }
47
+
48
+ /* Helper function to extract default color from CSS variables
49
+ -------------------------- */
50
+ @function extract-default-color($color) {
51
+ @if type-of($color) == 'string' and string.index($color, 'var(') != null {
52
+ // 提取默认颜色值 (var(--name, default) 中的 default 部分)
53
+ $start: string.index($color, ',') + 1;
54
+ $end: string.index($color, ')') - 1;
55
+ @if $start and $end {
56
+ $default-color: string.slice($color, $start, $end);
57
+ // 去除前后空格
58
+ $default-color: string.unquote(string.trim($default-color));
59
+ @return $default-color;
60
+ }
61
+ }
62
+ @return $color;
63
+ }
64
+
65
+ /* Custom mix function for CSS variables
66
+ -------------------------- */
67
+ @function custom-mix($color1, $color2, $weight: 50%) {
68
+ // 提取默认颜色
69
+ $color1-extracted: extract-default-color($color1);
70
+ $color2-extracted: extract-default-color($color2);
71
+
72
+ // 如果提取后仍然是字符串(非CSS颜色值),直接返回
73
+ @if type-of($color1-extracted) ==
74
+ 'string' or
75
+ type-of($color2-extracted) ==
76
+ 'string'
77
+ {
78
+ // 如果第二个颜色是CSS变量,返回第二个颜色
79
+ @if type-of($color2) == 'string' and string.index($color2, 'var(') != null {
80
+ @return $color2;
81
+ }
82
+ // 否则返回第一个颜色
83
+ @return $color1;
84
+ }
85
+
86
+ // 使用原生mix函数混合颜色
87
+ @return color.mix($color1-extracted, $color2-extracted, $weight);
88
+ }
@@ -1,4 +1,5 @@
1
1
  @use 'mixins/mixins' as *;
2
+ @use 'mixins/function' as func;
2
3
  @use 'common/var' as *;
3
4
 
4
5
  @mixin genTheme(
@@ -12,45 +13,61 @@
12
13
  }
13
14
 
14
15
  &.es-tag--info {
15
- background-color: mix(
16
+ background-color: func.custom-mix(
16
17
  $tag-info-color,
17
18
  $color-white,
18
19
  $backgroundColorWeight
19
20
  );
20
- border-color: mix($tag-info-color, $color-white, $borderColorWeight);
21
- color: mix($tag-info-color, $color-white, $fontColorWeight);
21
+ border-color: func.custom-mix(
22
+ $tag-info-color,
23
+ $color-white,
24
+ $borderColorWeight
25
+ );
26
+ color: func.custom-mix($tag-info-color, $color-white, $fontColorWeight);
22
27
 
23
28
  @include when(hit) {
24
29
  border-color: $tag-info-color;
25
30
  }
26
31
 
27
32
  .es-tag__close {
28
- color: mix($tag-info-color, $color-white, $fontColorWeight);
33
+ color: func.custom-mix($tag-info-color, $color-white, $fontColorWeight);
29
34
  &:hover {
30
35
  color: $color-white;
31
- background-color: mix($tag-info-color, $color-white, $hoverColorWeight);
36
+ background-color: func.custom-mix(
37
+ $tag-info-color,
38
+ $color-white,
39
+ $hoverColorWeight
40
+ );
32
41
  }
33
42
  }
34
43
  }
35
44
 
36
45
  &.es-tag--success {
37
- background-color: mix(
46
+ background-color: func.custom-mix(
38
47
  $tag-success-color,
39
48
  $color-white,
40
49
  $backgroundColorWeight
41
50
  );
42
- border-color: mix($tag-success-color, $color-white, $borderColorWeight);
43
- color: mix($tag-success-color, $color-white, $fontColorWeight);
51
+ border-color: func.custom-mix(
52
+ $tag-success-color,
53
+ $color-white,
54
+ $borderColorWeight
55
+ );
56
+ color: func.custom-mix($tag-success-color, $color-white, $fontColorWeight);
44
57
 
45
58
  @include when(hit) {
46
59
  border-color: $tag-success-color;
47
60
  }
48
61
 
49
62
  .es-tag__close {
50
- color: mix($tag-success-color, $color-white, $fontColorWeight);
63
+ color: func.custom-mix(
64
+ $tag-success-color,
65
+ $color-white,
66
+ $fontColorWeight
67
+ );
51
68
  &:hover {
52
69
  color: $color-white;
53
- background-color: mix(
70
+ background-color: func.custom-mix(
54
71
  $tag-success-color,
55
72
  $color-white,
56
73
  $hoverColorWeight
@@ -60,23 +77,31 @@
60
77
  }
61
78
 
62
79
  &.es-tag--warning {
63
- background-color: mix(
80
+ background-color: func.custom-mix(
64
81
  $tag-warning-color,
65
82
  $color-white,
66
83
  $backgroundColorWeight
67
84
  );
68
- border-color: mix($tag-warning-color, $color-white, $borderColorWeight);
69
- color: mix($tag-warning-color, $color-white, $fontColorWeight);
85
+ border-color: func.custom-mix(
86
+ $tag-warning-color,
87
+ $color-white,
88
+ $borderColorWeight
89
+ );
90
+ color: func.custom-mix($tag-warning-color, $color-white, $fontColorWeight);
70
91
 
71
92
  @include when(hit) {
72
93
  border-color: $tag-warning-color;
73
94
  }
74
95
 
75
96
  .es-tag__close {
76
- color: mix($tag-warning-color, $color-white, $fontColorWeight);
97
+ color: func.custom-mix(
98
+ $tag-warning-color,
99
+ $color-white,
100
+ $fontColorWeight
101
+ );
77
102
  &:hover {
78
103
  color: $color-white;
79
- background-color: mix(
104
+ background-color: func.custom-mix(
80
105
  $tag-warning-color,
81
106
  $color-white,
82
107
  $hoverColorWeight
@@ -86,23 +111,27 @@
86
111
  }
87
112
 
88
113
  &.es-tag--danger {
89
- background-color: mix(
114
+ background-color: func.custom-mix(
90
115
  $tag-danger-color,
91
116
  $color-white,
92
117
  $backgroundColorWeight
93
118
  );
94
- border-color: mix($tag-danger-color, $color-white, $borderColorWeight);
95
- color: mix($tag-danger-color, $color-white, $fontColorWeight);
119
+ border-color: func.custom-mix(
120
+ $tag-danger-color,
121
+ $color-white,
122
+ $borderColorWeight
123
+ );
124
+ color: func.custom-mix($tag-danger-color, $color-white, $fontColorWeight);
96
125
 
97
126
  @include when(hit) {
98
127
  border-color: $tag-danger-color;
99
128
  }
100
129
 
101
130
  .es-tag__close {
102
- color: mix($tag-danger-color, $color-white, $fontColorWeight);
131
+ color: func.custom-mix($tag-danger-color, $color-white, $fontColorWeight);
103
132
  &:hover {
104
133
  color: $color-white;
105
- background-color: mix(
134
+ background-color: func.custom-mix(
106
135
  $tag-danger-color,
107
136
  $color-white,
108
137
  $hoverColorWeight
package/src/index.js CHANGED
@@ -223,7 +223,7 @@ if (typeof window !== 'undefined' && window.Vue) {
223
223
  }
224
224
 
225
225
  export default {
226
- version: '0.1.0-alpha.4',
226
+ version: '0.1.0-alpha.5',
227
227
  install,
228
228
  CollapseTransition,
229
229
  Loading,