@appartmint/mint 0.13.3 → 0.14.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/README.md +3 -3
- package/dist/css/mint.css +55 -9
- package/dist/css/mint.css.map +1 -1
- package/dist/css/mint.min.css +1 -1
- package/dist/css/mint.min.css.map +1 -1
- package/dist/js/imports/components/header.d.ts +124 -122
- package/dist/js/imports/components/header.d.ts.map +1 -1
- package/dist/js/imports/enum.d.ts +9 -9
- package/dist/js/imports/models/color.d.ts +31 -31
- package/dist/js/imports/models/item.d.ts +69 -69
- package/dist/js/imports/util/display.d.ts +6 -6
- package/dist/js/imports/util/event.d.ts +6 -6
- package/dist/js/imports/util/icon.d.ts +28 -28
- package/dist/js/imports/util/list.d.ts +12 -12
- package/dist/js/imports/util/math.d.ts +13 -13
- package/dist/js/imports/util/object.d.ts +58 -58
- package/dist/js/imports/util/selectors.d.ts +121 -145
- package/dist/js/imports/util/selectors.d.ts.map +1 -1
- package/dist/js/imports/util/settings.d.ts +38 -52
- package/dist/js/imports/util/settings.d.ts.map +1 -1
- package/dist/js/imports/util/text.d.ts +16 -16
- package/dist/js/imports/util/window.d.ts +6 -6
- package/dist/js/index.d.ts +23 -23
- package/dist/js/index.js +381 -422
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.min.js +1 -1
- package/dist/js/index.min.js.map +1 -1
- package/dist/js/util.d.ts +77 -77
- package/dist/js/util.js +81 -325
- package/dist/js/util.js.map +1 -1
- package/dist/js/util.min.js +1 -1
- package/dist/js/util.min.js.map +1 -1
- package/package.json +1 -1
- package/src/scss/imports/_index.scss +8 -8
- package/src/scss/imports/components/_cards.scss +12 -1
- package/src/scss/imports/components/_embed.scss +75 -63
- package/src/scss/imports/components/_header.scss +60 -13
- package/src/scss/imports/components/_index.scss +7 -7
- package/src/scss/imports/global/_aspect.scss +1 -1
- package/src/scss/imports/global/_icons.scss +6 -6
- package/src/scss/imports/global/_structure.scss +2 -1
- package/src/scss/imports/global/_texture.scss +27 -2
- package/src/scss/imports/util/_index.scss +8 -8
- package/src/scss/imports/util/_vars.scss +8 -0
- package/src/ts/imports/components/header.ts +60 -35
- package/src/ts/imports/enum.ts +9 -9
- package/src/ts/imports/models/color.ts +96 -96
- package/src/ts/imports/util/display.ts +6 -6
- package/src/ts/imports/util/event.ts +7 -7
- package/src/ts/imports/util/list.ts +19 -19
- package/src/ts/imports/util/math.ts +17 -17
- package/src/ts/imports/util/selectors.ts +0 -45
- package/src/ts/imports/util/settings.ts +13 -47
- package/src/ts/imports/util/window.ts +6 -6
- package/src/ts/index.ts +33 -33
|
@@ -12,9 +12,12 @@ import mintSettings from '../util/settings';
|
|
|
12
12
|
*/
|
|
13
13
|
export class mintHeader {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Navbar settings
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
settings: {[key: string]: any} = {
|
|
18
|
+
from: mintSide.Top,
|
|
19
|
+
fixed: true
|
|
20
|
+
};
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Frequently-referenced elements
|
|
@@ -25,17 +28,11 @@ export class mintHeader {
|
|
|
25
28
|
* Initializes and closes the menu
|
|
26
29
|
*/
|
|
27
30
|
constructor (settings?: {[key: string]: any}) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
fixed: true
|
|
31
|
-
};
|
|
32
|
-
mintSettings.set({ ...defaultSettings, ...settings });
|
|
33
|
-
|
|
31
|
+
this.settings = {...this.settings, ...settings};
|
|
32
|
+
|
|
34
33
|
this.attachElements();
|
|
35
34
|
this.attachEvents();
|
|
36
35
|
this.addClasses();
|
|
37
|
-
|
|
38
|
-
this.setMobileMenu();
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
/**
|
|
@@ -44,27 +41,27 @@ export class mintHeader {
|
|
|
44
41
|
attachElements () : void {
|
|
45
42
|
this.el.html = document.querySelector('html');
|
|
46
43
|
this.el.body = document.querySelector('body');
|
|
47
|
-
this.el.header = document.getElementById(
|
|
48
|
-
this.el.mobileButton = this.el.header?.querySelector(mintSelectors.controls(
|
|
49
|
-
this.el.wrapper = document.getElementById(
|
|
44
|
+
this.el.header = document.getElementById('mint-header');
|
|
45
|
+
this.el.mobileButton = this.el.header?.querySelector(mintSelectors.controls('mint-wrapper')) || null;
|
|
46
|
+
this.el.wrapper = document.getElementById('mint-wrapper');
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
|
53
50
|
* Adds events to the dom
|
|
54
51
|
*/
|
|
55
52
|
attachEvents () : void {
|
|
56
|
-
|
|
53
|
+
window.addEventListener('resize', mintUtil.throttleEvent(this.eHandleResize.bind(this), mintSettings.delay.default));
|
|
57
54
|
window.addEventListener('scroll', mintUtil.throttleEvent(this.eHandleScroll.bind(this), mintSettings.delay.default, { trailing: false }));
|
|
58
55
|
|
|
59
|
-
let focusables
|
|
60
|
-
lastFocusable
|
|
56
|
+
let focusables = this.el.header?.querySelectorAll(mintSelectors.focusable),
|
|
57
|
+
lastFocusable = focusables?.[focusables?.length - 1];
|
|
61
58
|
lastFocusable?.addEventListener('keydown', mintUtil.throttleEvent(this.eWrapTab.bind(this)));
|
|
62
|
-
focusables?.forEach((focusable
|
|
59
|
+
focusables?.forEach((focusable) => {
|
|
63
60
|
focusable.addEventListener('keydown', mintUtil.throttleEvent(this.eHandleKeypress.bind(this)));
|
|
64
61
|
});
|
|
65
62
|
|
|
66
|
-
let menuButtons
|
|
67
|
-
menuButtons?.forEach((menuButton
|
|
63
|
+
let menuButtons = this.el.wrapper?.querySelectorAll(mintSelectors.controls());
|
|
64
|
+
menuButtons?.forEach((menuButton) => {
|
|
68
65
|
menuButton.addEventListener('click', mintUtil.throttleEvent(this.eToggleMenu.bind(this), mintSettings.delay.slow, { trailing: false }));
|
|
69
66
|
});
|
|
70
67
|
|
|
@@ -73,11 +70,17 @@ export class mintHeader {
|
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
/**
|
|
76
|
-
* Adds classes that inform the styles
|
|
73
|
+
* Adds classes that inform the styles based on settings
|
|
77
74
|
*/
|
|
78
75
|
addClasses () : void {
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
this.el.header?.classList.remove('mint-top', 'mint-right', 'mint-bottom', 'mint-left');
|
|
77
|
+
this.el.header?.classList.add(`mint-${mintSide[this.settings.from ?? 0].toLowerCase()}`);
|
|
78
|
+
|
|
79
|
+
if (this.settings.fixed) {
|
|
80
|
+
this.el.body?.classList.add('mint-fixed');
|
|
81
|
+
}
|
|
82
|
+
if (this.settings.tray) {
|
|
83
|
+
this.el.header?.classList.add('mint-tray');
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -95,7 +98,7 @@ export class mintHeader {
|
|
|
95
98
|
}, mintSettings.delay.fast);
|
|
96
99
|
|
|
97
100
|
if (open) {
|
|
98
|
-
if (
|
|
101
|
+
if (this.settings.fixed !== true) {
|
|
99
102
|
window.scroll({
|
|
100
103
|
top: 0,
|
|
101
104
|
left: 0,
|
|
@@ -105,16 +108,26 @@ export class mintHeader {
|
|
|
105
108
|
|
|
106
109
|
setTimeout(() => {
|
|
107
110
|
if (this.el.html) {
|
|
108
|
-
|
|
111
|
+
let isMobile = mintUtil.windowWidth() <= mintSettings.break.sm,
|
|
112
|
+
overflow = 'auto';
|
|
113
|
+
|
|
114
|
+
if (this.settings.tray) {
|
|
115
|
+
if (isMobile) {
|
|
116
|
+
overflow = 'hidden';
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
overflow = 'hidden';
|
|
120
|
+
}
|
|
121
|
+
this.el.html.style.overflow = overflow;
|
|
109
122
|
}
|
|
110
|
-
},
|
|
123
|
+
}, this.settings.from === mintSide.Left ? mintSettings.delay.default : mintSettings.delay.instant);
|
|
111
124
|
|
|
112
125
|
if (this.el.wrapper) {
|
|
113
126
|
this.el.wrapper.style.display = 'flex';
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
requestAnimationFrame(() => {
|
|
117
|
-
this.el.wrapper?.classList.add(
|
|
130
|
+
this.el.wrapper?.classList.add('mint-open');
|
|
118
131
|
});
|
|
119
132
|
} else {
|
|
120
133
|
if (this.el.html) {
|
|
@@ -122,7 +135,7 @@ export class mintHeader {
|
|
|
122
135
|
}
|
|
123
136
|
|
|
124
137
|
requestAnimationFrame(() => {
|
|
125
|
-
this.el.wrapper?.classList.remove(
|
|
138
|
+
this.el.wrapper?.classList.remove('mint-open');
|
|
126
139
|
});
|
|
127
140
|
|
|
128
141
|
this.closeAllMenus();
|
|
@@ -210,7 +223,7 @@ export class mintHeader {
|
|
|
210
223
|
let activeButton: HTMLElement | null = document.activeElement as HTMLElement | null,
|
|
211
224
|
activeMenu: HTMLElement | null = activeButton?.nextElementSibling as HTMLElement | null,
|
|
212
225
|
showing: boolean = activeButton?.getAttribute('aria-expanded')?.toLowerCase() === 'true';
|
|
213
|
-
if (activeButton?.getAttribute('aria-controls') ===
|
|
226
|
+
if (activeButton?.getAttribute('aria-controls') === 'mint-wrapper') {
|
|
214
227
|
activeMenu = this.el.wrapper;
|
|
215
228
|
}
|
|
216
229
|
|
|
@@ -252,12 +265,24 @@ export class mintHeader {
|
|
|
252
265
|
/**
|
|
253
266
|
* Closes the mobile menu when the window resizes
|
|
254
267
|
*/
|
|
255
|
-
eHandleResize (
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
eHandleResize () : void {
|
|
269
|
+
let isOpen = this.el.mobileButton?.getAttribute('aria-expanded')?.toLowerCase() === 'true',
|
|
270
|
+
isMobile = mintUtil.windowWidth() <= mintSettings.break.sm,
|
|
271
|
+
overflow = 'auto';
|
|
272
|
+
|
|
273
|
+
if (isOpen) {
|
|
274
|
+
if (this.settings.tray) {
|
|
275
|
+
if (isMobile) {
|
|
276
|
+
overflow = 'hidden';
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
overflow = 'hidden';
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (this.el.html) {
|
|
284
|
+
this.el.html.style.overflow = overflow;
|
|
259
285
|
}
|
|
260
|
-
this.lastWidth = mintUtil.windowWidth();
|
|
261
286
|
}
|
|
262
287
|
|
|
263
288
|
/**
|
|
@@ -289,7 +314,7 @@ export class mintHeader {
|
|
|
289
314
|
subMenu = target?.closest('li');
|
|
290
315
|
switch (e.key.toLowerCase()) {
|
|
291
316
|
case 'escape':
|
|
292
|
-
if (subMenu?.classList.contains(
|
|
317
|
+
if (subMenu?.classList.contains('mint-open')) {
|
|
293
318
|
this.setMenu(subMenu);
|
|
294
319
|
} else {
|
|
295
320
|
this.setMobileMenu();
|
|
@@ -370,7 +395,7 @@ export class mintHeader {
|
|
|
370
395
|
* Runs after the mobile menu transitions
|
|
371
396
|
*/
|
|
372
397
|
eTransitionEnd () : void {
|
|
373
|
-
if (this.el.wrapper?.classList.contains(
|
|
398
|
+
if (this.el.wrapper?.classList.contains('mint-open') === false ) {
|
|
374
399
|
this.el.wrapper.style.display = 'none';
|
|
375
400
|
}
|
|
376
401
|
};
|
package/src/ts/imports/enum.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Side Enum
|
|
3
|
-
*/
|
|
4
|
-
export enum mintSide {
|
|
5
|
-
Top,
|
|
6
|
-
Right,
|
|
7
|
-
Bottom,
|
|
8
|
-
Left
|
|
9
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Side Enum
|
|
3
|
+
*/
|
|
4
|
+
export enum mintSide {
|
|
5
|
+
Top,
|
|
6
|
+
Right,
|
|
7
|
+
Bottom,
|
|
8
|
+
Left
|
|
9
|
+
};
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color
|
|
3
|
-
*/
|
|
4
|
-
export class mintColor {
|
|
5
|
-
protected static hexBase: number = 16;
|
|
6
|
-
protected static hexMax: string = 'FF';
|
|
7
|
-
public r: number;
|
|
8
|
-
public g: number;
|
|
9
|
-
public b: number;
|
|
10
|
-
public a: number;
|
|
11
|
-
|
|
12
|
-
constructor (args: {[key: string]: number | string}) {
|
|
13
|
-
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
-
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
-
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
-
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
-
if (typeof args.color === 'string') {
|
|
18
|
-
this.stringConstructor(args.color);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Constructor from a string argument
|
|
24
|
-
*/
|
|
25
|
-
protected stringConstructor (str: string) : void {
|
|
26
|
-
if (str.startsWith('#')) {
|
|
27
|
-
this.hexConstructor(str);
|
|
28
|
-
} else {
|
|
29
|
-
if (~str.indexOf('linear-gradient')) {
|
|
30
|
-
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
-
}
|
|
32
|
-
this.rgbConstructor(str);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructor from a hex argument
|
|
38
|
-
*/
|
|
39
|
-
protected hexConstructor (hex: string) : void {
|
|
40
|
-
switch (hex.length) {
|
|
41
|
-
case 1:
|
|
42
|
-
case 5:
|
|
43
|
-
case 6:
|
|
44
|
-
return;
|
|
45
|
-
case 2:
|
|
46
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
-
break;
|
|
48
|
-
case 3:
|
|
49
|
-
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
-
break;
|
|
51
|
-
case 4:
|
|
52
|
-
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
-
break;
|
|
54
|
-
case 7:
|
|
55
|
-
hex += mintColor.hexMax;
|
|
56
|
-
break;
|
|
57
|
-
case 8:
|
|
58
|
-
hex += hex[hex.length - 1];
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
hex = hex.substring(0, 9);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
-
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
-
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
-
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Constructor from an rgba argument
|
|
72
|
-
*/
|
|
73
|
-
protected rgbConstructor (rgb: string) : void {
|
|
74
|
-
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
-
if (match) {
|
|
76
|
-
this.r = parseInt(match[1]);
|
|
77
|
-
this.g = parseInt(match[2]);
|
|
78
|
-
this.b = parseInt(match[3]);
|
|
79
|
-
this.a = parseFloat(match[4]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns the perceived brightness of the color
|
|
85
|
-
*/
|
|
86
|
-
getBrightness () : number {
|
|
87
|
-
if (this.a === 0) {
|
|
88
|
-
return 262;
|
|
89
|
-
}
|
|
90
|
-
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
-
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
-
}
|
|
93
|
-
return -1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export default mintColor;
|
|
1
|
+
/**
|
|
2
|
+
* Color
|
|
3
|
+
*/
|
|
4
|
+
export class mintColor {
|
|
5
|
+
protected static hexBase: number = 16;
|
|
6
|
+
protected static hexMax: string = 'FF';
|
|
7
|
+
public r: number;
|
|
8
|
+
public g: number;
|
|
9
|
+
public b: number;
|
|
10
|
+
public a: number;
|
|
11
|
+
|
|
12
|
+
constructor (args: {[key: string]: number | string}) {
|
|
13
|
+
this.r = typeof args.r === 'number' ? Math.max(Math.min(args.r, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
14
|
+
this.g = typeof args.g === 'number' ? Math.max(Math.min(args.g, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
15
|
+
this.b = typeof args.b === 'number' ? Math.max(Math.min(args.b, mintColor.hexBase ** 2 - 1), 0) : 0;
|
|
16
|
+
this.a = typeof args.a === 'number' ? Math.max(Math.min(args.a, 1), 0) : 1;
|
|
17
|
+
if (typeof args.color === 'string') {
|
|
18
|
+
this.stringConstructor(args.color);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constructor from a string argument
|
|
24
|
+
*/
|
|
25
|
+
protected stringConstructor (str: string) : void {
|
|
26
|
+
if (str.startsWith('#')) {
|
|
27
|
+
this.hexConstructor(str);
|
|
28
|
+
} else {
|
|
29
|
+
if (~str.indexOf('linear-gradient')) {
|
|
30
|
+
str = str.substring(str.indexOf('linear-gradient'), str.length);
|
|
31
|
+
}
|
|
32
|
+
this.rgbConstructor(str);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Constructor from a hex argument
|
|
38
|
+
*/
|
|
39
|
+
protected hexConstructor (hex: string) : void {
|
|
40
|
+
switch (hex.length) {
|
|
41
|
+
case 1:
|
|
42
|
+
case 5:
|
|
43
|
+
case 6:
|
|
44
|
+
return;
|
|
45
|
+
case 2:
|
|
46
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + hex[1] + mintColor.hexMax;
|
|
47
|
+
break;
|
|
48
|
+
case 3:
|
|
49
|
+
hex = '#' + hex[1] + hex[1] + hex[1] + hex[2] + hex[2] + hex[2] + mintColor.hexMax;
|
|
50
|
+
break;
|
|
51
|
+
case 4:
|
|
52
|
+
hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3] + mintColor.hexMax;
|
|
53
|
+
break;
|
|
54
|
+
case 7:
|
|
55
|
+
hex += mintColor.hexMax;
|
|
56
|
+
break;
|
|
57
|
+
case 8:
|
|
58
|
+
hex += hex[hex.length - 1];
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
hex = hex.substring(0, 9);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.r = parseInt(hex.substring(1, 3), mintColor.hexBase);
|
|
65
|
+
this.g = parseInt(hex.substring(3, 5), mintColor.hexBase);
|
|
66
|
+
this.b = parseInt(hex.substring(5, 7), mintColor.hexBase);
|
|
67
|
+
this.a = parseInt(hex.substring(7, 9), mintColor.hexBase) / mintColor.hexBase ** 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Constructor from an rgba argument
|
|
72
|
+
*/
|
|
73
|
+
protected rgbConstructor (rgb: string) : void {
|
|
74
|
+
let match: RegExpMatchArray | null = rgb.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d*)?)\))?/);
|
|
75
|
+
if (match) {
|
|
76
|
+
this.r = parseInt(match[1]);
|
|
77
|
+
this.g = parseInt(match[2]);
|
|
78
|
+
this.b = parseInt(match[3]);
|
|
79
|
+
this.a = parseFloat(match[4]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns the perceived brightness of the color
|
|
85
|
+
*/
|
|
86
|
+
getBrightness () : number {
|
|
87
|
+
if (this.a === 0) {
|
|
88
|
+
return 262;
|
|
89
|
+
}
|
|
90
|
+
if (!isNaN(this.r) && !isNaN(this.g) && !isNaN(this.b)) {
|
|
91
|
+
return Math.round((this.r * 299 + this.g * 587 + this.b * 144) / 1000);
|
|
92
|
+
}
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export default mintColor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handles the display of elements
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintDisplay {
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Handles the display of elements
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintDisplay {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
7
|
export default mintDisplay;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event helper functions
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintEvent {
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export default mintEvent;
|
|
1
|
+
/**
|
|
2
|
+
* Event helper functions
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintEvent {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
|
+
export default mintEvent;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List functions for the util library
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintList {
|
|
5
|
-
/**
|
|
6
|
-
* Returns a copy of the provided list with the items in random order
|
|
7
|
-
* @param list - the list to shuffle
|
|
8
|
-
* @returns - the shuffled list
|
|
9
|
-
*/
|
|
10
|
-
static shuffle (list: any[]): any[] {
|
|
11
|
-
let copy = [...list];
|
|
12
|
-
for (let i = copy.length - 1; i > 0; i--) {
|
|
13
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
14
|
-
[copy[i], copy[j]] = [copy[j], copy[i]];
|
|
15
|
-
}
|
|
16
|
-
return copy;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export default mintList;
|
|
1
|
+
/**
|
|
2
|
+
* List functions for the util library
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintList {
|
|
5
|
+
/**
|
|
6
|
+
* Returns a copy of the provided list with the items in random order
|
|
7
|
+
* @param list - the list to shuffle
|
|
8
|
+
* @returns - the shuffled list
|
|
9
|
+
*/
|
|
10
|
+
static shuffle (list: any[]): any[] {
|
|
11
|
+
let copy = [...list];
|
|
12
|
+
for (let i = copy.length - 1; i > 0; i--) {
|
|
13
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
14
|
+
[copy[i], copy[j]] = [copy[j], copy[i]];
|
|
15
|
+
}
|
|
16
|
+
return copy;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export default mintList;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Math functions for the util library
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintMath {
|
|
5
|
-
/**
|
|
6
|
-
* Get a random integer between min and max
|
|
7
|
-
* @param max Maximum value to return
|
|
8
|
-
* @param min Minimum value to return (default is 0)
|
|
9
|
-
* @returns a random integer between min and max
|
|
10
|
-
*/
|
|
11
|
-
static randomInt (max: number, min: number = 0): number {
|
|
12
|
-
min = Math.ceil(min);
|
|
13
|
-
max = Math.floor(max);
|
|
14
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
export default mintMath;
|
|
1
|
+
/**
|
|
2
|
+
* Math functions for the util library
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintMath {
|
|
5
|
+
/**
|
|
6
|
+
* Get a random integer between min and max
|
|
7
|
+
* @param max Maximum value to return
|
|
8
|
+
* @param min Minimum value to return (default is 0)
|
|
9
|
+
* @returns a random integer between min and max
|
|
10
|
+
*/
|
|
11
|
+
static randomInt (max: number, min: number = 0): number {
|
|
12
|
+
min = Math.ceil(min);
|
|
13
|
+
max = Math.floor(max);
|
|
14
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default mintMath;
|
|
@@ -75,33 +75,6 @@ export abstract class mintSelectors {
|
|
|
75
75
|
*/
|
|
76
76
|
static subMenu: string = `${this.subMenuButtons} + ul${this.hasId}`;
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* Frequently-used ids
|
|
80
|
-
*/
|
|
81
|
-
static ids: {[key: string]: string | {[key: string]: string}} = {
|
|
82
|
-
header: this.prefix('header'),
|
|
83
|
-
logo: this.prefix('logo'),
|
|
84
|
-
wrapper: this.prefix('wrapper'),
|
|
85
|
-
mainContent: this.prefix('main-content')
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Classes
|
|
90
|
-
*/
|
|
91
|
-
static classes: {[key: string]: string | {[key: string]: string}} = {
|
|
92
|
-
sides: {
|
|
93
|
-
top: this.prefix('top'),
|
|
94
|
-
right: this.prefix('right'),
|
|
95
|
-
bottom: this.prefix('bottom'),
|
|
96
|
-
left: this.prefix('left')
|
|
97
|
-
},
|
|
98
|
-
srOnly: this.prefix('sr-only'),
|
|
99
|
-
js: this.prefix('js'),
|
|
100
|
-
ready: this.prefix('ready'),
|
|
101
|
-
fixed: this.prefix('fixed'),
|
|
102
|
-
open: this.prefix('open')
|
|
103
|
-
};
|
|
104
|
-
|
|
105
78
|
/**
|
|
106
79
|
* Adds the library prefix to the beginning of the provided string
|
|
107
80
|
* @param base - the string to be prefixed
|
|
@@ -175,24 +148,6 @@ export abstract class mintSelectors {
|
|
|
175
148
|
return typeof bool === 'boolean' ? `[aria-expanded="${bool}"]` : this.hasExpanded;
|
|
176
149
|
}
|
|
177
150
|
|
|
178
|
-
/**
|
|
179
|
-
* Returns the id of the requested element
|
|
180
|
-
*/
|
|
181
|
-
static getId (id?: string) : string {
|
|
182
|
-
return this.ids[id ?? -1] as string ?? '';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Returns the class of the requested element
|
|
187
|
-
*/
|
|
188
|
-
static getClass (className?: string, classGroup?: string) : string {
|
|
189
|
-
if (classGroup) {
|
|
190
|
-
let group: {[key: string]: string} = this.classes[classGroup] as {[key: string]: string};
|
|
191
|
-
return group[className ?? -1] ?? '';
|
|
192
|
-
}
|
|
193
|
-
return this.classes[className ?? -1] as string ?? '';
|
|
194
|
-
}
|
|
195
|
-
|
|
196
151
|
/**
|
|
197
152
|
* Returns a NodeList of HTMLElements within the given element that are focusable
|
|
198
153
|
* @param el - the element whose focusable children will be returned
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Imports
|
|
3
|
-
*/
|
|
4
|
-
import { mintSide } from '../enum';
|
|
5
|
-
import { mintSelectors } from './selectors';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Settings management
|
|
9
3
|
* @public
|
|
@@ -32,14 +26,16 @@ export abstract class mintSettings {
|
|
|
32
26
|
};
|
|
33
27
|
|
|
34
28
|
/**
|
|
35
|
-
*
|
|
29
|
+
* Breakpoint variables
|
|
36
30
|
*/
|
|
37
|
-
static
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
static break: {[key: string]: number} = {
|
|
32
|
+
z: 0,
|
|
33
|
+
xs: 480,
|
|
34
|
+
sm: 768,
|
|
35
|
+
md: 1024,
|
|
36
|
+
lg: 1200,
|
|
37
|
+
xl: 1440
|
|
38
|
+
};
|
|
43
39
|
|
|
44
40
|
/**
|
|
45
41
|
* Update the provided settings variables
|
|
@@ -65,12 +61,10 @@ export abstract class mintSettings {
|
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (typeof settings.fixed === 'boolean') {
|
|
73
|
-
this.setFixed(settings.fixed);
|
|
64
|
+
if (settings.break && Object.keys(settings.break).length) {
|
|
65
|
+
if (Object.values(settings.break).reduce((prev: any, next: any) => prev && typeof next === 'number', true)) {
|
|
66
|
+
this.break = {...this.break, ...settings.break};
|
|
67
|
+
}
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
|
|
@@ -87,34 +81,6 @@ export abstract class mintSettings {
|
|
|
87
81
|
slow: this.delayBase + this.delayStep * 5
|
|
88
82
|
};
|
|
89
83
|
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Updates the direction the navbar enters from
|
|
93
|
-
*/
|
|
94
|
-
protected static setFrom (from: mintSide) : void {
|
|
95
|
-
if (this.from !== from) {
|
|
96
|
-
this.from = from;
|
|
97
|
-
let header: HTMLElement | null = document.getElementById(mintSelectors.getId('header'));
|
|
98
|
-
header?.classList.remove(...Object.values(mintSelectors.classes.sides));
|
|
99
|
-
header?.classList.add(mintSelectors.getClass(mintSide[this.from].toLowerCase(), 'sides'));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Updates whether or not the navbar is fixed
|
|
105
|
-
*/
|
|
106
|
-
protected static setFixed (fixed: boolean) : void {
|
|
107
|
-
if (this.fixed !== fixed) {
|
|
108
|
-
this.fixed = fixed;
|
|
109
|
-
let header: HTMLElement | null = document.getElementById(mintSelectors.getId('header')),
|
|
110
|
-
fixedClass: string = mintSelectors.getClass('fixed');
|
|
111
|
-
if (this.fixed) {
|
|
112
|
-
header?.classList.add(fixedClass);
|
|
113
|
-
} else {
|
|
114
|
-
header?.classList.remove(fixedClass);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
84
|
};
|
|
119
85
|
|
|
120
86
|
export default mintSettings;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions related to the browser window.
|
|
3
|
-
*/
|
|
4
|
-
export abstract class mintWindow {
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Functions related to the browser window.
|
|
3
|
+
*/
|
|
4
|
+
export abstract class mintWindow {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
7
|
export default mintWindow;
|