@carbon/element-styles 0.3.1 → 0.3.2-rc.1
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/element-styles",
|
|
3
3
|
"description": "An experimental styling system for native HTML elements, relying on semantic, attribute-focused selectors instead of class names.",
|
|
4
|
-
"version": "0.3.1",
|
|
4
|
+
"version": "0.3.2-rc.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sass": "index.scss",
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
@use 'sass:map';
|
|
9
|
+
@use 'sass:string';
|
|
10
|
+
@use 'sass:list';
|
|
9
11
|
|
|
10
12
|
@use '@carbon/styles/scss/theme';
|
|
11
13
|
@use '@carbon/styles/scss/spacing';
|
|
@@ -21,12 +23,14 @@ $config: () !default;
|
|
|
21
23
|
$-default-config: (
|
|
22
24
|
selector: '[popover]',
|
|
23
25
|
caret: true,
|
|
26
|
+
alignment: 'end center',
|
|
24
27
|
);
|
|
25
28
|
|
|
26
29
|
/// @group popover
|
|
27
30
|
/// @param {Map} config [()]
|
|
28
31
|
/// @param {Selector} config.selector ['[popover]']
|
|
29
32
|
/// @param {Bool} config.caret [true]
|
|
33
|
+
/// @param {'start start' | 'start center' | 'start end' | 'center start' | 'center end' | 'end start' | 'end center' | 'end end'} config.alignment ['end center']
|
|
30
34
|
@mixin styles($config: $config) {
|
|
31
35
|
$props: map.deep-merge($-default-config, $config);
|
|
32
36
|
|
|
@@ -39,11 +43,8 @@ $-default-config: (
|
|
|
39
43
|
@include layer.styles;
|
|
40
44
|
@include box-shadow.box-shadow;
|
|
41
45
|
@include layout.mode--body;
|
|
42
|
-
position: absolute;
|
|
43
|
-
inset: unset;
|
|
44
46
|
margin: 0;
|
|
45
|
-
|
|
46
|
-
inset-inline-start: calc(anchor(start) + spacing.$spacing-02);
|
|
47
|
+
position: fixed;
|
|
47
48
|
border: none;
|
|
48
49
|
border-radius: 0.125rem;
|
|
49
50
|
padding: layout.$density--padding;
|
|
@@ -56,10 +57,7 @@ $-default-config: (
|
|
|
56
57
|
display: block;
|
|
57
58
|
block-size: $-caret-size;
|
|
58
59
|
inline-size: $-caret-size;
|
|
59
|
-
rotate: -45deg;
|
|
60
60
|
background-color: inherit;
|
|
61
|
-
inset-block-start: calc($-caret-size * -0.5);
|
|
62
|
-
inset-inline-start: layout.$density--padding;
|
|
63
61
|
clip-path: polygon(
|
|
64
62
|
0% 0%,
|
|
65
63
|
100% 0%,
|
|
@@ -67,5 +65,93 @@ $-default-config: (
|
|
|
67
65
|
0% 0%,
|
|
68
66
|
);
|
|
69
67
|
}
|
|
68
|
+
|
|
69
|
+
$-alignment: string.split(map.get($props, 'alignment'), " ");
|
|
70
|
+
$-alignment-block: list.nth($-alignment, 1);
|
|
71
|
+
$-alignment-inline: list.nth($-alignment, 2);
|
|
72
|
+
|
|
73
|
+
@if $-alignment-block == 'start' {
|
|
74
|
+
position-area: start center;
|
|
75
|
+
inset-block-end: calc(spacing.$spacing-02 + ($-caret-size * 0.5));
|
|
76
|
+
inset-block-start: unset;
|
|
77
|
+
|
|
78
|
+
&::before {
|
|
79
|
+
inset-block-end: calc($-caret-size * -0.5);
|
|
80
|
+
inset-block-start: unset;
|
|
81
|
+
rotate: 135deg;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@if $-alignment-block == 'end' {
|
|
86
|
+
position-area: end center;
|
|
87
|
+
inset-block-start: calc(spacing.$spacing-02 + ($-caret-size * 0.5));
|
|
88
|
+
inset-block-end: unset;
|
|
89
|
+
|
|
90
|
+
&::before {
|
|
91
|
+
inset-block-start: calc($-caret-size * -0.5);
|
|
92
|
+
inset-block-end: unset;
|
|
93
|
+
rotate: -45deg;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@if $-alignment-block == 'start' or $-alignment-block == 'end' {
|
|
98
|
+
@if $-alignment-inline == 'start' {
|
|
99
|
+
translate: calc(-50% + layout.$density--padding + spacing.$spacing-02) 0;
|
|
100
|
+
|
|
101
|
+
&::before {
|
|
102
|
+
inset-inline-start: -get-caret-offset('end', $-caret-size);
|
|
103
|
+
}
|
|
104
|
+
} @else if $-alignment-inline == 'end' {
|
|
105
|
+
translate: calc(50% - layout.$density--padding - spacing.$spacing-02) 0;
|
|
106
|
+
|
|
107
|
+
&::before {
|
|
108
|
+
inset-inline-start: -get-caret-offset('start', $-caret-size);
|
|
109
|
+
}
|
|
110
|
+
} @else if $-alignment-inline == 'center' {
|
|
111
|
+
&::before {
|
|
112
|
+
inset-inline-start: -get-caret-offset('center', $-caret-size);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@if map.get($props, 'alignment') == 'center start' {
|
|
118
|
+
position-area: center start;
|
|
119
|
+
translate: calc((spacing.$spacing-02 + ($-caret-size * 0.5)) * -1);
|
|
120
|
+
|
|
121
|
+
&::before {
|
|
122
|
+
inset-block-start: -get-caret-offset('center', $-caret-size);
|
|
123
|
+
inset-block-end: unset;
|
|
124
|
+
inset-inline-end: calc($-caret-size * -0.5);
|
|
125
|
+
rotate: 45deg;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@if map.get($props, 'alignment') == 'center end' {
|
|
130
|
+
position-area: center end;
|
|
131
|
+
translate: calc(spacing.$spacing-02 + ($-caret-size * 0.5));
|
|
132
|
+
|
|
133
|
+
&::before {
|
|
134
|
+
inset-block-start: -get-caret-offset('center', $-caret-size);
|
|
135
|
+
inset-block-end: unset;
|
|
136
|
+
inset-inline-start: calc($-caret-size * -0.5);
|
|
137
|
+
rotate: -135deg;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@function -get-caret-offset($position, $caret-size: 0rem) {
|
|
144
|
+
@if ($position == 'start') {
|
|
145
|
+
@return calc(layout.$density--padding - $caret-size * 0.5 + spacing.$spacing-02);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@if ($position == 'center') {
|
|
149
|
+
@return calc(50% - $caret-size * 0.5);
|
|
70
150
|
}
|
|
151
|
+
|
|
152
|
+
@if ($position == 'end') {
|
|
153
|
+
@return calc(100% - layout.$density--padding - $caret-size * 0.5 - spacing.$spacing-02);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@error '"#{$position}" is not one of "start" | "center" | "end"';
|
|
71
157
|
}
|
|
@@ -17,11 +17,13 @@ $config: () !default;
|
|
|
17
17
|
|
|
18
18
|
$-default-config: (
|
|
19
19
|
selector: '[popover="hint"]',
|
|
20
|
+
alignment: 'start center',
|
|
20
21
|
);
|
|
21
22
|
|
|
22
23
|
/// @group tooltip
|
|
23
24
|
/// @param {Map} config [()]
|
|
24
25
|
/// @param {Selector} config.selector ['[popover="hint"]']
|
|
26
|
+
/// @param {'start start' | 'start center' | 'start end' | 'center start' | 'center end' | 'end start' | 'end center' | 'end end'} config.alignment ['start center']
|
|
25
27
|
@mixin styles($config: $config) {
|
|
26
28
|
$props: map.deep-merge($-default-config, $config);
|
|
27
29
|
|
|
@@ -29,16 +31,12 @@ $-default-config: (
|
|
|
29
31
|
@include popover.styles((
|
|
30
32
|
selector: '&',
|
|
31
33
|
caret: true,
|
|
34
|
+
alignment: map.get($props, 'alignment'),
|
|
32
35
|
));
|
|
33
36
|
|
|
34
37
|
background-color: theme.$background-inverse;
|
|
35
38
|
color: theme.$text-inverse;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
&::before {
|
|
40
|
-
inset-inline-start: 50%;
|
|
41
|
-
translate: -50% 0;
|
|
42
|
-
}
|
|
39
|
+
inline-size: max-content;
|
|
40
|
+
max-inline-size: 20rem;
|
|
43
41
|
}
|
|
44
42
|
}
|