@spectrum-web-components/swatch 0.1.2 → 0.1.3-devmode.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 +33 -13
- package/sp-swatch-group.dev.js +3 -0
- package/sp-swatch-group.dev.js.map +7 -0
- package/sp-swatch-group.js +3 -14
- package/sp-swatch-group.js.map +7 -1
- package/sp-swatch.dev.js +3 -0
- package/sp-swatch.dev.js.map +7 -0
- package/sp-swatch.js +3 -14
- package/sp-swatch.js.map +7 -1
- package/src/Swatch.dev.js +219 -0
- package/src/Swatch.dev.js.map +7 -0
- package/src/Swatch.js +165 -170
- package/src/Swatch.js.map +7 -1
- package/src/SwatchGroup.dev.js +220 -0
- package/src/SwatchGroup.dev.js.map +7 -0
- package/src/SwatchGroup.js +201 -216
- package/src/SwatchGroup.js.map +7 -1
- package/src/index.dev.js +3 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +3 -14
- package/src/index.js.map +7 -1
- package/src/spectrum-swatch-group.css.dev.js +10 -0
- package/src/spectrum-swatch-group.css.dev.js.map +7 -0
- package/src/spectrum-swatch-group.css.js +3 -14
- package/src/spectrum-swatch-group.css.js.map +7 -1
- package/src/spectrum-swatch.css.dev.js +66 -0
- package/src/spectrum-swatch.css.dev.js.map +7 -0
- package/src/spectrum-swatch.css.js +3 -14
- package/src/spectrum-swatch.css.js.map +7 -1
- package/src/swatch-group.css.dev.js +10 -0
- package/src/swatch-group.css.dev.js.map +7 -0
- package/src/swatch-group.css.js +3 -14
- package/src/swatch-group.css.js.map +7 -1
- package/src/swatch.css.dev.js +66 -0
- package/src/swatch.css.dev.js.map +7 -0
- package/src/swatch.css.js +3 -14
- package/src/swatch.css.js.map +7 -1
- package/stories/swatch-group.stories.js +124 -133
- package/stories/swatch-group.stories.js.map +7 -1
- package/stories/swatch-sizes.stories.js +15 -21
- package/stories/swatch-sizes.stories.js.map +7 -1
- package/stories/swatch.stories.js +69 -73
- package/stories/swatch.stories.js.map +7 -1
- package/test/benchmark/basic-test.js +5 -16
- package/test/benchmark/basic-test.js.map +7 -1
- package/test/swatch-group.test-vrt.js +4 -15
- package/test/swatch-group.test-vrt.js.map +7 -1
- package/test/swatch-group.test.js +229 -240
- package/test/swatch-group.test.js.map +7 -1
- package/test/swatch-sizes.test-vrt.js +4 -15
- package/test/swatch-sizes.test-vrt.js.map +7 -1
- package/test/swatch.test-vrt.js +4 -15
- package/test/swatch.test-vrt.js.map +7 -1
- package/test/swatch.test.js +124 -135
- package/test/swatch.test.js.map +7 -1
|
@@ -1,134 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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';
|
|
1
|
+
import { html } from "@spectrum-web-components/base";
|
|
2
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
3
|
+
import "../sp-swatch-group.js";
|
|
4
|
+
import "../sp-swatch.js";
|
|
16
5
|
export default {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
},
|
|
6
|
+
title: "Swatch group",
|
|
7
|
+
component: "sp-swatch-group",
|
|
8
|
+
args: {},
|
|
9
|
+
argTypes: {
|
|
10
|
+
border: {
|
|
11
|
+
name: "border",
|
|
12
|
+
type: { name: "string", required: false },
|
|
13
|
+
description: "The border to apply to the Swatch children.",
|
|
14
|
+
table: {
|
|
15
|
+
defaultValue: { summary: "" }
|
|
16
|
+
},
|
|
17
|
+
control: {
|
|
18
|
+
type: "inline-radio",
|
|
19
|
+
options: ["normal", "light", "none"]
|
|
20
|
+
}
|
|
81
21
|
},
|
|
82
|
-
|
|
83
|
-
|
|
22
|
+
density: {
|
|
23
|
+
name: "density",
|
|
24
|
+
type: { name: "string", required: false },
|
|
25
|
+
description: "The density at which to display the Swatch children.",
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: { summary: "" }
|
|
28
|
+
},
|
|
29
|
+
control: {
|
|
30
|
+
type: "inline-radio",
|
|
31
|
+
options: ["normal", "compact", "spacious"]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
rounding: {
|
|
35
|
+
name: "rounding",
|
|
36
|
+
type: { name: "string", required: false },
|
|
37
|
+
description: "The rounding to apply to the Swatch children.",
|
|
38
|
+
table: {
|
|
39
|
+
defaultValue: { summary: "" }
|
|
40
|
+
},
|
|
41
|
+
control: {
|
|
42
|
+
type: "inline-radio",
|
|
43
|
+
options: ["normal", "none", "full"]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
selects: {
|
|
47
|
+
name: "selects",
|
|
48
|
+
type: { name: "string", required: false },
|
|
49
|
+
description: "Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.",
|
|
50
|
+
table: {
|
|
51
|
+
defaultValue: { summary: "" }
|
|
52
|
+
},
|
|
53
|
+
control: {
|
|
54
|
+
type: "inline-radio",
|
|
55
|
+
options: ["none", "single", "multiple"]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
shape: {
|
|
59
|
+
name: "shape",
|
|
60
|
+
type: { name: "string", required: false },
|
|
61
|
+
description: "The shape to apply to the Swatch children.",
|
|
62
|
+
table: {
|
|
63
|
+
defaultValue: { summary: "" }
|
|
64
|
+
},
|
|
65
|
+
control: {
|
|
66
|
+
type: "inline-radio",
|
|
67
|
+
options: ["normal", "rectangle"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
decorators: [
|
|
72
|
+
(story) => html`
|
|
84
73
|
<div
|
|
85
74
|
@change=${async (event) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}}
|
|
75
|
+
await 0;
|
|
76
|
+
if (event.defaultPrevented)
|
|
77
|
+
return;
|
|
78
|
+
const next = event.target.nextElementSibling;
|
|
79
|
+
next.textContent = `Selected: ${JSON.stringify(event.target.selected)}`;
|
|
80
|
+
}}
|
|
93
81
|
>
|
|
94
82
|
${story()}
|
|
95
83
|
<div>Selected: []</div>
|
|
96
84
|
</div>
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
`
|
|
86
|
+
]
|
|
99
87
|
};
|
|
100
88
|
const colors = [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
89
|
+
"--spectrum-global-color-gray-500",
|
|
90
|
+
"--spectrum-global-color-red-500",
|
|
91
|
+
"--spectrum-global-color-orange-500",
|
|
92
|
+
"--spectrum-global-color-yellow-500",
|
|
93
|
+
"--spectrum-global-color-chartreuse-500",
|
|
94
|
+
"--spectrum-global-color-celery-500",
|
|
95
|
+
"--spectrum-global-color-green-500",
|
|
96
|
+
"--spectrum-global-color-seafoam-500",
|
|
97
|
+
"--spectrum-global-color-blue-500",
|
|
98
|
+
"--spectrum-global-color-indigo-500",
|
|
99
|
+
"--spectrum-global-color-purple-500",
|
|
100
|
+
"--spectrum-global-color-fuchsia-500",
|
|
101
|
+
"--spectrum-global-color-magenta-500"
|
|
114
102
|
];
|
|
115
|
-
const template = ({
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
const template = ({
|
|
104
|
+
border,
|
|
105
|
+
density,
|
|
106
|
+
rounding,
|
|
107
|
+
selects,
|
|
108
|
+
selected = [],
|
|
109
|
+
shape
|
|
110
|
+
}) => {
|
|
111
|
+
const groupLabel = !!selects ? selects === "single" ? "Select a color" : "Selects color(s)" : void 0;
|
|
112
|
+
return html`
|
|
122
113
|
<sp-swatch-group
|
|
123
|
-
border=${ifDefined(border ===
|
|
124
|
-
density=${ifDefined(density ===
|
|
125
|
-
rounding=${ifDefined(rounding ===
|
|
126
|
-
selects=${ifDefined(selects ===
|
|
114
|
+
border=${ifDefined(border === "normal" ? void 0 : border)}
|
|
115
|
+
density=${ifDefined(density === "normal" ? void 0 : density)}
|
|
116
|
+
rounding=${ifDefined(rounding === "normal" ? void 0 : rounding)}
|
|
117
|
+
selects=${ifDefined(selects === "none" ? void 0 : selects)}
|
|
127
118
|
.selected=${selected}
|
|
128
|
-
shape=${ifDefined(shape ===
|
|
119
|
+
shape=${ifDefined(shape === "normal" ? void 0 : shape)}
|
|
129
120
|
aria-label=${ifDefined(groupLabel)}
|
|
130
121
|
>
|
|
131
|
-
${colors.map((color) => html
|
|
122
|
+
${colors.map((color) => html`
|
|
132
123
|
<sp-swatch
|
|
133
124
|
color="var(${color})"
|
|
134
125
|
label=${color}
|
|
@@ -142,45 +133,45 @@ export const Default = (args) => template(args);
|
|
|
142
133
|
Default.args = {};
|
|
143
134
|
export const densityCompact = (args) => template(args);
|
|
144
135
|
densityCompact.args = {
|
|
145
|
-
|
|
136
|
+
density: "compact"
|
|
146
137
|
};
|
|
147
138
|
export const densitySpacious = (args) => template(args);
|
|
148
139
|
densitySpacious.args = {
|
|
149
|
-
|
|
140
|
+
density: "spacious"
|
|
150
141
|
};
|
|
151
142
|
export const selectsSingle = (args) => template(args);
|
|
152
143
|
selectsSingle.args = {
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
selects: "single",
|
|
145
|
+
selected: ["--spectrum-global-color-yellow-500"]
|
|
155
146
|
};
|
|
156
147
|
export const selectsMultiple = (args) => template(args);
|
|
157
148
|
selectsMultiple.args = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
149
|
+
selects: "multiple",
|
|
150
|
+
selected: [
|
|
151
|
+
"--spectrum-global-color-celery-500",
|
|
152
|
+
"--spectrum-global-color-red-500",
|
|
153
|
+
"--spectrum-global-color-purple-500",
|
|
154
|
+
"--spectrum-global-color-blue-500"
|
|
155
|
+
]
|
|
165
156
|
};
|
|
166
157
|
export const borderLight = (args) => template(args);
|
|
167
158
|
borderLight.args = {
|
|
168
|
-
|
|
159
|
+
border: "light"
|
|
169
160
|
};
|
|
170
161
|
export const borderNone = (args) => template(args);
|
|
171
162
|
borderNone.args = {
|
|
172
|
-
|
|
163
|
+
border: "none"
|
|
173
164
|
};
|
|
174
165
|
export const roundingNone = (args) => template(args);
|
|
175
166
|
roundingNone.args = {
|
|
176
|
-
|
|
167
|
+
rounding: "none"
|
|
177
168
|
};
|
|
178
169
|
export const roundingFull = (args) => template(args);
|
|
179
170
|
roundingFull.args = {
|
|
180
|
-
|
|
171
|
+
rounding: "full"
|
|
181
172
|
};
|
|
182
173
|
export const shapeRectangle = (args) => template(args);
|
|
183
174
|
shapeRectangle.args = {
|
|
184
|
-
|
|
175
|
+
shape: "rectangle"
|
|
185
176
|
};
|
|
186
|
-
//# sourceMappingURL=swatch-group.stories.js.map
|
|
177
|
+
//# sourceMappingURL=swatch-group.stories.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"swatch-group.stories.js","sourceRoot":"","sources":["swatch-group.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAE5E,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AAiBzB,eAAe;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AAM;CACL,CAAC;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAgB,EAAkB,EAAE,CAC/D,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,cAAc,CAAC,IAAI,GAAG;IAClB,KAAK,EAAE,WAAW;CACP,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 { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '../sp-swatch-group.js';\nimport '../sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\nimport { SwatchGroup } from '../src/SwatchGroup.js';\n\ntype Properties = {\n border: SwatchBorder | 'normal';\n density?: 'normal' | 'spacious' | 'compact';\n rounding?: SwatchRounding | 'normal';\n selected?: string[];\n selects?: 'none' | 'single' | 'multiple';\n shape?: SwatchShape | 'normal';\n};\n\nexport default {\n title: 'Swatch group',\n component: 'sp-swatch-group',\n args: {},\n argTypes: {\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'compact', 'spacious'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n selects: {\n name: 'selects',\n type: { name: 'string', required: false },\n description:\n 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['none', 'single', 'multiple'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n decorators: [\n (story: () => TemplateResult): TemplateResult => html`\n <div\n @change=${async (event: Event & { target: SwatchGroup }) => {\n await 0;\n if (event.defaultPrevented) return;\n const next = event.target\n .nextElementSibling as HTMLDivElement;\n next.textContent = `Selected: ${JSON.stringify(\n event.target.selected\n )}`;\n }}\n >\n ${story()}\n <div>Selected: []</div>\n </div>\n `,\n ],\n};\n\nconst colors = [\n '--spectrum-global-color-gray-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-orange-500',\n '--spectrum-global-color-yellow-500',\n '--spectrum-global-color-chartreuse-500',\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-green-500',\n '--spectrum-global-color-seafoam-500',\n '--spectrum-global-color-blue-500',\n '--spectrum-global-color-indigo-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-fuchsia-500',\n '--spectrum-global-color-magenta-500',\n];\n\nconst template = ({\n border,\n density,\n rounding,\n selects,\n selected = [],\n shape,\n}: Properties): TemplateResult => {\n const groupLabel = !!selects\n ? selects === 'single'\n ? 'Select a color'\n : 'Selects color(s)'\n : undefined;\n return html`\n <sp-swatch-group\n border=${ifDefined(border === 'normal' ? undefined : border)}\n density=${ifDefined(density === 'normal' ? undefined : density)}\n rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}\n selects=${ifDefined(selects === 'none' ? undefined : selects)}\n .selected=${selected}\n shape=${ifDefined(shape === 'normal' ? undefined : shape)}\n aria-label=${ifDefined(groupLabel)}\n >\n ${colors.map(\n (color) => html`\n <sp-swatch\n color=\"var(${color})\"\n label=${color}\n value=${color}\n ></sp-swatch>\n `\n )}\n </sp-swatch-group>\n `;\n};\n\nexport const Default = (args: Properties): TemplateResult => template(args);\nDefault.args = {} as Properties;\nexport const densityCompact = (args: Properties): TemplateResult =>\n template(args);\ndensityCompact.args = {\n density: 'compact',\n} as Properties;\nexport const densitySpacious = (args: Properties): TemplateResult =>\n template(args);\ndensitySpacious.args = {\n density: 'spacious',\n} as Properties;\nexport const selectsSingle = (args: Properties): TemplateResult =>\n template(args);\nselectsSingle.args = {\n selects: 'single',\n selected: ['--spectrum-global-color-yellow-500'],\n} as Properties;\nexport const selectsMultiple = (args: Properties): TemplateResult =>\n template(args);\nselectsMultiple.args = {\n selects: 'multiple',\n selected: [\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-blue-500',\n ],\n} as Properties;\nexport const borderLight = (args: Properties): TemplateResult => template(args);\nborderLight.args = {\n border: 'light',\n} as Properties;\nexport const borderNone = (args: Properties): TemplateResult => template(args);\nborderNone.args = {\n border: 'none',\n} as Properties;\nexport const roundingNone = (args: Properties): TemplateResult =>\n template(args);\nroundingNone.args = {\n rounding: 'none',\n} as Properties;\nexport const roundingFull = (args: Properties): TemplateResult =>\n template(args);\nroundingFull.args = {\n rounding: 'full',\n} as Properties;\nexport const shapeRectangle = (args: Properties): TemplateResult =>\n template(args);\nshapeRectangle.args = {\n shape: 'rectangle',\n} as Properties;\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["swatch-group.stories.ts"],
|
|
4
|
+
"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 { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '../sp-swatch-group.js';\nimport '../sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\nimport { SwatchGroup } from '../src/SwatchGroup.js';\n\ntype Properties = {\n border: SwatchBorder | 'normal';\n density?: 'normal' | 'spacious' | 'compact';\n rounding?: SwatchRounding | 'normal';\n selected?: string[];\n selects?: 'none' | 'single' | 'multiple';\n shape?: SwatchShape | 'normal';\n};\n\nexport default {\n title: 'Swatch group',\n component: 'sp-swatch-group',\n args: {},\n argTypes: {\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'compact', 'spacious'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n selects: {\n name: 'selects',\n type: { name: 'string', required: false },\n description:\n 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['none', 'single', 'multiple'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n decorators: [\n (story: () => TemplateResult): TemplateResult => html`\n <div\n @change=${async (event: Event & { target: SwatchGroup }) => {\n await 0;\n if (event.defaultPrevented) return;\n const next = event.target\n .nextElementSibling as HTMLDivElement;\n next.textContent = `Selected: ${JSON.stringify(\n event.target.selected\n )}`;\n }}\n >\n ${story()}\n <div>Selected: []</div>\n </div>\n `,\n ],\n};\n\nconst colors = [\n '--spectrum-global-color-gray-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-orange-500',\n '--spectrum-global-color-yellow-500',\n '--spectrum-global-color-chartreuse-500',\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-green-500',\n '--spectrum-global-color-seafoam-500',\n '--spectrum-global-color-blue-500',\n '--spectrum-global-color-indigo-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-fuchsia-500',\n '--spectrum-global-color-magenta-500',\n];\n\nconst template = ({\n border,\n density,\n rounding,\n selects,\n selected = [],\n shape,\n}: Properties): TemplateResult => {\n const groupLabel = !!selects\n ? selects === 'single'\n ? 'Select a color'\n : 'Selects color(s)'\n : undefined;\n return html`\n <sp-swatch-group\n border=${ifDefined(border === 'normal' ? undefined : border)}\n density=${ifDefined(density === 'normal' ? undefined : density)}\n rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}\n selects=${ifDefined(selects === 'none' ? undefined : selects)}\n .selected=${selected}\n shape=${ifDefined(shape === 'normal' ? undefined : shape)}\n aria-label=${ifDefined(groupLabel)}\n >\n ${colors.map(\n (color) => html`\n <sp-swatch\n color=\"var(${color})\"\n label=${color}\n value=${color}\n ></sp-swatch>\n `\n )}\n </sp-swatch-group>\n `;\n};\n\nexport const Default = (args: Properties): TemplateResult => template(args);\nDefault.args = {} as Properties;\nexport const densityCompact = (args: Properties): TemplateResult =>\n template(args);\ndensityCompact.args = {\n density: 'compact',\n} as Properties;\nexport const densitySpacious = (args: Properties): TemplateResult =>\n template(args);\ndensitySpacious.args = {\n density: 'spacious',\n} as Properties;\nexport const selectsSingle = (args: Properties): TemplateResult =>\n template(args);\nselectsSingle.args = {\n selects: 'single',\n selected: ['--spectrum-global-color-yellow-500'],\n} as Properties;\nexport const selectsMultiple = (args: Properties): TemplateResult =>\n template(args);\nselectsMultiple.args = {\n selects: 'multiple',\n selected: [\n '--spectrum-global-color-celery-500',\n '--spectrum-global-color-red-500',\n '--spectrum-global-color-purple-500',\n '--spectrum-global-color-blue-500',\n ],\n} as Properties;\nexport const borderLight = (args: Properties): TemplateResult => template(args);\nborderLight.args = {\n border: 'light',\n} as Properties;\nexport const borderNone = (args: Properties): TemplateResult => template(args);\nborderNone.args = {\n border: 'none',\n} as Properties;\nexport const roundingNone = (args: Properties): TemplateResult =>\n template(args);\nroundingNone.args = {\n rounding: 'none',\n} as Properties;\nexport const roundingFull = (args: Properties): TemplateResult =>\n template(args);\nroundingFull.args = {\n rounding: 'full',\n} as Properties;\nexport const shapeRectangle = (args: Properties): TemplateResult =>\n template(args);\nshapeRectangle.args = {\n shape: 'rectangle',\n} as Properties;\n"],
|
|
5
|
+
"mappings": "AAWA;AACA;AAEA;AACA;AAiBA,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,UAAU;AAAA,IACN,QAAQ;AAAA,MACJ,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,MACxC,aAAa;AAAA,MACb,OAAO;AAAA,QACH,cAAc,EAAE,SAAS,GAAG;AAAA,MAChC;AAAA,MACA,SAAS;AAAA,QACL,MAAM;AAAA,QACN,SAAS,CAAC,UAAU,SAAS,MAAM;AAAA,MACvC;AAAA,IACJ;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,MACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,MACxC,aAAa;AAAA,MACb,OAAO;AAAA,QACH,cAAc,EAAE,SAAS,GAAG;AAAA,MAChC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I;AAC9E,YAAY,OAAO;AAAA,EACf,QAAQ;AACZ;AACO,aAAM,aAAa,CAAC,SAAqC,SAAS,IAAI;AAC7E,WAAW,OAAO;AAAA,EACd,QAAQ;AACZ;AACO,aAAM,eAAe,CAAC,SACzB,SAAS,IAAI;AACjB,aAAa,OAAO;AAAA,EAChB,UAAU;AACd;AACO,aAAM,eAAe,CAAC,SACzB,SAAS,IAAI;AACjB,aAAa,OAAO;AAAA,EAChB,UAAU;AACd;AACO,aAAM,iBAAiB,CAAC,SAC3B,SAAS,IAAI;AACjB,eAAe,OAAO;AAAA,EAClB,OAAO;AACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 '../sp-swatch.js';
|
|
1
|
+
import {
|
|
2
|
+
html
|
|
3
|
+
} from "@spectrum-web-components/base";
|
|
4
|
+
import "../sp-swatch.js";
|
|
14
5
|
export default {
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
title: "Swatch/Sizes",
|
|
7
|
+
component: "sp-swatch"
|
|
17
8
|
};
|
|
18
|
-
const template = ({
|
|
9
|
+
const template = ({
|
|
10
|
+
size,
|
|
11
|
+
color = "rgb(255 0 0 / 0.7)"
|
|
12
|
+
}) => html`
|
|
19
13
|
<div style="display: flex; gap: 5px;">
|
|
20
14
|
<sp-swatch color=${color} size=${size}></sp-swatch>
|
|
21
15
|
<sp-swatch color=${color} rounding="none" size=${size}></sp-swatch>
|
|
@@ -38,8 +32,8 @@ const template = ({ size, color = 'rgb(255 0 0 / 0.7)', }) => html `
|
|
|
38
32
|
></sp-swatch>
|
|
39
33
|
</div>
|
|
40
34
|
`;
|
|
41
|
-
export const XS = () => template({ size:
|
|
42
|
-
export const s = () => template({ size:
|
|
43
|
-
export const m = () => template({ size:
|
|
44
|
-
export const l = () => template({ size:
|
|
45
|
-
//# sourceMappingURL=swatch-sizes.stories.js.map
|
|
35
|
+
export const XS = () => template({ size: "xs" });
|
|
36
|
+
export const s = () => template({ size: "s" });
|
|
37
|
+
export const m = () => template({ size: "m" });
|
|
38
|
+
export const l = () => template({ size: "l" });
|
|
39
|
+
//# sourceMappingURL=swatch-sizes.stories.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["swatch-sizes.stories.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 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 {\n ElementSize,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\n\nimport '../sp-swatch.js';\n\nexport default {\n title: 'Swatch/Sizes',\n component: 'sp-swatch',\n};\n\nconst template = ({\n size,\n color = 'rgb(255 0 0 / 0.7)',\n}: {\n size: ElementSize;\n color?: string;\n}): TemplateResult => html`\n <div style=\"display: flex; gap: 5px;\">\n <sp-swatch color=${color} size=${size}></sp-swatch>\n <sp-swatch color=${color} rounding=\"none\" size=${size}></sp-swatch>\n <sp-swatch color=${color} rounding=\"full\" size=${size}></sp-swatch>\n <sp-swatch color=${color} border=\"light\" size=${size}></sp-swatch>\n <sp-swatch color=${color} border=\"none\" size=${size}></sp-swatch>\n <sp-swatch nothing size=${size}></sp-swatch>\n <sp-swatch color=${color} shape=\"rectangle\" size=${size}></sp-swatch>\n <sp-swatch\n color=${color}\n shape=\"rectangle\"\n size=${size}\n disabled\n ></sp-swatch>\n <sp-swatch\n rounding=\"full\"\n shape=\"rectangle\"\n size=${size}\n mixed-value\n ></sp-swatch>\n </div>\n`;\n\nexport const XS = (): TemplateResult => template({ size: 'xs' });\n\nexport const s = (): TemplateResult => template({ size: 's' });\n\nexport const m = (): TemplateResult => template({ size: 'm' });\n\nexport const l = (): TemplateResult => template({ size: 'l' });\n"],
|
|
5
|
+
"mappings": "AAWA;AAAA;AAAA;AAMA;AAEA,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAEA,MAAM,WAAW,CAAC;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,MAIU;AAAA;AAAA,2BAEK,cAAc;AAAA,2BACd,8BAA8B;AAAA,2BAC9B,8BAA8B;AAAA,2BAC9B,6BAA6B;AAAA,2BAC7B,4BAA4B;AAAA,kCACrB;AAAA,2BACP,gCAAgC;AAAA;AAAA,oBAEvC;AAAA;AAAA,mBAED;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAMA;AAAA;AAAA;AAAA;AAAA;AAMZ,aAAM,KAAK,MAAsB,SAAS,EAAE,MAAM,KAAK,CAAC;AAExD,aAAM,IAAI,MAAsB,SAAS,EAAE,MAAM,IAAI,CAAC;AAEtD,aAAM,IAAI,MAAsB,SAAS,EAAE,MAAM,IAAI,CAAC;AAEtD,aAAM,IAAI,MAAsB,SAAS,EAAE,MAAM,IAAI,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,104 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.js';
|
|
1
|
+
import { html } from "@spectrum-web-components/base";
|
|
2
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
3
|
+
import "../sp-swatch.js";
|
|
15
4
|
export default {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
title: "Swatch",
|
|
6
|
+
component: "sp-swatch",
|
|
7
|
+
args: {
|
|
8
|
+
color: "#ff0000"
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
color: { control: "color" },
|
|
12
|
+
border: {
|
|
13
|
+
name: "border",
|
|
14
|
+
type: { name: "string", required: false },
|
|
15
|
+
description: "The border to apply to the Swatch children.",
|
|
16
|
+
table: {
|
|
17
|
+
defaultValue: { summary: "" }
|
|
18
|
+
},
|
|
19
|
+
control: {
|
|
20
|
+
type: "inline-radio",
|
|
21
|
+
options: ["normal", "light", "none"]
|
|
22
|
+
}
|
|
20
23
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
options: ['normal', 'light', 'none'],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
rounding: {
|
|
36
|
-
name: 'rounding',
|
|
37
|
-
type: { name: 'string', required: false },
|
|
38
|
-
description: 'The rounding to apply to the Swatch children.',
|
|
39
|
-
table: {
|
|
40
|
-
defaultValue: { summary: '' },
|
|
41
|
-
},
|
|
42
|
-
control: {
|
|
43
|
-
type: 'inline-radio',
|
|
44
|
-
options: ['normal', 'none', 'full'],
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
shape: {
|
|
48
|
-
name: 'shape',
|
|
49
|
-
type: { name: 'string', required: false },
|
|
50
|
-
description: 'The shape to apply to the Swatch children.',
|
|
51
|
-
table: {
|
|
52
|
-
defaultValue: { summary: '' },
|
|
53
|
-
},
|
|
54
|
-
control: {
|
|
55
|
-
type: 'inline-radio',
|
|
56
|
-
options: ['normal', 'rectangle'],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
24
|
+
rounding: {
|
|
25
|
+
name: "rounding",
|
|
26
|
+
type: { name: "string", required: false },
|
|
27
|
+
description: "The rounding to apply to the Swatch children.",
|
|
28
|
+
table: {
|
|
29
|
+
defaultValue: { summary: "" }
|
|
30
|
+
},
|
|
31
|
+
control: {
|
|
32
|
+
type: "inline-radio",
|
|
33
|
+
options: ["normal", "none", "full"]
|
|
34
|
+
}
|
|
59
35
|
},
|
|
36
|
+
shape: {
|
|
37
|
+
name: "shape",
|
|
38
|
+
type: { name: "string", required: false },
|
|
39
|
+
description: "The shape to apply to the Swatch children.",
|
|
40
|
+
table: {
|
|
41
|
+
defaultValue: { summary: "" }
|
|
42
|
+
},
|
|
43
|
+
control: {
|
|
44
|
+
type: "inline-radio",
|
|
45
|
+
options: ["normal", "rectangle"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
60
49
|
};
|
|
61
|
-
const template = ({
|
|
62
|
-
|
|
50
|
+
const template = ({
|
|
51
|
+
color,
|
|
52
|
+
border,
|
|
53
|
+
rounding,
|
|
54
|
+
shape,
|
|
55
|
+
mixedValue: mixedValue2,
|
|
56
|
+
nothing: nothing2
|
|
57
|
+
}) => {
|
|
58
|
+
return html`
|
|
63
59
|
<sp-swatch
|
|
64
|
-
border=${ifDefined(border ===
|
|
65
|
-
rounding=${ifDefined(rounding ===
|
|
66
|
-
shape=${ifDefined(shape ===
|
|
60
|
+
border=${ifDefined(border === "normal" ? void 0 : border)}
|
|
61
|
+
rounding=${ifDefined(rounding === "normal" ? void 0 : rounding)}
|
|
62
|
+
shape=${ifDefined(shape === "normal" ? void 0 : shape)}
|
|
67
63
|
color=${color}
|
|
68
|
-
?mixed-value=${
|
|
69
|
-
?nothing=${
|
|
64
|
+
?mixed-value=${mixedValue2}
|
|
65
|
+
?nothing=${nothing2}
|
|
70
66
|
></sp-swatch>
|
|
71
67
|
`;
|
|
72
68
|
};
|
|
73
69
|
export const Default = (args) => template(args);
|
|
74
70
|
export const mixedValue = (args) => template(args);
|
|
75
71
|
mixedValue.args = {
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
mixedValue: true,
|
|
73
|
+
color: ""
|
|
78
74
|
};
|
|
79
75
|
export const nothing = (args) => template(args);
|
|
80
76
|
nothing.args = {
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
nothing: true,
|
|
78
|
+
color: ""
|
|
83
79
|
};
|
|
84
80
|
export const borderLight = (args) => template(args);
|
|
85
81
|
borderLight.args = {
|
|
86
|
-
|
|
82
|
+
border: "light"
|
|
87
83
|
};
|
|
88
84
|
export const borderNone = (args) => template(args);
|
|
89
85
|
borderNone.args = {
|
|
90
|
-
|
|
86
|
+
border: "none"
|
|
91
87
|
};
|
|
92
88
|
export const roundingNone = (args) => template(args);
|
|
93
89
|
roundingNone.args = {
|
|
94
|
-
|
|
90
|
+
rounding: "none"
|
|
95
91
|
};
|
|
96
92
|
export const roundingFull = (args) => template(args);
|
|
97
93
|
roundingFull.args = {
|
|
98
|
-
|
|
94
|
+
rounding: "full"
|
|
99
95
|
};
|
|
100
96
|
export const shapeRectangle = (args) => template(args);
|
|
101
97
|
shapeRectangle.args = {
|
|
102
|
-
|
|
98
|
+
shape: "rectangle"
|
|
103
99
|
};
|
|
104
|
-
//# sourceMappingURL=swatch.stories.js.map
|
|
100
|
+
//# sourceMappingURL=swatch.stories.js.map
|