@spectrum-web-components/swatch 0.1.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/LICENSE +201 -0
- package/README.md +247 -0
- package/custom-elements.json +600 -0
- package/package.json +64 -0
- package/sp-swatch-group.d.ts +6 -0
- package/sp-swatch-group.js +14 -0
- package/sp-swatch-group.js.map +1 -0
- package/sp-swatch.d.ts +6 -0
- package/sp-swatch.js +14 -0
- package/sp-swatch.js.map +1 -0
- package/src/Swatch.d.ts +43 -0
- package/src/Swatch.js +224 -0
- package/src/Swatch.js.map +1 -0
- package/src/SwatchGroup.d.ts +36 -0
- package/src/SwatchGroup.js +235 -0
- package/src/SwatchGroup.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +14 -0
- package/src/index.js.map +1 -0
- package/src/spectrum-config.js +160 -0
- package/src/spectrum-swatch-group.css.d.ts +2 -0
- package/src/spectrum-swatch-group.css.js +21 -0
- package/src/spectrum-swatch-group.css.js.map +1 -0
- package/src/spectrum-swatch.css.d.ts +2 -0
- package/src/spectrum-swatch.css.js +77 -0
- package/src/spectrum-swatch.css.js.map +1 -0
- package/src/swatch-group.css.d.ts +2 -0
- package/src/swatch-group.css.js +21 -0
- package/src/swatch-group.css.js.map +1 -0
- package/src/swatch.css.d.ts +2 -0
- package/src/swatch.css.js +77 -0
- package/src/swatch.css.js.map +1 -0
- package/stories/swatch-group.stories.js +186 -0
- package/stories/swatch-group.stories.js.map +1 -0
- package/stories/swatch-sizes.stories.js +45 -0
- package/stories/swatch-sizes.stories.js.map +1 -0
- package/stories/swatch.stories.js +104 -0
- package/stories/swatch.stories.js.map +1 -0
- package/test/benchmark/basic-test.js +18 -0
- package/test/benchmark/basic-test.js.map +1 -0
- package/test/swatch-group.test-vrt.js +15 -0
- package/test/swatch-group.test-vrt.js.map +1 -0
- package/test/swatch-group.test.js +262 -0
- package/test/swatch-group.test.js.map +1 -0
- package/test/swatch-sizes.test-vrt.js +15 -0
- package/test/swatch-sizes.test-vrt.js.map +1 -0
- package/test/swatch.test-vrt.js +15 -0
- package/test/swatch.test-vrt.js.map +1 -0
- package/test/swatch.test.js +148 -0
- package/test/swatch.test.js.map +1 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
const config = [
|
|
13
|
+
{
|
|
14
|
+
spectrum: 'swatchgroup',
|
|
15
|
+
components: [
|
|
16
|
+
{
|
|
17
|
+
name: 'swatch-group',
|
|
18
|
+
host: {
|
|
19
|
+
selector: '.spectrum-SwatchGroup',
|
|
20
|
+
},
|
|
21
|
+
attributes: [
|
|
22
|
+
{
|
|
23
|
+
type: 'enum',
|
|
24
|
+
name: 'density',
|
|
25
|
+
forceOntoHost: true,
|
|
26
|
+
values: [
|
|
27
|
+
{
|
|
28
|
+
name: 'compact',
|
|
29
|
+
selector: '.spectrum-SwatchGroup--compact',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'spacious',
|
|
33
|
+
selector: '.spectrum-SwatchGroup--spacious',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
spectrum: 'swatch',
|
|
43
|
+
components: [
|
|
44
|
+
{
|
|
45
|
+
name: 'swatch',
|
|
46
|
+
host: {
|
|
47
|
+
selector: '.spectrum-Swatch',
|
|
48
|
+
},
|
|
49
|
+
attributes: [
|
|
50
|
+
{
|
|
51
|
+
type: 'enum',
|
|
52
|
+
name: 'border',
|
|
53
|
+
forceOntoHost: true,
|
|
54
|
+
values: [
|
|
55
|
+
{
|
|
56
|
+
name: 'light',
|
|
57
|
+
selector: '.spectrum-Swatch--lightBorder',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'none',
|
|
61
|
+
selector: '.spectrum-Swatch--noBorder',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'enum',
|
|
67
|
+
name: 'rounding',
|
|
68
|
+
forceOntoHost: true,
|
|
69
|
+
values: [
|
|
70
|
+
{
|
|
71
|
+
name: 'none',
|
|
72
|
+
selector: '.spectrum-Swatch--roundingNone',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'full',
|
|
76
|
+
selector: '.spectrum-Swatch--roundingFull',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
name: 'selected',
|
|
83
|
+
selector: '.is-selected',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
name: 'mixed-value',
|
|
88
|
+
selector: '.is-mixedValue',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'boolean',
|
|
92
|
+
name: 'nothing',
|
|
93
|
+
selector: '.is-nothing',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
name: 'disabled',
|
|
98
|
+
selector: '.is-disabled',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'enum',
|
|
102
|
+
name: 'shape',
|
|
103
|
+
forceOntoHost: true,
|
|
104
|
+
values: [
|
|
105
|
+
{
|
|
106
|
+
name: 'rectangle',
|
|
107
|
+
selector: '.spectrum-Swatch--rectangle',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: 'enum',
|
|
113
|
+
name: 'size',
|
|
114
|
+
forceOntoHost: true,
|
|
115
|
+
values: [
|
|
116
|
+
{
|
|
117
|
+
name: 'xs',
|
|
118
|
+
selector: '.spectrum-Swatch--sizeXS',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 's',
|
|
122
|
+
selector: '.spectrum-Swatch--sizeS',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'm',
|
|
126
|
+
selector: '.spectrum-Swatch--sizeM',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'l',
|
|
130
|
+
selector: '.spectrum-Swatch--sizeL',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
classes: [
|
|
136
|
+
{
|
|
137
|
+
name: 'fill',
|
|
138
|
+
selector: '.spectrum-Swatch-fill',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'disabledIcon',
|
|
142
|
+
selector: '.spectrum-Swatch-disabledIcon',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'mixedValueIcon',
|
|
146
|
+
selector: '.spectrum-Swatch-mixedValueIcon',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
slots: [
|
|
150
|
+
{
|
|
151
|
+
selector: '.spectrum-Swatch-image',
|
|
152
|
+
name: 'image',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
export default config;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{align-items:flex-start;display:inline-flex;flex-direction:row;flex-wrap:wrap;gap:var(--spectrum-global-dimension-size-50);justify-content:flex-start}:host([density=compact]){gap:var(
|
|
15
|
+
--spectrum-global-dimension-size-25
|
|
16
|
+
)}:host([density=spacious]){gap:var(
|
|
17
|
+
--spectrum-global-dimension-size-100
|
|
18
|
+
)}
|
|
19
|
+
`;
|
|
20
|
+
export default styles;
|
|
21
|
+
//# sourceMappingURL=spectrum-swatch-group.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectrum-swatch-group.css.js","sourceRoot":"","sources":["spectrum-swatch-group.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;CAMjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{align-items:flex-start;display:inline-flex;flex-direction:row;flex-wrap:wrap;gap:var(--spectrum-global-dimension-size-50);justify-content:flex-start}:host([density=compact]){gap:var(\n--spectrum-global-dimension-size-25\n)}:host([density=spacious]){gap:var(\n--spectrum-global-dimension-size-100\n)}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{--spectrum-swatch-size-xs:var(
|
|
15
|
+
--spectrum-global-dimension-size-200
|
|
16
|
+
);--spectrum-swatch-size-s:var(--spectrum-global-dimension-size-300);--spectrum-swatch-size-m:var(--spectrum-global-dimension-size-400);--spectrum-swatch-size-l:var(--spectrum-global-dimension-size-500);--spectrum-swatch-disabled-icon-size-xs:var(
|
|
17
|
+
--spectrum-global-dimension-size-150
|
|
18
|
+
);--spectrum-swatch-disabled-icon-size-s:var(
|
|
19
|
+
--spectrum-global-dimension-size-200
|
|
20
|
+
);--spectrum-swatch-disabled-icon-size-m:var(
|
|
21
|
+
--spectrum-global-dimension-size-225
|
|
22
|
+
);--spectrum-swatch-disabled-icon-size-l:var(
|
|
23
|
+
--spectrum-global-dimension-size-250
|
|
24
|
+
);--spectrum-swatch-disabled-icon-color:var(
|
|
25
|
+
--spectrum-global-color-static-gray-50,rgb(var(--spectrum-global-color-static-gray-50-rgb))
|
|
26
|
+
);--spectrum-swatch-disabled-icon-stroke-color:rgba(var(--spectrum-global-color-static-black-rgb,0,0,0),0.51);--spectrum-swatch-selection-padding:var(
|
|
27
|
+
--spectrum-global-dimension-size-100
|
|
28
|
+
);--spectrum-swatch-selection-indicator-border-width:var(
|
|
29
|
+
--spectrum-global-dimension-size-25
|
|
30
|
+
);--spectrum-swatch-selection-indicator-border-color:var(
|
|
31
|
+
--spectrum-global-color-gray-900
|
|
32
|
+
);--spectrum-swatch-background-color-selected:var(
|
|
33
|
+
--spectrum-global-color-gray-50
|
|
34
|
+
);--spectrum-swatch-border-radius:var(
|
|
35
|
+
--spectrum-alias-border-radius-regular,var(--spectrum-global-dimension-size-50)
|
|
36
|
+
);--spectrum-swatch-fill-border-radius-selected:var(
|
|
37
|
+
--spectrum-alias-border-radius-small,var(--spectrum-global-dimension-size-25)
|
|
38
|
+
);--spectrum-swatch-fill-border-width:var(
|
|
39
|
+
--spectrum-alias-border-size-thin,var(--spectrum-global-dimension-static-size-10)
|
|
40
|
+
);--spectrum-swatch-fill-border-color:rgba(var(--spectrum-global-color-gray-900-rgb),0.51);--spectrum-swatch-fill-border-color-light:rgba(var(--spectrum-global-color-gray-900-rgb),0.2);--spectrum-swatch-background-offset:0px;--spectrum-swatch-checkerboard-size:var(
|
|
41
|
+
--spectrum-global-dimension-static-size-100,8px
|
|
42
|
+
);align-items:center;display:flex;justify-content:center;outline:none;position:relative;-webkit-user-select:none;user-select:none}:host,:host:before{border-radius:var(
|
|
43
|
+
--spectrum-swatch-border-radius
|
|
44
|
+
)}:host([selected]){--spectrum-swatch-background-offset:-4px;background-color:var(
|
|
45
|
+
--spectrum-swatch-background-color-selected
|
|
46
|
+
)}:host([selected]) .fill{border-radius:var(--spectrum-swatch-fill-border-radius-selected);height:calc(100% - var(--spectrum-swatch-selection-padding));width:calc(100% - var(--spectrum-swatch-selection-padding))}:host([selected]) .fill:before{border-radius:var(
|
|
47
|
+
--spectrum-swatch-fill-border-radius-selected
|
|
48
|
+
);box-shadow:none}:host([selected]):before{opacity:1}:host([mixed-value]) .fill{background:var(
|
|
49
|
+
--spectrum-swatch-background-color-selected
|
|
50
|
+
)}:host([mixed-value]) .mixedValueIcon{visibility:visible}:host([nothing]) .fill{background:var(
|
|
51
|
+
--spectrum-swatch-background-color-selected
|
|
52
|
+
)}:host([nothing]) .fill:after{background:var(--spectrum-global-color-red-500);content:"";position:absolute;transform:rotate(-45deg);width:200%}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([nothing][size=xs]) .fill:after{height:2px}:host([nothing][size=s]) .fill:after{height:3px}:host([nothing][size=m]) .fill:after{height:4px}:host([nothing][size=l]) .fill:after{height:5px}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{visibility:visible}:host(.focus-visible):after{opacity:1}:host(:focus-visible):after{opacity:1}:host:before{border:var(--spectrum-swatch-selection-indicator-border-width) solid var(--spectrum-swatch-selection-indicator-border-color);bottom:0;content:"";left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0}:host:after{border:var(--spectrum-global-dimension-static-size-25,2px) solid var(
|
|
53
|
+
--spectrum-alias-focus-ring-color,var(--spectrum-alias-focus-color)
|
|
54
|
+
);border-radius:var(--spectrum-alias-focus-ring-border-radius-regular);bottom:calc(var(--spectrum-global-dimension-size-50)*-1);content:"";left:calc(var(--spectrum-global-dimension-size-50)*-1);opacity:0;position:absolute;right:calc(var(--spectrum-global-dimension-size-50)*-1);top:calc(var(--spectrum-global-dimension-size-50)*-1);transition:opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out}.fill{align-items:center;background-color:var(
|
|
55
|
+
--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)
|
|
56
|
+
);background-image:linear-gradient(-45deg,transparent 75.5%,var(
|
|
57
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
58
|
+
) 75.5%),linear-gradient(45deg,transparent 75.5%,var(
|
|
59
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
60
|
+
) 75.5%),linear-gradient(-45deg,var(
|
|
61
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
62
|
+
) 25.5%,transparent 25.5%),linear-gradient(45deg,var(
|
|
63
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
64
|
+
) 25.5%,transparent 25.5%);background-position:var(--spectrum-swatch-background-offset) var(--spectrum-swatch-background-offset),var(--spectrum-swatch-background-offset) calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)) calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)) var(--spectrum-swatch-background-offset);background-size:calc(var(--spectrum-swatch-checkerboard-size)*2) calc(var(--spectrum-swatch-checkerboard-size)*2);border-radius:var(--spectrum-swatch-border-radius);box-sizing:border-box;display:flex;height:100%;justify-content:center;overflow:hidden;position:relative;width:100%}.fill:before{background-color:var(--spectrum-picked-color,transparent);border-radius:var(--spectrum-swatch-border-radius);bottom:0;box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color);content:"";left:0;position:absolute;right:0;top:0;z-index:0}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color-light)}:host([border=none]) .fill:before{box-shadow:none}.mixedValueIcon{color:var(
|
|
65
|
+
--spectrum-global-color-gray-700
|
|
66
|
+
)}.disabledIcon,.mixedValueIcon{pointer-events:none;visibility:hidden}.disabledIcon{stroke:var(--spectrum-swatch-disabled-icon-stroke-color);color:var(--spectrum-swatch-disabled-icon-color);position:relative;z-index:2}:host([size=xs]){height:var(--spectrum-swatch-size-xs);width:var(--spectrum-swatch-size-xs)}:host([size=xs]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-xs);width:var(
|
|
67
|
+
--spectrum-swatch-disabled-icon-size-xs
|
|
68
|
+
)}:host([size=s]){height:var(--spectrum-swatch-size-s);width:var(--spectrum-swatch-size-s)}:host([size=s]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-s);width:var(
|
|
69
|
+
--spectrum-swatch-disabled-icon-size-s
|
|
70
|
+
)}:host([size=m]){height:var(--spectrum-swatch-size-m);width:var(--spectrum-swatch-size-m)}:host([size=m]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-m);width:var(
|
|
71
|
+
--spectrum-swatch-disabled-icon-size-m
|
|
72
|
+
)}:host([size=l]){height:var(--spectrum-swatch-size-l);width:var(--spectrum-swatch-size-l)}:host([size=l]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-l);width:var(
|
|
73
|
+
--spectrum-swatch-disabled-icon-size-l
|
|
74
|
+
)}:host([shape=rectangle][size=xs]){width:calc(var(--spectrum-swatch-size-xs)*2)}:host([shape=rectangle][size=s]){width:calc(var(--spectrum-swatch-size-s)*2)}:host([shape=rectangle][size=m]){width:calc(var(--spectrum-swatch-size-m)*2)}:host([shape=rectangle][size=l]){width:calc(var(--spectrum-swatch-size-l)*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before{border-radius:0}:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before,:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before{border-radius:100%}::slotted([slot=image]){height:100%;object-fit:contain;transition:width var(--spectrum-global-animation-duration-100,.13s) ease-in-out,height var(--spectrum-global-animation-duration-100,.13s) ease-in-out;width:100%}
|
|
75
|
+
`;
|
|
76
|
+
export default styles;
|
|
77
|
+
//# sourceMappingURL=spectrum-swatch.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectrum-swatch.css.js","sourceRoot":"","sources":["spectrum-swatch.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-swatch-size-xs:var(\n--spectrum-global-dimension-size-200\n);--spectrum-swatch-size-s:var(--spectrum-global-dimension-size-300);--spectrum-swatch-size-m:var(--spectrum-global-dimension-size-400);--spectrum-swatch-size-l:var(--spectrum-global-dimension-size-500);--spectrum-swatch-disabled-icon-size-xs:var(\n--spectrum-global-dimension-size-150\n);--spectrum-swatch-disabled-icon-size-s:var(\n--spectrum-global-dimension-size-200\n);--spectrum-swatch-disabled-icon-size-m:var(\n--spectrum-global-dimension-size-225\n);--spectrum-swatch-disabled-icon-size-l:var(\n--spectrum-global-dimension-size-250\n);--spectrum-swatch-disabled-icon-color:var(\n--spectrum-global-color-static-gray-50,rgb(var(--spectrum-global-color-static-gray-50-rgb))\n);--spectrum-swatch-disabled-icon-stroke-color:rgba(var(--spectrum-global-color-static-black-rgb,0,0,0),0.51);--spectrum-swatch-selection-padding:var(\n--spectrum-global-dimension-size-100\n);--spectrum-swatch-selection-indicator-border-width:var(\n--spectrum-global-dimension-size-25\n);--spectrum-swatch-selection-indicator-border-color:var(\n--spectrum-global-color-gray-900\n);--spectrum-swatch-background-color-selected:var(\n--spectrum-global-color-gray-50\n);--spectrum-swatch-border-radius:var(\n--spectrum-alias-border-radius-regular,var(--spectrum-global-dimension-size-50)\n);--spectrum-swatch-fill-border-radius-selected:var(\n--spectrum-alias-border-radius-small,var(--spectrum-global-dimension-size-25)\n);--spectrum-swatch-fill-border-width:var(\n--spectrum-alias-border-size-thin,var(--spectrum-global-dimension-static-size-10)\n);--spectrum-swatch-fill-border-color:rgba(var(--spectrum-global-color-gray-900-rgb),0.51);--spectrum-swatch-fill-border-color-light:rgba(var(--spectrum-global-color-gray-900-rgb),0.2);--spectrum-swatch-background-offset:0px;--spectrum-swatch-checkerboard-size:var(\n--spectrum-global-dimension-static-size-100,8px\n);align-items:center;display:flex;justify-content:center;outline:none;position:relative;-webkit-user-select:none;user-select:none}:host,:host:before{border-radius:var(\n--spectrum-swatch-border-radius\n)}:host([selected]){--spectrum-swatch-background-offset:-4px;background-color:var(\n--spectrum-swatch-background-color-selected\n)}:host([selected]) .fill{border-radius:var(--spectrum-swatch-fill-border-radius-selected);height:calc(100% - var(--spectrum-swatch-selection-padding));width:calc(100% - var(--spectrum-swatch-selection-padding))}:host([selected]) .fill:before{border-radius:var(\n--spectrum-swatch-fill-border-radius-selected\n);box-shadow:none}:host([selected]):before{opacity:1}:host([mixed-value]) .fill{background:var(\n--spectrum-swatch-background-color-selected\n)}:host([mixed-value]) .mixedValueIcon{visibility:visible}:host([nothing]) .fill{background:var(\n--spectrum-swatch-background-color-selected\n)}:host([nothing]) .fill:after{background:var(--spectrum-global-color-red-500);content:\"\";position:absolute;transform:rotate(-45deg);width:200%}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([nothing][size=xs]) .fill:after{height:2px}:host([nothing][size=s]) .fill:after{height:3px}:host([nothing][size=m]) .fill:after{height:4px}:host([nothing][size=l]) .fill:after{height:5px}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{visibility:visible}:host(.focus-visible):after{opacity:1}:host(:focus-visible):after{opacity:1}:host:before{border:var(--spectrum-swatch-selection-indicator-border-width) solid var(--spectrum-swatch-selection-indicator-border-color);bottom:0;content:\"\";left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0}:host:after{border:var(--spectrum-global-dimension-static-size-25,2px) solid var(\n--spectrum-alias-focus-ring-color,var(--spectrum-alias-focus-color)\n);border-radius:var(--spectrum-alias-focus-ring-border-radius-regular);bottom:calc(var(--spectrum-global-dimension-size-50)*-1);content:\"\";left:calc(var(--spectrum-global-dimension-size-50)*-1);opacity:0;position:absolute;right:calc(var(--spectrum-global-dimension-size-50)*-1);top:calc(var(--spectrum-global-dimension-size-50)*-1);transition:opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out}.fill{align-items:center;background-color:var(\n--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)\n);background-image:linear-gradient(-45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(-45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%),linear-gradient(45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%);background-position:var(--spectrum-swatch-background-offset) var(--spectrum-swatch-background-offset),var(--spectrum-swatch-background-offset) calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)) calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)) var(--spectrum-swatch-background-offset);background-size:calc(var(--spectrum-swatch-checkerboard-size)*2) calc(var(--spectrum-swatch-checkerboard-size)*2);border-radius:var(--spectrum-swatch-border-radius);box-sizing:border-box;display:flex;height:100%;justify-content:center;overflow:hidden;position:relative;width:100%}.fill:before{background-color:var(--spectrum-picked-color,transparent);border-radius:var(--spectrum-swatch-border-radius);bottom:0;box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color);content:\"\";left:0;position:absolute;right:0;top:0;z-index:0}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color-light)}:host([border=none]) .fill:before{box-shadow:none}.mixedValueIcon{color:var(\n--spectrum-global-color-gray-700\n)}.disabledIcon,.mixedValueIcon{pointer-events:none;visibility:hidden}.disabledIcon{stroke:var(--spectrum-swatch-disabled-icon-stroke-color);color:var(--spectrum-swatch-disabled-icon-color);position:relative;z-index:2}:host([size=xs]){height:var(--spectrum-swatch-size-xs);width:var(--spectrum-swatch-size-xs)}:host([size=xs]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-xs);width:var(\n--spectrum-swatch-disabled-icon-size-xs\n)}:host([size=s]){height:var(--spectrum-swatch-size-s);width:var(--spectrum-swatch-size-s)}:host([size=s]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-s);width:var(\n--spectrum-swatch-disabled-icon-size-s\n)}:host([size=m]){height:var(--spectrum-swatch-size-m);width:var(--spectrum-swatch-size-m)}:host([size=m]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-m);width:var(\n--spectrum-swatch-disabled-icon-size-m\n)}:host([size=l]){height:var(--spectrum-swatch-size-l);width:var(--spectrum-swatch-size-l)}:host([size=l]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-l);width:var(\n--spectrum-swatch-disabled-icon-size-l\n)}:host([shape=rectangle][size=xs]){width:calc(var(--spectrum-swatch-size-xs)*2)}:host([shape=rectangle][size=s]){width:calc(var(--spectrum-swatch-size-s)*2)}:host([shape=rectangle][size=m]){width:calc(var(--spectrum-swatch-size-m)*2)}:host([shape=rectangle][size=l]){width:calc(var(--spectrum-swatch-size-l)*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before{border-radius:0}:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before,:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before{border-radius:100%}::slotted([slot=image]){height:100%;object-fit:contain;transition:width var(--spectrum-global-animation-duration-100,.13s) ease-in-out,height var(--spectrum-global-animation-duration-100,.13s) ease-in-out;width:100%}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{align-items:flex-start;display:inline-flex;flex-direction:row;flex-wrap:wrap;gap:var(--spectrum-global-dimension-size-50);justify-content:flex-start}:host([density=compact]){gap:var(
|
|
15
|
+
--spectrum-global-dimension-size-25
|
|
16
|
+
)}:host([density=spacious]){gap:var(
|
|
17
|
+
--spectrum-global-dimension-size-100
|
|
18
|
+
)}
|
|
19
|
+
`;
|
|
20
|
+
export default styles;
|
|
21
|
+
//# sourceMappingURL=swatch-group.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swatch-group.css.js","sourceRoot":"","sources":["swatch-group.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;CAMjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{align-items:flex-start;display:inline-flex;flex-direction:row;flex-wrap:wrap;gap:var(--spectrum-global-dimension-size-50);justify-content:flex-start}:host([density=compact]){gap:var(\n--spectrum-global-dimension-size-25\n)}:host([density=spacious]){gap:var(\n--spectrum-global-dimension-size-100\n)}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{--spectrum-swatch-size-xs:var(
|
|
15
|
+
--spectrum-global-dimension-size-200
|
|
16
|
+
);--spectrum-swatch-size-s:var(--spectrum-global-dimension-size-300);--spectrum-swatch-size-m:var(--spectrum-global-dimension-size-400);--spectrum-swatch-size-l:var(--spectrum-global-dimension-size-500);--spectrum-swatch-disabled-icon-size-xs:var(
|
|
17
|
+
--spectrum-global-dimension-size-150
|
|
18
|
+
);--spectrum-swatch-disabled-icon-size-s:var(
|
|
19
|
+
--spectrum-global-dimension-size-200
|
|
20
|
+
);--spectrum-swatch-disabled-icon-size-m:var(
|
|
21
|
+
--spectrum-global-dimension-size-225
|
|
22
|
+
);--spectrum-swatch-disabled-icon-size-l:var(
|
|
23
|
+
--spectrum-global-dimension-size-250
|
|
24
|
+
);--spectrum-swatch-disabled-icon-color:var(
|
|
25
|
+
--spectrum-global-color-static-gray-50,rgb(var(--spectrum-global-color-static-gray-50-rgb))
|
|
26
|
+
);--spectrum-swatch-disabled-icon-stroke-color:rgba(var(--spectrum-global-color-static-black-rgb,0,0,0),0.51);--spectrum-swatch-selection-padding:var(
|
|
27
|
+
--spectrum-global-dimension-size-100
|
|
28
|
+
);--spectrum-swatch-selection-indicator-border-width:var(
|
|
29
|
+
--spectrum-global-dimension-size-25
|
|
30
|
+
);--spectrum-swatch-selection-indicator-border-color:var(
|
|
31
|
+
--spectrum-global-color-gray-900
|
|
32
|
+
);--spectrum-swatch-background-color-selected:var(
|
|
33
|
+
--spectrum-global-color-gray-50
|
|
34
|
+
);--spectrum-swatch-border-radius:var(
|
|
35
|
+
--spectrum-alias-border-radius-regular,var(--spectrum-global-dimension-size-50)
|
|
36
|
+
);--spectrum-swatch-fill-border-radius-selected:var(
|
|
37
|
+
--spectrum-alias-border-radius-small,var(--spectrum-global-dimension-size-25)
|
|
38
|
+
);--spectrum-swatch-fill-border-width:var(
|
|
39
|
+
--spectrum-alias-border-size-thin,var(--spectrum-global-dimension-static-size-10)
|
|
40
|
+
);--spectrum-swatch-fill-border-color:rgba(var(--spectrum-global-color-gray-900-rgb),0.51);--spectrum-swatch-fill-border-color-light:rgba(var(--spectrum-global-color-gray-900-rgb),0.2);--spectrum-swatch-background-offset:0px;--spectrum-swatch-checkerboard-size:var(
|
|
41
|
+
--spectrum-global-dimension-static-size-100,8px
|
|
42
|
+
);align-items:center;display:flex;justify-content:center;outline:none;position:relative;-webkit-user-select:none;user-select:none}:host,:host:before{border-radius:var(
|
|
43
|
+
--spectrum-swatch-border-radius
|
|
44
|
+
)}:host([selected]){--spectrum-swatch-background-offset:-4px;background-color:var(
|
|
45
|
+
--spectrum-swatch-background-color-selected
|
|
46
|
+
)}:host([selected]) .fill{border-radius:var(--spectrum-swatch-fill-border-radius-selected);height:calc(100% - var(--spectrum-swatch-selection-padding));width:calc(100% - var(--spectrum-swatch-selection-padding))}:host([selected]) .fill:before{border-radius:var(
|
|
47
|
+
--spectrum-swatch-fill-border-radius-selected
|
|
48
|
+
);box-shadow:none}:host([selected]):before{opacity:1}:host([mixed-value]) .fill{background:var(
|
|
49
|
+
--spectrum-swatch-background-color-selected
|
|
50
|
+
)}:host([mixed-value]) .mixedValueIcon{visibility:visible}:host([nothing]) .fill{background:var(
|
|
51
|
+
--spectrum-swatch-background-color-selected
|
|
52
|
+
)}:host([nothing]) .fill:after{background:var(--spectrum-global-color-red-500);content:"";position:absolute;transform:rotate(-45deg);width:200%}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([nothing][size=xs]) .fill:after{height:2px}:host([nothing][size=s]) .fill:after{height:3px}:host([nothing][size=m]) .fill:after{height:4px}:host([nothing][size=l]) .fill:after{height:5px}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{visibility:visible}:host(.focus-visible):after{opacity:1}:host(:focus-visible):after{opacity:1}:host:before{border:var(--spectrum-swatch-selection-indicator-border-width) solid var(--spectrum-swatch-selection-indicator-border-color);bottom:0;content:"";left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0}:host:after{border:var(--spectrum-global-dimension-static-size-25,2px) solid var(
|
|
53
|
+
--spectrum-alias-focus-ring-color,var(--spectrum-alias-focus-color)
|
|
54
|
+
);border-radius:var(--spectrum-alias-focus-ring-border-radius-regular);bottom:calc(var(--spectrum-global-dimension-size-50)*-1);content:"";left:calc(var(--spectrum-global-dimension-size-50)*-1);opacity:0;position:absolute;right:calc(var(--spectrum-global-dimension-size-50)*-1);top:calc(var(--spectrum-global-dimension-size-50)*-1);transition:opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out}.fill{align-items:center;background-color:var(
|
|
55
|
+
--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)
|
|
56
|
+
);background-image:linear-gradient(-45deg,transparent 75.5%,var(
|
|
57
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
58
|
+
) 75.5%),linear-gradient(45deg,transparent 75.5%,var(
|
|
59
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
60
|
+
) 75.5%),linear-gradient(-45deg,var(
|
|
61
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
62
|
+
) 25.5%,transparent 25.5%),linear-gradient(45deg,var(
|
|
63
|
+
--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)
|
|
64
|
+
) 25.5%,transparent 25.5%);background-position:var(--spectrum-swatch-background-offset) var(--spectrum-swatch-background-offset),var(--spectrum-swatch-background-offset) calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)) calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)) var(--spectrum-swatch-background-offset);background-size:calc(var(--spectrum-swatch-checkerboard-size)*2) calc(var(--spectrum-swatch-checkerboard-size)*2);border-radius:var(--spectrum-swatch-border-radius);box-sizing:border-box;display:flex;height:100%;justify-content:center;overflow:hidden;position:relative;width:100%}.fill:before{background-color:var(--spectrum-picked-color,transparent);border-radius:var(--spectrum-swatch-border-radius);bottom:0;box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color);content:"";left:0;position:absolute;right:0;top:0;z-index:0}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color-light)}:host([border=none]) .fill:before{box-shadow:none}.mixedValueIcon{color:var(
|
|
65
|
+
--spectrum-global-color-gray-700
|
|
66
|
+
)}.disabledIcon,.mixedValueIcon{pointer-events:none;visibility:hidden}.disabledIcon{stroke:var(--spectrum-swatch-disabled-icon-stroke-color);color:var(--spectrum-swatch-disabled-icon-color);position:relative;z-index:2}:host([size=xs]){height:var(--spectrum-swatch-size-xs);width:var(--spectrum-swatch-size-xs)}:host([size=xs]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-xs);width:var(
|
|
67
|
+
--spectrum-swatch-disabled-icon-size-xs
|
|
68
|
+
)}:host([size=s]){height:var(--spectrum-swatch-size-s);width:var(--spectrum-swatch-size-s)}:host([size=s]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-s);width:var(
|
|
69
|
+
--spectrum-swatch-disabled-icon-size-s
|
|
70
|
+
)}:host([size=m]){height:var(--spectrum-swatch-size-m);width:var(--spectrum-swatch-size-m)}:host([size=m]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-m);width:var(
|
|
71
|
+
--spectrum-swatch-disabled-icon-size-m
|
|
72
|
+
)}:host([size=l]){height:var(--spectrum-swatch-size-l);width:var(--spectrum-swatch-size-l)}:host([size=l]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-l);width:var(
|
|
73
|
+
--spectrum-swatch-disabled-icon-size-l
|
|
74
|
+
)}:host([shape=rectangle][size=xs]){width:calc(var(--spectrum-swatch-size-xs)*2)}:host([shape=rectangle][size=s]){width:calc(var(--spectrum-swatch-size-s)*2)}:host([shape=rectangle][size=m]){width:calc(var(--spectrum-swatch-size-m)*2)}:host([shape=rectangle][size=l]){width:calc(var(--spectrum-swatch-size-l)*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before{border-radius:0}:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before,:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before{border-radius:100%}::slotted([slot=image]){height:100%;object-fit:contain;transition:width var(--spectrum-global-animation-duration-100,.13s) ease-in-out,height var(--spectrum-global-animation-duration-100,.13s) ease-in-out;width:100%}
|
|
75
|
+
`;
|
|
76
|
+
export default styles;
|
|
77
|
+
//# sourceMappingURL=swatch.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swatch.css.js","sourceRoot":"","sources":["swatch.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-swatch-size-xs:var(\n--spectrum-global-dimension-size-200\n);--spectrum-swatch-size-s:var(--spectrum-global-dimension-size-300);--spectrum-swatch-size-m:var(--spectrum-global-dimension-size-400);--spectrum-swatch-size-l:var(--spectrum-global-dimension-size-500);--spectrum-swatch-disabled-icon-size-xs:var(\n--spectrum-global-dimension-size-150\n);--spectrum-swatch-disabled-icon-size-s:var(\n--spectrum-global-dimension-size-200\n);--spectrum-swatch-disabled-icon-size-m:var(\n--spectrum-global-dimension-size-225\n);--spectrum-swatch-disabled-icon-size-l:var(\n--spectrum-global-dimension-size-250\n);--spectrum-swatch-disabled-icon-color:var(\n--spectrum-global-color-static-gray-50,rgb(var(--spectrum-global-color-static-gray-50-rgb))\n);--spectrum-swatch-disabled-icon-stroke-color:rgba(var(--spectrum-global-color-static-black-rgb,0,0,0),0.51);--spectrum-swatch-selection-padding:var(\n--spectrum-global-dimension-size-100\n);--spectrum-swatch-selection-indicator-border-width:var(\n--spectrum-global-dimension-size-25\n);--spectrum-swatch-selection-indicator-border-color:var(\n--spectrum-global-color-gray-900\n);--spectrum-swatch-background-color-selected:var(\n--spectrum-global-color-gray-50\n);--spectrum-swatch-border-radius:var(\n--spectrum-alias-border-radius-regular,var(--spectrum-global-dimension-size-50)\n);--spectrum-swatch-fill-border-radius-selected:var(\n--spectrum-alias-border-radius-small,var(--spectrum-global-dimension-size-25)\n);--spectrum-swatch-fill-border-width:var(\n--spectrum-alias-border-size-thin,var(--spectrum-global-dimension-static-size-10)\n);--spectrum-swatch-fill-border-color:rgba(var(--spectrum-global-color-gray-900-rgb),0.51);--spectrum-swatch-fill-border-color-light:rgba(var(--spectrum-global-color-gray-900-rgb),0.2);--spectrum-swatch-background-offset:0px;--spectrum-swatch-checkerboard-size:var(\n--spectrum-global-dimension-static-size-100,8px\n);align-items:center;display:flex;justify-content:center;outline:none;position:relative;-webkit-user-select:none;user-select:none}:host,:host:before{border-radius:var(\n--spectrum-swatch-border-radius\n)}:host([selected]){--spectrum-swatch-background-offset:-4px;background-color:var(\n--spectrum-swatch-background-color-selected\n)}:host([selected]) .fill{border-radius:var(--spectrum-swatch-fill-border-radius-selected);height:calc(100% - var(--spectrum-swatch-selection-padding));width:calc(100% - var(--spectrum-swatch-selection-padding))}:host([selected]) .fill:before{border-radius:var(\n--spectrum-swatch-fill-border-radius-selected\n);box-shadow:none}:host([selected]):before{opacity:1}:host([mixed-value]) .fill{background:var(\n--spectrum-swatch-background-color-selected\n)}:host([mixed-value]) .mixedValueIcon{visibility:visible}:host([nothing]) .fill{background:var(\n--spectrum-swatch-background-color-selected\n)}:host([nothing]) .fill:after{background:var(--spectrum-global-color-red-500);content:\"\";position:absolute;transform:rotate(-45deg);width:200%}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([nothing][size=xs]) .fill:after{height:2px}:host([nothing][size=s]) .fill:after{height:3px}:host([nothing][size=m]) .fill:after{height:4px}:host([nothing][size=l]) .fill:after{height:5px}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{visibility:visible}:host(.focus-visible):after{opacity:1}:host(:focus-visible):after{opacity:1}:host:before{border:var(--spectrum-swatch-selection-indicator-border-width) solid var(--spectrum-swatch-selection-indicator-border-color);bottom:0;content:\"\";left:0;opacity:0;pointer-events:none;position:absolute;right:0;top:0}:host:after{border:var(--spectrum-global-dimension-static-size-25,2px) solid var(\n--spectrum-alias-focus-ring-color,var(--spectrum-alias-focus-color)\n);border-radius:var(--spectrum-alias-focus-ring-border-radius-regular);bottom:calc(var(--spectrum-global-dimension-size-50)*-1);content:\"\";left:calc(var(--spectrum-global-dimension-size-50)*-1);opacity:0;position:absolute;right:calc(var(--spectrum-global-dimension-size-50)*-1);top:calc(var(--spectrum-global-dimension-size-50)*-1);transition:opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out}.fill{align-items:center;background-color:var(\n--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)\n);background-image:linear-gradient(-45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(-45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%),linear-gradient(45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%);background-position:var(--spectrum-swatch-background-offset) var(--spectrum-swatch-background-offset),var(--spectrum-swatch-background-offset) calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size) + var(--spectrum-swatch-background-offset)) calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)),calc(var(--spectrum-swatch-checkerboard-size)*-1 + var(--spectrum-swatch-background-offset)) var(--spectrum-swatch-background-offset);background-size:calc(var(--spectrum-swatch-checkerboard-size)*2) calc(var(--spectrum-swatch-checkerboard-size)*2);border-radius:var(--spectrum-swatch-border-radius);box-sizing:border-box;display:flex;height:100%;justify-content:center;overflow:hidden;position:relative;width:100%}.fill:before{background-color:var(--spectrum-picked-color,transparent);border-radius:var(--spectrum-swatch-border-radius);bottom:0;box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color);content:\"\";left:0;position:absolute;right:0;top:0;z-index:0}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--spectrum-swatch-fill-border-width) var(--spectrum-swatch-fill-border-color-light)}:host([border=none]) .fill:before{box-shadow:none}.mixedValueIcon{color:var(\n--spectrum-global-color-gray-700\n)}.disabledIcon,.mixedValueIcon{pointer-events:none;visibility:hidden}.disabledIcon{stroke:var(--spectrum-swatch-disabled-icon-stroke-color);color:var(--spectrum-swatch-disabled-icon-color);position:relative;z-index:2}:host([size=xs]){height:var(--spectrum-swatch-size-xs);width:var(--spectrum-swatch-size-xs)}:host([size=xs]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-xs);width:var(\n--spectrum-swatch-disabled-icon-size-xs\n)}:host([size=s]){height:var(--spectrum-swatch-size-s);width:var(--spectrum-swatch-size-s)}:host([size=s]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-s);width:var(\n--spectrum-swatch-disabled-icon-size-s\n)}:host([size=m]){height:var(--spectrum-swatch-size-m);width:var(--spectrum-swatch-size-m)}:host([size=m]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-m);width:var(\n--spectrum-swatch-disabled-icon-size-m\n)}:host([size=l]){height:var(--spectrum-swatch-size-l);width:var(--spectrum-swatch-size-l)}:host([size=l]) .disabledIcon{height:var(--spectrum-swatch-disabled-icon-size-l);width:var(\n--spectrum-swatch-disabled-icon-size-l\n)}:host([shape=rectangle][size=xs]){width:calc(var(--spectrum-swatch-size-xs)*2)}:host([shape=rectangle][size=s]){width:calc(var(--spectrum-swatch-size-s)*2)}:host([shape=rectangle][size=m]){width:calc(var(--spectrum-swatch-size-m)*2)}:host([shape=rectangle][size=l]){width:calc(var(--spectrum-swatch-size-l)*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before{border-radius:0}:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before,:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before{border-radius:100%}::slotted([slot=image]){height:100%;object-fit:contain;transition:width var(--spectrum-global-animation-duration-100,.13s) ease-in-out,height var(--spectrum-global-animation-duration-100,.13s) ease-in-out;width:100%}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { html } from '@spectrum-web-components/base';
|
|
13
|
+
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
|
|
14
|
+
import '../sp-swatch-group.js';
|
|
15
|
+
import '../sp-swatch.js';
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Swatch group',
|
|
18
|
+
component: 'sp-swatch-group',
|
|
19
|
+
args: {},
|
|
20
|
+
argTypes: {
|
|
21
|
+
border: {
|
|
22
|
+
name: 'border',
|
|
23
|
+
type: { name: 'string', required: false },
|
|
24
|
+
description: 'The border to apply to the Swatch children.',
|
|
25
|
+
table: {
|
|
26
|
+
defaultValue: { summary: '' },
|
|
27
|
+
},
|
|
28
|
+
control: {
|
|
29
|
+
type: 'inline-radio',
|
|
30
|
+
options: ['normal', 'light', 'none'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
density: {
|
|
34
|
+
name: 'density',
|
|
35
|
+
type: { name: 'string', required: false },
|
|
36
|
+
description: 'The density at which to display the Swatch children.',
|
|
37
|
+
table: {
|
|
38
|
+
defaultValue: { summary: '' },
|
|
39
|
+
},
|
|
40
|
+
control: {
|
|
41
|
+
type: 'inline-radio',
|
|
42
|
+
options: ['normal', 'compact', 'spacious'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
rounding: {
|
|
46
|
+
name: 'rounding',
|
|
47
|
+
type: { name: 'string', required: false },
|
|
48
|
+
description: 'The rounding to apply to the Swatch children.',
|
|
49
|
+
table: {
|
|
50
|
+
defaultValue: { summary: '' },
|
|
51
|
+
},
|
|
52
|
+
control: {
|
|
53
|
+
type: 'inline-radio',
|
|
54
|
+
options: ['normal', 'none', 'full'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
selects: {
|
|
58
|
+
name: 'selects',
|
|
59
|
+
type: { name: 'string', required: false },
|
|
60
|
+
description: 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',
|
|
61
|
+
table: {
|
|
62
|
+
defaultValue: { summary: '' },
|
|
63
|
+
},
|
|
64
|
+
control: {
|
|
65
|
+
type: 'inline-radio',
|
|
66
|
+
options: ['none', 'single', 'multiple'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
shape: {
|
|
70
|
+
name: 'shape',
|
|
71
|
+
type: { name: 'string', required: false },
|
|
72
|
+
description: 'The shape to apply to the Swatch children.',
|
|
73
|
+
table: {
|
|
74
|
+
defaultValue: { summary: '' },
|
|
75
|
+
},
|
|
76
|
+
control: {
|
|
77
|
+
type: 'inline-radio',
|
|
78
|
+
options: ['normal', 'rectangle'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
decorators: [
|
|
83
|
+
(story) => html `
|
|
84
|
+
<div
|
|
85
|
+
@change=${async (event) => {
|
|
86
|
+
await 0;
|
|
87
|
+
if (event.defaultPrevented)
|
|
88
|
+
return;
|
|
89
|
+
const next = event.target
|
|
90
|
+
.nextElementSibling;
|
|
91
|
+
next.textContent = `Selected: ${JSON.stringify(event.target.selected)}`;
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
${story()}
|
|
95
|
+
<div>Selected: []</div>
|
|
96
|
+
</div>
|
|
97
|
+
`,
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
const colors = [
|
|
101
|
+
'--spectrum-global-color-gray-500',
|
|
102
|
+
'--spectrum-global-color-red-500',
|
|
103
|
+
'--spectrum-global-color-orange-500',
|
|
104
|
+
'--spectrum-global-color-yellow-500',
|
|
105
|
+
'--spectrum-global-color-chartreuse-500',
|
|
106
|
+
'--spectrum-global-color-celery-500',
|
|
107
|
+
'--spectrum-global-color-green-500',
|
|
108
|
+
'--spectrum-global-color-seafoam-500',
|
|
109
|
+
'--spectrum-global-color-blue-500',
|
|
110
|
+
'--spectrum-global-color-indigo-500',
|
|
111
|
+
'--spectrum-global-color-purple-500',
|
|
112
|
+
'--spectrum-global-color-fuchsia-500',
|
|
113
|
+
'--spectrum-global-color-magenta-500',
|
|
114
|
+
];
|
|
115
|
+
const template = ({ border, density, rounding, selects, selected = [], shape, }) => {
|
|
116
|
+
const groupLabel = !!selects
|
|
117
|
+
? selects === 'single'
|
|
118
|
+
? 'Select a color'
|
|
119
|
+
: 'Selects color(s)'
|
|
120
|
+
: undefined;
|
|
121
|
+
return html `
|
|
122
|
+
<sp-swatch-group
|
|
123
|
+
border=${ifDefined(border === 'normal' ? undefined : border)}
|
|
124
|
+
density=${ifDefined(density === 'normal' ? undefined : density)}
|
|
125
|
+
rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}
|
|
126
|
+
selects=${ifDefined(selects === 'none' ? undefined : selects)}
|
|
127
|
+
.selected=${selected}
|
|
128
|
+
shape=${ifDefined(shape === 'normal' ? undefined : shape)}
|
|
129
|
+
aria-label=${ifDefined(groupLabel)}
|
|
130
|
+
>
|
|
131
|
+
${colors.map((color) => html `
|
|
132
|
+
<sp-swatch
|
|
133
|
+
color="var(${color})"
|
|
134
|
+
label=${color}
|
|
135
|
+
value=${color}
|
|
136
|
+
></sp-swatch>
|
|
137
|
+
`)}
|
|
138
|
+
</sp-swatch-group>
|
|
139
|
+
`;
|
|
140
|
+
};
|
|
141
|
+
export const Default = (args) => template(args);
|
|
142
|
+
Default.args = {};
|
|
143
|
+
export const densityCompact = (args) => template(args);
|
|
144
|
+
densityCompact.args = {
|
|
145
|
+
density: 'compact',
|
|
146
|
+
};
|
|
147
|
+
export const densitySpacious = (args) => template(args);
|
|
148
|
+
densitySpacious.args = {
|
|
149
|
+
density: 'spacious',
|
|
150
|
+
};
|
|
151
|
+
export const selectsSingle = (args) => template(args);
|
|
152
|
+
selectsSingle.args = {
|
|
153
|
+
selects: 'single',
|
|
154
|
+
selected: ['--spectrum-global-color-yellow-500'],
|
|
155
|
+
};
|
|
156
|
+
export const selectsMultiple = (args) => template(args);
|
|
157
|
+
selectsMultiple.args = {
|
|
158
|
+
selects: 'multiple',
|
|
159
|
+
selected: [
|
|
160
|
+
'--spectrum-global-color-celery-500',
|
|
161
|
+
'--spectrum-global-color-red-500',
|
|
162
|
+
'--spectrum-global-color-purple-500',
|
|
163
|
+
'--spectrum-global-color-blue-500',
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
export const borderLight = (args) => template(args);
|
|
167
|
+
borderLight.args = {
|
|
168
|
+
border: 'light',
|
|
169
|
+
};
|
|
170
|
+
export const borderNone = (args) => template(args);
|
|
171
|
+
borderNone.args = {
|
|
172
|
+
border: 'none',
|
|
173
|
+
};
|
|
174
|
+
export const roundingNone = (args) => template(args);
|
|
175
|
+
roundingNone.args = {
|
|
176
|
+
rounding: 'none',
|
|
177
|
+
};
|
|
178
|
+
export const roundingFull = (args) => template(args);
|
|
179
|
+
roundingFull.args = {
|
|
180
|
+
rounding: 'full',
|
|
181
|
+
};
|
|
182
|
+
export const shapeRectangle = (args) => template(args);
|
|
183
|
+
shapeRectangle.args = {
|
|
184
|
+
shape: 'rectangle',
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=swatch-group.stories.js.map
|