@spectrum-web-components/grid 0.0.2 → 0.0.3
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 +4 -4
- package/stories/grid.stories.js +184 -0
- package/stories/grid.stories.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/grid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@lit-labs/observers": "^1.0.1",
|
|
48
48
|
"@lit-labs/virtualizer": "0.7.0-pre.2",
|
|
49
|
-
"@spectrum-web-components/base": "^0.5.
|
|
50
|
-
"@spectrum-web-components/reactive-controllers": "^0.2.
|
|
49
|
+
"@spectrum-web-components/base": "^0.5.4",
|
|
50
|
+
"@spectrum-web-components/reactive-controllers": "^0.2.2",
|
|
51
51
|
"tslib": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"types": "./src/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"sideEffects": [
|
|
56
56
|
"./sp-*.js"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "caf12727e7f91dcf961e1fadacc727eea9ece27b"
|
|
59
59
|
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 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 '../sp-grid.js';
|
|
14
|
+
import '@spectrum-web-components/action-bar/sp-action-bar.js';
|
|
15
|
+
import '@spectrum-web-components/card/sp-card.js';
|
|
16
|
+
import '@spectrum-web-components/checkbox/sp-checkbox.js';
|
|
17
|
+
import '@spectrum-web-components/action-button/sp-action-button.js';
|
|
18
|
+
import '@spectrum-web-components/action-group/sp-action-group.js';
|
|
19
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';
|
|
20
|
+
import '@spectrum-web-components/icons-workflow/icons/sp-icon-more.js';
|
|
21
|
+
export default {
|
|
22
|
+
title: 'Grid',
|
|
23
|
+
component: 'sp-grid',
|
|
24
|
+
};
|
|
25
|
+
function generateItems(count) {
|
|
26
|
+
const items = [];
|
|
27
|
+
while (count) {
|
|
28
|
+
count -= 1;
|
|
29
|
+
items.unshift({ id: count });
|
|
30
|
+
}
|
|
31
|
+
return items;
|
|
32
|
+
}
|
|
33
|
+
export const Default = () => {
|
|
34
|
+
const items = generateItems(1000);
|
|
35
|
+
const renderItem = (item, index, selected) => {
|
|
36
|
+
return html `
|
|
37
|
+
<sp-card
|
|
38
|
+
toggles
|
|
39
|
+
variant="quiet"
|
|
40
|
+
heading="Card Heading ${item.id}"
|
|
41
|
+
subheading="JPG Photo"
|
|
42
|
+
style="contain: strict; padding: 1px;"
|
|
43
|
+
value="card-${item.id}"
|
|
44
|
+
.selected=${selected}
|
|
45
|
+
key=${index}
|
|
46
|
+
>
|
|
47
|
+
<img
|
|
48
|
+
alt=""
|
|
49
|
+
slot="preview"
|
|
50
|
+
src="https://picsum.photos/id/${item.id}/200/300"
|
|
51
|
+
decoding="async"
|
|
52
|
+
/>
|
|
53
|
+
<div slot="description">10/15/18</div>
|
|
54
|
+
<div slot="footer">Footer</div>
|
|
55
|
+
</sp-card>
|
|
56
|
+
`;
|
|
57
|
+
};
|
|
58
|
+
const handleChange = (event) => {
|
|
59
|
+
const actionbar = document.querySelector('sp-action-bar');
|
|
60
|
+
const selected = document.querySelector('.selected');
|
|
61
|
+
const ids = document.querySelector('.ids');
|
|
62
|
+
actionbar.open = !!event.currentTarget.selected.length;
|
|
63
|
+
actionbar.style.setProperty('display', !!event.currentTarget.selected.length ? 'flex' : 'none');
|
|
64
|
+
selected.textContent = '' + event.currentTarget.selected.length;
|
|
65
|
+
ids.textContent =
|
|
66
|
+
'' +
|
|
67
|
+
event.currentTarget.selected
|
|
68
|
+
.map((selection) => selection.id)
|
|
69
|
+
.join(', ');
|
|
70
|
+
};
|
|
71
|
+
const handleActionBarChange = (event) => {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
const grid = document.querySelector('sp-grid');
|
|
74
|
+
const actionbar = document.querySelector('sp-action-bar');
|
|
75
|
+
actionbar.open = false;
|
|
76
|
+
grid.selected = [];
|
|
77
|
+
};
|
|
78
|
+
return html `
|
|
79
|
+
<h1>Random before content that is focusable</h1>
|
|
80
|
+
<input id="first-input" />
|
|
81
|
+
<sp-grid
|
|
82
|
+
@change=${handleChange}
|
|
83
|
+
.items=${items}
|
|
84
|
+
.focusableSelector=${'sp-card'}
|
|
85
|
+
.renderItem=${renderItem}
|
|
86
|
+
></sp-grid>
|
|
87
|
+
<sp-action-bar variant="fixed" style="display: none">
|
|
88
|
+
<sp-checkbox @click=${handleActionBarChange} checked>
|
|
89
|
+
<span class="selected"></span>
|
|
90
|
+
Selected
|
|
91
|
+
<span class="ids"></span>
|
|
92
|
+
</sp-checkbox>
|
|
93
|
+
<sp-action-group quiet>
|
|
94
|
+
<sp-action-button>
|
|
95
|
+
<sp-icon-edit slot="icon" label="Edit"></sp-icon-edit>
|
|
96
|
+
</sp-action-button>
|
|
97
|
+
<sp-action-button>
|
|
98
|
+
<sp-icon-more slot="icon" label="More"></sp-icon-more>
|
|
99
|
+
</sp-action-button>
|
|
100
|
+
</sp-action-group>
|
|
101
|
+
</sp-action-bar>
|
|
102
|
+
<h2>Random after content that is focusable</h2>
|
|
103
|
+
<input id="last-input" />
|
|
104
|
+
`;
|
|
105
|
+
};
|
|
106
|
+
export const sized = () => {
|
|
107
|
+
const items = generateItems(1000);
|
|
108
|
+
const renderItem = (item, index, selected) => {
|
|
109
|
+
return html `
|
|
110
|
+
<sp-card
|
|
111
|
+
toggles
|
|
112
|
+
variant="quiet"
|
|
113
|
+
heading="Card Heading ${item.id}"
|
|
114
|
+
subheading="JPG Photo"
|
|
115
|
+
style="contain: strict; padding: 1px;"
|
|
116
|
+
value="card-${item.id}"
|
|
117
|
+
.selected=${selected}
|
|
118
|
+
key=${index}
|
|
119
|
+
>
|
|
120
|
+
<img
|
|
121
|
+
alt=""
|
|
122
|
+
slot="preview"
|
|
123
|
+
src="https://picsum.photos/id/${item.id}/200/300"
|
|
124
|
+
decoding="async"
|
|
125
|
+
/>
|
|
126
|
+
<div slot="description">10/15/18</div>
|
|
127
|
+
<div slot="footer">Footer</div>
|
|
128
|
+
</sp-card>
|
|
129
|
+
`;
|
|
130
|
+
};
|
|
131
|
+
const handleChange = (event) => {
|
|
132
|
+
const actionbar = document.querySelector('sp-action-bar');
|
|
133
|
+
const selected = document.querySelector('.selected');
|
|
134
|
+
const ids = document.querySelector('.ids');
|
|
135
|
+
actionbar.open = !!event.currentTarget.selected.length;
|
|
136
|
+
actionbar.style.setProperty('display', !!event.currentTarget.selected.length ? 'flex' : 'none');
|
|
137
|
+
selected.textContent = '' + event.currentTarget.selected.length;
|
|
138
|
+
ids.textContent =
|
|
139
|
+
'' +
|
|
140
|
+
event.currentTarget.selected
|
|
141
|
+
.map((selection) => selection.id)
|
|
142
|
+
.join(', ');
|
|
143
|
+
};
|
|
144
|
+
const handleActionBarChange = (event) => {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
const grid = document.querySelector('sp-grid');
|
|
147
|
+
const actionbar = document.querySelector('sp-action-bar');
|
|
148
|
+
actionbar.open = false;
|
|
149
|
+
grid.selected = [];
|
|
150
|
+
};
|
|
151
|
+
return html `
|
|
152
|
+
<h1>Random before content that is focusable</h1>
|
|
153
|
+
<input id="first-input" />
|
|
154
|
+
<sp-grid
|
|
155
|
+
@change=${handleChange}
|
|
156
|
+
.items=${items}
|
|
157
|
+
.focusableSelector=${'sp-card'}
|
|
158
|
+
.renderItem=${renderItem}
|
|
159
|
+
.itemSize=${{
|
|
160
|
+
width: 200,
|
|
161
|
+
height: 300,
|
|
162
|
+
}}
|
|
163
|
+
.gap=${'10px'}
|
|
164
|
+
></sp-grid>
|
|
165
|
+
<sp-action-bar variant="fixed" style="display: none">
|
|
166
|
+
<sp-checkbox @click=${handleActionBarChange} checked>
|
|
167
|
+
<span class="selected"></span>
|
|
168
|
+
Selected
|
|
169
|
+
<span class="ids"></span>
|
|
170
|
+
</sp-checkbox>
|
|
171
|
+
<sp-action-group quiet>
|
|
172
|
+
<sp-action-button>
|
|
173
|
+
<sp-icon-edit slot="icon" label="Edit"></sp-icon-edit>
|
|
174
|
+
</sp-action-button>
|
|
175
|
+
<sp-action-button>
|
|
176
|
+
<sp-icon-more slot="icon" label="More"></sp-icon-more>
|
|
177
|
+
</sp-action-button>
|
|
178
|
+
</sp-action-group>
|
|
179
|
+
</sp-action-bar>
|
|
180
|
+
<h2>Random after content that is focusable</h2>
|
|
181
|
+
<input id="last-input" />
|
|
182
|
+
`;
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=grid.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.stories.js","sourceRoot":"","sources":["grid.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AAErE,OAAO,eAAe,CAAC;AACvB,OAAO,sDAAsD,CAAC;AAC9D,OAAO,0CAA0C,CAAC;AAClD,OAAO,kDAAkD,CAAC;A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;;KAgBlD,CAAC;AACN,CAAC,CAAC","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*/\n\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '../sp-grid.js';\nimport '@spectrum-web-components/action-bar/sp-action-bar.js';\nimport '@spectrum-web-components/card/sp-card.js';\nimport '@spectrum-web-components/checkbox/sp-checkbox.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/action-group/sp-action-group.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-more.js';\nimport type { ActionBar } from '@spectrum-web-components/action-bar';\nimport type { Grid } from '..';\n\nexport default {\n title: 'Grid',\n component: 'sp-grid',\n};\n\ninterface Item extends Record<string, unknown> {\n id: number;\n}\n\nfunction generateItems(count: number): Item[] {\n const items: Item[] = [];\n while (count) {\n count -= 1;\n items.unshift({ id: count });\n }\n return items;\n}\n\nexport const Default = (): TemplateResult => {\n const items = generateItems(1000);\n\n const renderItem = (\n item: Item,\n index: number,\n selected: boolean\n ): TemplateResult => {\n return html`\n <sp-card\n toggles\n variant=\"quiet\"\n heading=\"Card Heading ${item.id}\"\n subheading=\"JPG Photo\"\n style=\"contain: strict; padding: 1px;\"\n value=\"card-${item.id}\"\n .selected=${selected}\n key=${index}\n >\n <img\n alt=\"\"\n slot=\"preview\"\n src=\"https://picsum.photos/id/${item.id}/200/300\"\n decoding=\"async\"\n />\n <div slot=\"description\">10/15/18</div>\n <div slot=\"footer\">Footer</div>\n </sp-card>\n `;\n };\n const handleChange = (event: Event & { currentTarget: Grid }): void => {\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n const selected = document.querySelector('.selected') as HTMLElement;\n const ids = document.querySelector('.ids') as HTMLElement;\n actionbar.open = !!event.currentTarget.selected.length;\n actionbar.style.setProperty(\n 'display',\n !!event.currentTarget.selected.length ? 'flex' : 'none'\n );\n selected.textContent = '' + event.currentTarget.selected.length;\n ids.textContent =\n '' +\n event.currentTarget.selected\n .map((selection) => selection.id)\n .join(', ');\n };\n const handleActionBarChange = (event: Event): void => {\n event.preventDefault();\n const grid = document.querySelector('sp-grid') as Grid;\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n actionbar.open = false;\n grid.selected = [];\n };\n return html`\n <h1>Random before content that is focusable</h1>\n <input id=\"first-input\" />\n <sp-grid\n @change=${handleChange}\n .items=${items}\n .focusableSelector=${'sp-card'}\n .renderItem=${renderItem}\n ></sp-grid>\n <sp-action-bar variant=\"fixed\" style=\"display: none\">\n <sp-checkbox @click=${handleActionBarChange} checked>\n <span class=\"selected\"></span>\n Selected\n <span class=\"ids\"></span>\n </sp-checkbox>\n <sp-action-group quiet>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\" label=\"Edit\"></sp-icon-edit>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-more slot=\"icon\" label=\"More\"></sp-icon-more>\n </sp-action-button>\n </sp-action-group>\n </sp-action-bar>\n <h2>Random after content that is focusable</h2>\n <input id=\"last-input\" />\n `;\n};\n\nexport const sized = (): TemplateResult => {\n const items = generateItems(1000);\n\n const renderItem = (\n item: Item,\n index: number,\n selected: boolean\n ): TemplateResult => {\n return html`\n <sp-card\n toggles\n variant=\"quiet\"\n heading=\"Card Heading ${item.id}\"\n subheading=\"JPG Photo\"\n style=\"contain: strict; padding: 1px;\"\n value=\"card-${item.id}\"\n .selected=${selected}\n key=${index}\n >\n <img\n alt=\"\"\n slot=\"preview\"\n src=\"https://picsum.photos/id/${item.id}/200/300\"\n decoding=\"async\"\n />\n <div slot=\"description\">10/15/18</div>\n <div slot=\"footer\">Footer</div>\n </sp-card>\n `;\n };\n const handleChange = (event: Event & { currentTarget: Grid }): void => {\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n const selected = document.querySelector('.selected') as HTMLElement;\n const ids = document.querySelector('.ids') as HTMLElement;\n actionbar.open = !!event.currentTarget.selected.length;\n actionbar.style.setProperty(\n 'display',\n !!event.currentTarget.selected.length ? 'flex' : 'none'\n );\n selected.textContent = '' + event.currentTarget.selected.length;\n ids.textContent =\n '' +\n event.currentTarget.selected\n .map((selection) => selection.id)\n .join(', ');\n };\n const handleActionBarChange = (event: Event): void => {\n event.preventDefault();\n const grid = document.querySelector('sp-grid') as Grid;\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n actionbar.open = false;\n grid.selected = [];\n };\n return html`\n <h1>Random before content that is focusable</h1>\n <input id=\"first-input\" />\n <sp-grid\n @change=${handleChange}\n .items=${items}\n .focusableSelector=${'sp-card'}\n .renderItem=${renderItem}\n .itemSize=${{\n width: 200,\n height: 300,\n }}\n .gap=${'10px'}\n ></sp-grid>\n <sp-action-bar variant=\"fixed\" style=\"display: none\">\n <sp-checkbox @click=${handleActionBarChange} checked>\n <span class=\"selected\"></span>\n Selected\n <span class=\"ids\"></span>\n </sp-checkbox>\n <sp-action-group quiet>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\" label=\"Edit\"></sp-icon-edit>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-more slot=\"icon\" label=\"More\"></sp-icon-more>\n </sp-action-button>\n </sp-action-group>\n </sp-action-bar>\n <h2>Random after content that is focusable</h2>\n <input id=\"last-input\" />\n `;\n};\n"]}
|