@canlooks/can-ui 0.0.44 → 0.0.45
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/cjs/components/card/card.style.js +2 -2
- package/dist/cjs/components/form/form.d.ts +1 -1
- package/dist/cjs/components/placeholder/placeholder.js +3 -3
- package/dist/cjs/components/segmented/segmented.d.ts +3 -1
- package/dist/cjs/components/segmented/segmented.js +2 -2
- package/dist/cjs/components/segmented/segmented.style.d.ts +4 -1
- package/dist/cjs/components/segmented/segmented.style.js +94 -90
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/utils/style.js +5 -1
- package/dist/esm/components/card/card.style.js +2 -2
- package/dist/esm/components/form/form.d.ts +1 -1
- package/dist/esm/components/placeholder/placeholder.js +3 -3
- package/dist/esm/components/segmented/segmented.d.ts +3 -1
- package/dist/esm/components/segmented/segmented.js +3 -3
- package/dist/esm/components/segmented/segmented.style.d.ts +4 -1
- package/dist/esm/components/segmented/segmented.style.js +93 -90
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/utils/style.js +5 -1
- package/documentation/dist/assets/{index-DD484MoK.js → index-Dqm5gD_7.js} +387 -387
- package/documentation/dist/components/segmented.md +14 -13
- package/documentation/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import { defineInnerClasses,
|
|
2
|
+
import { defineInnerClasses, useColor, useCss } from '../../utils';
|
|
3
3
|
import Color from 'color';
|
|
4
4
|
export const classes = defineInnerClasses('segmented', [
|
|
5
5
|
'option',
|
|
@@ -8,115 +8,118 @@ export const classes = defineInnerClasses('segmented', [
|
|
|
8
8
|
'suffix',
|
|
9
9
|
'indicator'
|
|
10
10
|
]);
|
|
11
|
-
export
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
position: relative;
|
|
21
|
-
|
|
22
|
-
.${classes.option} {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
gap: 6px;
|
|
27
|
-
padding: 4px 12px;
|
|
11
|
+
export function useStyle({ indicatorColor }) {
|
|
12
|
+
const indicatorColorValue = useColor(indicatorColor);
|
|
13
|
+
return useCss(({ mode, background, borderRadius, easing, text }) => {
|
|
14
|
+
const bgColor = Color(background.body);
|
|
15
|
+
const hoverBg = bgColor.darken(mode === 'light' ? .04 : .12).hex();
|
|
16
|
+
const activeBg = bgColor.darken(mode === 'light' ? .08 : .24).hex();
|
|
17
|
+
return css `
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
background-color: ${background.body};
|
|
28
20
|
border-radius: ${borderRadius}px;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
z-index: 1;
|
|
33
|
-
transition: background-color .3s ${easing.easeOut};
|
|
34
|
-
-webkit-tap-highlight-color: transparent;
|
|
35
|
-
|
|
36
|
-
&[data-active=true] {
|
|
37
|
-
transition: background-color 0s;
|
|
38
|
-
}
|
|
21
|
+
padding: 2px;
|
|
22
|
+
position: relative;
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
.${classes.option} {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
gap: 6px;
|
|
29
|
+
padding: 4px 12px;
|
|
30
|
+
border-radius: ${borderRadius}px;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
transition: background-color .3s ${easing.easeOut};
|
|
36
|
+
-webkit-tap-highlight-color: transparent;
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
38
|
+
&[data-active=true] {
|
|
39
|
+
transition: background-color 0s;
|
|
40
|
+
}
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
42
|
+
&[data-orientation=vertical] {
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
}
|
|
55
45
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
&[data-disabled=true] {
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
color: ${text.disabled};
|
|
49
|
+
}
|
|
59
50
|
}
|
|
60
|
-
}
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
&[data-size=small] {
|
|
53
|
+
.${classes.option} {
|
|
54
|
+
padding: 3px 12px;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
&[data-size=large] {
|
|
59
|
+
.${classes.option} {
|
|
60
|
+
padding: 11px 12px;
|
|
61
|
+
}
|
|
67
62
|
}
|
|
68
|
-
}
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
64
|
+
&[data-full-width=true] {
|
|
65
|
+
display: flex;
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
position: absolute;
|
|
79
|
-
transition: all .3s ${easing.bounce};
|
|
80
|
-
}
|
|
67
|
+
.${classes.option} {
|
|
68
|
+
flex: 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
81
71
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
transition: background-color 0s;
|
|
72
|
+
&[data-orientation=vertical] {
|
|
73
|
+
flex-direction: column;
|
|
85
74
|
}
|
|
86
|
-
}
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
background-color: ${
|
|
76
|
+
.${classes.indicator} {
|
|
77
|
+
border-radius: ${borderRadius}px;
|
|
78
|
+
background-color: ${indicatorColorValue};
|
|
91
79
|
box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
|
|
80
|
+
position: absolute;
|
|
81
|
+
transition: all .3s ${easing.bounce};
|
|
92
82
|
}
|
|
93
|
-
}
|
|
94
83
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
&[data-animating=true] {
|
|
85
|
+
.${classes.option} {
|
|
86
|
+
transition: background-color 0s;
|
|
87
|
+
}
|
|
98
88
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
&:not([data-active=true]):hover {
|
|
106
|
-
background-color: ${hoverBg};
|
|
89
|
+
|
|
90
|
+
&:not([data-animating=true]) {
|
|
91
|
+
.${classes.option}[data-active=true] {
|
|
92
|
+
background-color: ${indicatorColorValue};
|
|
93
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
|
|
107
94
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&:not(:has([data-active=true])) {
|
|
98
|
+
.${classes.indicator} {
|
|
99
|
+
display: none;
|
|
112
100
|
}
|
|
113
101
|
}
|
|
114
|
-
}
|
|
115
102
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
&:not([data-read-only=true]):not([data-disabled=true]) {
|
|
104
|
+
.${classes.option}:not([data-disabled=true]) {
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
|
|
107
|
+
&:not([data-active=true]):hover {
|
|
108
|
+
background-color: ${hoverBg};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&:not([data-active=true]):active {
|
|
112
|
+
transition: background-color 0s;
|
|
113
|
+
background-color: ${activeBg};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&[data-disabled=true] {
|
|
119
|
+
.${classes.option} {
|
|
120
|
+
cursor: not-allowed;
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
+
`;
|
|
124
|
+
}, [indicatorColorValue]);
|
|
125
|
+
}
|
package/dist/esm/types.d.ts
CHANGED
package/dist/esm/utils/style.js
CHANGED
|
@@ -55,7 +55,7 @@ export function useCss(callback, deps) {
|
|
|
55
55
|
* @param theme
|
|
56
56
|
*/
|
|
57
57
|
export function colorTransfer(colorPropsValue, theme) {
|
|
58
|
-
const { colors, text } = theme;
|
|
58
|
+
const { colors, text, background } = theme;
|
|
59
59
|
if (colorPropsValue in colors) {
|
|
60
60
|
return colors[colorPropsValue].main;
|
|
61
61
|
}
|
|
@@ -68,6 +68,10 @@ export function colorTransfer(colorPropsValue, theme) {
|
|
|
68
68
|
return text[member];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
if (colorPropsValue.startsWith('background')) {
|
|
72
|
+
const [, member] = colorPropsValue.split('.');
|
|
73
|
+
return background[member];
|
|
74
|
+
}
|
|
71
75
|
return colorPropsValue;
|
|
72
76
|
}
|
|
73
77
|
/**
|