@carbon/element-styles 0.3.5 → 0.3.6-rc.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.
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.5",
4
+ "version": "0.3.6-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "sass": "index.scss",
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/theme';
11
+ @use '@carbon/styles/scss/spacing';
12
+
13
+ @use '../_labelled-input';
14
+
15
+ @use '../../layout';
16
+ @use '../../utilities/icons';
17
+ @use '../../utilities/guards';
18
+
19
+ $config: () !default;
20
+
21
+ $-default-config: (
22
+ selector: 'label:has(input[type="color"])',
23
+ axis: 'block',
24
+ );
25
+
26
+ /// @group color-input
27
+ /// @param {Map} config [()]
28
+ /// @param {Selector} config.selector ['label:has(input[type="color"])']
29
+ /// @param {'block' | 'inline'} config.axis ['block']
30
+ @mixin styles($config: $config) {
31
+ $props: map.deep-merge($-default-config, $config);
32
+
33
+ #{map.get($props, 'selector')} {
34
+ @include labelled-input.styles((
35
+ label: (
36
+ selector: '&',
37
+ axis: map.get($props, 'axis'),
38
+ ),
39
+ input: (
40
+ selector: 'input[type="color"]',
41
+ emit-readonly: false,
42
+ ),
43
+ fixed-input-trailing-slots: 1,
44
+ input-invalid-slot: 'after',
45
+ ));
46
+
47
+ /*
48
+ inline padding
49
+ + color swatch
50
+ + spacing-05
51
+ + invalid icon space
52
+ + spacing-03
53
+ + trailing icon space
54
+ + inline padding
55
+ */
56
+ $-min-inline-size: calc(
57
+ layout.$density--padding
58
+ + 1rem
59
+ + spacing.$spacing-05
60
+ + 1rem
61
+ + spacing.$spacing-03
62
+ + 1rem
63
+ + layout.$density--padding
64
+ );
65
+
66
+ & input[type="color"] {
67
+ min-inline-size: $-min-inline-size;
68
+ inline-size: 100%;
69
+ cursor: pointer;
70
+
71
+ @include guards.hover {
72
+ &:enabled:hover {
73
+ background-color: theme.$field-hover;
74
+ }
75
+ }
76
+
77
+ &:enabled:active {
78
+ background-color: theme.$layer-active;
79
+ }
80
+ }
81
+
82
+ & input[type="color"]::-webkit-color-swatch-wrapper {
83
+ padding: 0;
84
+ inline-size: 1rem;
85
+ block-size: 1rem;
86
+ }
87
+
88
+ & input[type="color"]::-webkit-color-swatch {
89
+ position: relative;
90
+ inset-block-start: 0.0625rem;
91
+ padding: 0;
92
+ margin: 0;
93
+ border-radius: 0;
94
+ inline-size: 1rem;
95
+ block-size: 1rem;
96
+ border: none;
97
+ box-shadow: inset 0 0 0 0.0625rem rgb(from theme.$border-inverse r g b / 0.15);
98
+ }
99
+
100
+ & input[type="color"]::-moz-color-swatch {
101
+ position: relative;
102
+ inset-block-start: 0.0625rem;
103
+ padding: 0;
104
+ margin: 0;
105
+ border-radius: 0;
106
+ inline-size: 1rem;
107
+ block-size: 1rem;
108
+ border: none;
109
+ box-shadow: inset 0 0 0 0.0625rem rgb(from theme.$border-inverse r g b / 0.15);
110
+ }
111
+
112
+ & input[type="color"]:disabled::-webkit-color-swatch-wrapper {
113
+ opacity: 0.5;
114
+ }
115
+
116
+ &::before {
117
+ @include labelled-input.input-trailing-slot {
118
+ @include icons.color-palette;
119
+ }
120
+ }
121
+ }
122
+ }
@@ -14,6 +14,7 @@
14
14
  @use '../../elements/button';
15
15
  @use '../../elements/checkbox';
16
16
  @use '../../elements/code';
17
+ @use '../../elements/color-input';
17
18
  @use '../../elements/combo-box';
18
19
  @use '../../elements/date-input';
19
20
  @use '../../elements/date-time-input';
@@ -82,6 +83,7 @@
82
83
  ));
83
84
  @include checkbox.styles;
84
85
  @include code.styles;
86
+ @include color-input.styles;
85
87
  @include combo-box.styles;
86
88
  @include date-input.styles;
87
89
  @include date-time-input.styles;
@@ -14,6 +14,7 @@
14
14
  @use '../../elements/button';
15
15
  @use '../../elements/checkbox';
16
16
  @use '../../elements/code';
17
+ @use '../../elements/color-input';
17
18
  @use '../../elements/combo-box';
18
19
  @use '../../elements/date-input';
19
20
  @use '../../elements/date-time-input';
@@ -82,6 +83,7 @@
82
83
  ));
83
84
  @include checkbox.styles;
84
85
  @include code.styles;
86
+ @include color-input.styles;
85
87
  @include combo-box.styles;
86
88
  @include date-input.styles;
87
89
  @include date-time-input.styles;
@@ -82,6 +82,13 @@
82
82
  mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M17.4141 16 24 9.4141 22.5859 8 16 14.5859 9.4143 8 8 9.4141 14.5859 16 8 22.5859 9.4143 24 16 17.4141 22.5859 24 24 22.5859 17.4141 16z'/></svg>");
83
83
  }
84
84
 
85
+ /// @group icons
86
+ /// @param {Length} size [1rem]
87
+ @mixin color-palette($args...) {
88
+ @include -icon($args...);
89
+ mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><circle cx='10' cy='12' r='2'/><circle cx='16' cy='9' r='2'/><circle cx='22' cy='12' r='2'/><circle cx='23' cy='18' r='2'/><circle cx='19' cy='23' r='2'/><path d='M16.54,2A14,14,0,0,0,2,16a4.82,4.82,0,0,0,6.09,4.65l1.12-.31A3,3,0,0,1,13,23.24V27a3,3,0,0,0,3,3A14,14,0,0,0,30,15.46,14.05,14.05,0,0,0,16.54,2Zm8.11,22.31A11.93,11.93,0,0,1,16,28a1,1,0,0,1-1-1V23.24a5,5,0,0,0-5-5,5.07,5.07,0,0,0-1.33.18l-1.12.31A2.82,2.82,0,0,1,4,16,12,12,0,0,1,16.47,4,12.18,12.18,0,0,1,28,15.53,11.89,11.89,0,0,1,24.65,24.32Z'/></svg>");
90
+ }
91
+
85
92
  /// @group icons
86
93
  /// @param {Length} size [1rem]
87
94
  @mixin event--schedule($args...) {