@stackoverflow/stacks 1.0.1 → 1.3.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/dist/controllers/s-popover.d.ts +11 -2
- package/dist/css/stacks.css +282 -188
- package/dist/css/stacks.min.css +1 -1
- package/dist/js/stacks.js +39 -9
- package/dist/js/stacks.min.js +1 -1
- package/lib/css/atomic/spacing.less +10 -0
- package/lib/css/atomic/width-height.less +1 -1
- package/lib/css/components/activity-indicator.less +2 -3
- package/lib/css/components/avatars.less +1 -0
- package/lib/css/components/badges.less +47 -0
- package/lib/css/components/buttons.less +30 -6
- package/lib/css/components/inputs.less +10 -12
- package/lib/css/components/post-summary.less +32 -97
- package/lib/css/components/topbar.less +4 -1
- package/lib/css/exports/constants-colors.less +49 -49
- package/lib/ts/controllers/s-popover.ts +25 -5
- package/lib/ts/controllers/s-uploader.ts +26 -12
- package/package.json +26 -27
|
@@ -278,21 +278,33 @@ export class PopoverController extends BasePopoverController {
|
|
|
278
278
|
private boundHideOnEscapePress!: any;
|
|
279
279
|
|
|
280
280
|
/**
|
|
281
|
-
* Toggles optional classes in addition to BasePopoverController.shown
|
|
281
|
+
* Toggles optional classes and accessibility attributes in addition to BasePopoverController.shown
|
|
282
282
|
*/
|
|
283
|
-
protected shown(dispatcher: Element|null = null) {
|
|
283
|
+
protected override shown(dispatcher: Element|null = null) {
|
|
284
284
|
this.toggleOptionalClasses(true);
|
|
285
|
+
this.toggleAccessibilityAttributes(true);
|
|
285
286
|
super.shown(dispatcher);
|
|
286
287
|
}
|
|
287
288
|
|
|
288
289
|
/**
|
|
289
|
-
* Toggles optional classes in addition to BasePopoverController.hidden
|
|
290
|
+
* Toggles optional classes and accessibility attributes in addition to BasePopoverController.hidden
|
|
290
291
|
*/
|
|
291
|
-
protected hidden(dispatcher: Element|null = null) {
|
|
292
|
+
protected override hidden(dispatcher: Element|null = null) {
|
|
292
293
|
this.toggleOptionalClasses(false);
|
|
294
|
+
this.toggleAccessibilityAttributes(false);
|
|
293
295
|
super.hidden(dispatcher);
|
|
294
296
|
}
|
|
295
297
|
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Initializes accessibility attributes in addition to BasePopoverController.connect
|
|
301
|
+
*/
|
|
302
|
+
public override connect(): void {
|
|
303
|
+
super.connect();
|
|
304
|
+
|
|
305
|
+
this.toggleAccessibilityAttributes();
|
|
306
|
+
}
|
|
307
|
+
|
|
296
308
|
/**
|
|
297
309
|
* Binds global events to the document for hiding popovers on user interaction
|
|
298
310
|
*/
|
|
@@ -307,7 +319,7 @@ export class PopoverController extends BasePopoverController {
|
|
|
307
319
|
/**
|
|
308
320
|
* Unbinds global events to the document for hiding popovers on user interaction
|
|
309
321
|
*/
|
|
310
|
-
protected
|
|
322
|
+
protected unbindDocumentEvents() {
|
|
311
323
|
document.removeEventListener("mousedown", this.boundHideOnOutsideClick);
|
|
312
324
|
document.removeEventListener("keyup", this.boundHideOnEscapePress);
|
|
313
325
|
}
|
|
@@ -357,6 +369,14 @@ export class PopoverController extends BasePopoverController {
|
|
|
357
369
|
cl.toggle(cls, show);
|
|
358
370
|
});
|
|
359
371
|
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Toggles accessibility attributes based on whether the popover is shown or not
|
|
375
|
+
* @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide.
|
|
376
|
+
*/
|
|
377
|
+
private toggleAccessibilityAttributes(show?: boolean) {
|
|
378
|
+
this.referenceElement.ariaExpanded = show?.toString() || this.referenceElement.ariaExpanded || 'false';
|
|
379
|
+
}
|
|
360
380
|
}
|
|
361
381
|
|
|
362
382
|
/**
|
|
@@ -12,8 +12,8 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
12
12
|
private previewsTarget!: HTMLElement;
|
|
13
13
|
private uploaderTarget!: HTMLElement;
|
|
14
14
|
|
|
15
|
-
private boundDragEnter!:
|
|
16
|
-
private boundDragLeave!:
|
|
15
|
+
private boundDragEnter!: () => void;
|
|
16
|
+
private boundDragLeave!: () => void;
|
|
17
17
|
|
|
18
18
|
private static readonly FILE_DISPLAY_LIMIT = 10;
|
|
19
19
|
private static readonly MAX_FILE_SIZE = 1024 * 1024 * 10; // 10 MB
|
|
@@ -50,7 +50,7 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
50
50
|
const hasMultipleFiles = res.length > 1;
|
|
51
51
|
|
|
52
52
|
if (hasMultipleFiles) {
|
|
53
|
-
|
|
53
|
+
const headingElement = document.createElement("div");
|
|
54
54
|
headingElement.classList.add("s-uploader--previews-heading");
|
|
55
55
|
headingElement.innerText = res.length < count ?
|
|
56
56
|
`Showing ${res.length} of ${count} files` : `${count} items`;
|
|
@@ -61,7 +61,9 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
61
61
|
}
|
|
62
62
|
res.forEach((file) => this.addFilePreview(file));
|
|
63
63
|
this.handleUploaderActive(true);
|
|
64
|
-
})
|
|
64
|
+
})
|
|
65
|
+
// TODO consider rendering an error message
|
|
66
|
+
.catch(() => null);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
|
@@ -84,13 +86,25 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
84
86
|
const enableElements = scope.findAllElements('[data-s-uploader-enable-on-input]');
|
|
85
87
|
|
|
86
88
|
if (shouldPreview) {
|
|
87
|
-
hideElements.
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
hideElements.forEach(el => {
|
|
90
|
+
el.classList.add("d-none");
|
|
91
|
+
});
|
|
92
|
+
showElements.forEach(el => {
|
|
93
|
+
el.classList.remove("d-none");
|
|
94
|
+
});
|
|
95
|
+
enableElements.forEach(el => {
|
|
96
|
+
el.removeAttribute("disabled");
|
|
97
|
+
});
|
|
90
98
|
} else {
|
|
91
|
-
hideElements.
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
hideElements.forEach(el => {
|
|
100
|
+
el.classList.remove("d-none");
|
|
101
|
+
});
|
|
102
|
+
showElements.forEach(el => {
|
|
103
|
+
el.classList.add("d-none");
|
|
104
|
+
});
|
|
105
|
+
enableElements.forEach(el => {
|
|
106
|
+
el.setAttribute("disabled", "true");
|
|
107
|
+
});
|
|
94
108
|
this.handleUploaderActive(false);
|
|
95
109
|
}
|
|
96
110
|
}
|
|
@@ -104,7 +118,7 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
104
118
|
return;
|
|
105
119
|
}
|
|
106
120
|
|
|
107
|
-
|
|
121
|
+
const previewElement = document.createElement("div");
|
|
108
122
|
let thumbElement;
|
|
109
123
|
|
|
110
124
|
if (file.type.match('image/*') && file.data) {
|
|
@@ -137,7 +151,7 @@ export class UploaderController extends Stacks.StacksController {
|
|
|
137
151
|
* @returns an object containing a FilePreview object
|
|
138
152
|
*/
|
|
139
153
|
private fileToDataURL(file: File): Promise<FilePreview> {
|
|
140
|
-
|
|
154
|
+
const reader = new FileReader();
|
|
141
155
|
const { name, size, type } = file;
|
|
142
156
|
|
|
143
157
|
if (size < UploaderController.MAX_FILE_SIZE && type.indexOf("image") > -1) {
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/StackExchange/Stacks.git"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0
|
|
8
|
+
"version": "1.3.0",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"lib"
|
|
@@ -30,43 +30,42 @@
|
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@popperjs/core": "^2.11.
|
|
33
|
+
"@popperjs/core": "^2.11.5",
|
|
34
34
|
"stimulus": "^2.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@11ty/eleventy": "^1.0.
|
|
38
|
-
"@highlightjs/cdn-assets": "^11.
|
|
39
|
-
"@stackoverflow/stacks-editor": "^0.
|
|
40
|
-
"@stackoverflow/stacks-icons": "^
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
42
|
-
"@typescript-eslint/parser": "^5.
|
|
43
|
-
"backstopjs": "^6.0
|
|
44
|
-
"concurrently": "^7.
|
|
37
|
+
"@11ty/eleventy": "^1.0.1",
|
|
38
|
+
"@highlightjs/cdn-assets": "^11.6.0",
|
|
39
|
+
"@stackoverflow/stacks-editor": "^0.6.1",
|
|
40
|
+
"@stackoverflow/stacks-icons": "^3.0.0",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
|
42
|
+
"@typescript-eslint/parser": "^5.31.0",
|
|
43
|
+
"backstopjs": "^6.1.0",
|
|
44
|
+
"concurrently": "^7.3.0",
|
|
45
45
|
"css-loader": "^6.7.1",
|
|
46
|
-
"cssnano": "^5.1.
|
|
46
|
+
"cssnano": "^5.1.12",
|
|
47
47
|
"docsearch.js": "^2.6.3",
|
|
48
|
-
"eleventy-plugin-highlightjs": "^1.
|
|
48
|
+
"eleventy-plugin-highlightjs": "^1.1.0",
|
|
49
49
|
"eleventy-plugin-nesting-toc": "^1.3.0",
|
|
50
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.20.0",
|
|
51
51
|
"eslint-config-prettier": "^8.5.0",
|
|
52
52
|
"eslint-plugin-no-unsanitized": "^4.0.1",
|
|
53
|
-
"grunt-concurrent": "^3.0.0",
|
|
54
53
|
"jquery": "^3.6.0",
|
|
55
|
-
"less-loader": "^
|
|
54
|
+
"less-loader": "^11.0.0",
|
|
56
55
|
"list.js": "^2.3.1",
|
|
57
|
-
"markdown-it": "^
|
|
58
|
-
"mini-css-extract-plugin": "^2.6.
|
|
56
|
+
"markdown-it": "^13.0.1",
|
|
57
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
59
58
|
"postcss-less": "^6.0.0",
|
|
60
|
-
"postcss-loader": "^
|
|
61
|
-
"prettier": "^2.
|
|
62
|
-
"stylelint": "^14.
|
|
63
|
-
"stylelint-config-recommended": "^
|
|
64
|
-
"stylelint-config-standard": "^
|
|
65
|
-
"terser-webpack-plugin": "^5.3.
|
|
66
|
-
"ts-loader": "^9.
|
|
67
|
-
"typescript": "^4.
|
|
68
|
-
"webpack": "^5.
|
|
69
|
-
"webpack-cli": "^4.
|
|
59
|
+
"postcss-loader": "^7.0.1",
|
|
60
|
+
"prettier": "^2.7.1",
|
|
61
|
+
"stylelint": "^14.9.1",
|
|
62
|
+
"stylelint-config-recommended": "^8.0.0",
|
|
63
|
+
"stylelint-config-standard": "^26.0.0",
|
|
64
|
+
"terser-webpack-plugin": "^5.3.3",
|
|
65
|
+
"ts-loader": "^9.3.1",
|
|
66
|
+
"typescript": "^4.7.4",
|
|
67
|
+
"webpack": "^5.73.0",
|
|
68
|
+
"webpack-cli": "^4.10.0",
|
|
70
69
|
"webpack-merge": "^5.8.0"
|
|
71
70
|
},
|
|
72
71
|
"browserslist": [
|