@appartmint/mint 0.13.4 → 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.
@@ -37,6 +37,18 @@
37
37
  #{class(buttons)} {
38
38
  justify-content: center;
39
39
  }
40
+
41
+ &-title {
42
+ #{class(title)} {
43
+ text-align: center;
44
+ }
45
+ }
46
+
47
+ &-btns {
48
+ #{class(buttons)} {
49
+ justify-content: center;
50
+ }
51
+ }
40
52
  }
41
53
 
42
54
  &#{class(stagger)} {
@@ -45,7 +57,6 @@
45
57
 
46
58
  @include break(sm) {
47
59
  flex-direction: row;
48
- width: calc(100% + $card-padding * 2);
49
60
  border-radius: 0;
50
61
  box-shadow: none;
51
62
  overflow: visible;
@@ -39,6 +39,18 @@
39
39
 
40
40
  @include break(lg) {
41
41
  position: absolute;
42
+ left: -1rem;
43
+ width: 100vw;
44
+ border: none;
45
+ padding: 0;
46
+ }
47
+
48
+ & + * {
49
+ #{class(grid)} {
50
+ @include break(lg) {
51
+ margin-bottom: -15%;
52
+ }
53
+ }
42
54
  }
43
55
  }
44
56
 
@@ -149,25 +149,68 @@
149
149
 
150
150
  &#{class(spread)} {
151
151
  @include break-max($header-break) {
152
- #{$has-controls + neg(controls(wrapper))} {
153
- display: none;
152
+ #{id(wrapper)} {
153
+ #{$has-controls} {
154
+ display: none;
154
155
 
155
- & + ul {
156
- display: flex !important;
157
- height: auto !important;
158
- margin-bottom: 1rem !important;
156
+ &+ul {
157
+ display: flex !important;
158
+ height: auto !important;
159
+ margin-bottom: 1rem !important;
160
+ }
159
161
  }
160
162
  }
161
163
  }
162
164
 
163
165
  &#{neg(class(expand))} {
164
- #{$has-controls + neg(controls(wrapper))} {
165
- display: none;
166
+ #{id(wrapper)} {
167
+ #{$has-controls} {
168
+ display: none;
166
169
 
167
- & + ul {
168
- display: flex !important;
169
- height: auto !important;
170
- margin-bottom: 1rem !important;
170
+ &+ul {
171
+ display: flex !important;
172
+ height: auto !important;
173
+ margin-bottom: 1rem;
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ &#{class(tray)} {
181
+ #{id(wrapper)} {
182
+ gap: 1.5rem;
183
+ font-size: 0.5em;
184
+
185
+ @include break(sm) {
186
+ max-width: 512px;
187
+ }
188
+
189
+ a, button {
190
+ padding: 0.75rem;
191
+ margin: 0.25rem 0;
192
+ line-height: 1;
193
+ }
194
+
195
+ nav {
196
+ &>ul {
197
+ flex-direction: column;
198
+ flex-wrap: nowrap;
199
+ justify-content: flex-start;
200
+ }
201
+
202
+ li {
203
+ width: 100%;
204
+ }
205
+
206
+ #{$has-controls} {
207
+ &+ul {
208
+ margin-bottom: 3rem !important;
209
+
210
+ &>li:first-child {
211
+ font-size: 1.5em;
212
+ }
213
+ }
171
214
  }
172
215
  }
173
216
  }
@@ -233,11 +276,12 @@
233
276
 
234
277
  #{class(logo)} {
235
278
  display: flex;
279
+ align-items: center;
236
280
  width: auto;
237
281
  text-decoration: none;
238
282
 
239
283
  img {
240
- max-width: css-var(header-height);
284
+ max-height: calc(2rem + css-var(header-height));
241
285
  }
242
286
  }
243
287
 
@@ -254,6 +298,7 @@
254
298
 
255
299
  @include states(hover) {
256
300
  background: css-var($header-link-back-hover);
301
+
257
302
  #{class(menu-icon)} {
258
303
 
259
304
  &,
@@ -412,6 +457,7 @@
412
457
  flex-wrap: nowrap;
413
458
  flex-shrink: 0;
414
459
  justify-content: flex-end;
460
+ margin-left: auto;
415
461
 
416
462
  a,
417
463
  button {
@@ -28,5 +28,5 @@ $width: 16;
28
28
  $height: 9;
29
29
  #{class($width + '-' + $height)} {
30
30
  @extend #{class(aspect)};
31
- padding-top: math.div($height, $width) * 100%;
31
+ padding-top: math.div($height, $width) * 100% !important;
32
32
  }
@@ -11,7 +11,7 @@
11
11
  @mixin mint-texture () {
12
12
  position: relative;
13
13
 
14
- &::before {
14
+ &::before, &::after {
15
15
  content: '';
16
16
  position: absolute;
17
17
  top: 0;
@@ -19,16 +19,29 @@
19
19
  width: 100%;
20
20
  height: 100%;
21
21
  pointer-events: none;
22
+ }
23
+
24
+ &::before {
22
25
  opacity: $texture-opacity;
23
26
  background-image: url($texture-bg);
24
27
  background-size: $texture-bg-size;
25
28
  background-position: $texture-bg-position;
26
- //z-index: 0;
27
29
  @if ($texture-blend) {
28
30
  mix-blend-mode: $texture-blend;
29
31
  }
30
32
  }
31
33
 
34
+ &::after {
35
+ opacity: $texture-alt-opacity;
36
+ background-size: $texture-alt-bg-size;
37
+ background-position: $texture-alt-bg-position;
38
+ mask-image: $texture-alt-mask;
39
+ @if ($texture-alt-blend) {
40
+ mix-blend-mode: $texture-alt-blend;
41
+ }
42
+ z-index: 1;
43
+ }
44
+
32
45
  & > * {
33
46
  position: relative;
34
47
  z-index: 10;
@@ -78,3 +91,15 @@
78
91
  @extend #{class(border)};
79
92
  }
80
93
  }
94
+
95
+ @if $texture-alt-bg and $texture-alt-num {
96
+ @for $num from 1 through $texture-alt-num {
97
+ #{class(texture-#{$num})} {
98
+ #{class(content)} {
99
+ &::after {
100
+ background-image: url('#{$texture-alt-bg}#{$num}.jpg');
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
@@ -138,6 +138,14 @@ $texture-bg-position: center !default;
138
138
  $texture-blend: null !default;
139
139
  $texture-opacity: 1 !default;
140
140
 
141
+ $texture-alt-bg: null !default;
142
+ $texture-alt-num: 0 !default;
143
+ $texture-alt-opacity: 1 !default;
144
+ $texture-alt-bg-size: cover !default;
145
+ $texture-alt-bg-position: center !default;
146
+ $texture-alt-mask: null !default;
147
+ $texture-alt-blend: null !default;
148
+
141
149
  $texture-border-width: 1.25rem !default;
142
150
  $texture-border-type: solid !default;
143
151
  $texture-border-color: null !default;
@@ -12,9 +12,12 @@ import mintSettings from '../util/settings';
12
12
  */
13
13
  export class mintHeader {
14
14
  /**
15
- * Last-logged window width
15
+ * Navbar settings
16
16
  */
17
- lastWidth: number = mintUtil.windowWidth();
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
- let defaultSettings: {[key: string]: any} = {
29
- from: mintSide.Top,
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(mintSelectors.getId('header'));
48
- this.el.mobileButton = this.el.header?.querySelector(mintSelectors.controls(mintSelectors.getId('wrapper'))) || null;
49
- this.el.wrapper = document.getElementById(mintSelectors.getId('wrapper'));
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
- //window.addEventListener('resize', mintUtil.throttleEvent(this.eHandleResize.bind(this), mintSettings.delay.default, { trailing: false }));
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: NodeListOf<HTMLElement> | undefined = this.el.header?.querySelectorAll(mintSelectors.focusable),
60
- lastFocusable: HTMLElement | undefined = focusables?.[focusables?.length - 1];
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: HTMLElement) => {
59
+ focusables?.forEach((focusable) => {
63
60
  focusable.addEventListener('keydown', mintUtil.throttleEvent(this.eHandleKeypress.bind(this)));
64
61
  });
65
62
 
66
- let menuButtons: NodeListOf<HTMLElement> | undefined = this.el.header?.querySelectorAll(mintSelectors.controls() + mintSelectors.neg(mintSelectors.controls(mintSelectors.ids.wrapper as string)));
67
- menuButtons?.forEach((menuButton: HTMLElement) => {
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
- if (mintSettings.fixed) {
80
- this.el.body?.classList.add(mintSelectors.getClass('fixed'));
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 (mintSettings.fixed !== true) {
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
- this.el.html.style.overflow = 'hidden';
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
- }, mintSettings.from === mintSide.Left ? mintSettings.delay.default : mintSettings.delay.instant);
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(mintSelectors.getClass('open'));
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(mintSelectors.getClass('open'));
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') === mintSelectors.ids.wrapper) {
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 (e: Event) : void {
256
- // Also check if resized from mobile to desktop
257
- if (mintUtil.windowWidth() !== this.lastWidth) {
258
- this.setMobileMenu();
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(mintSelectors.classes.open as string)) {
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(mintSelectors.getClass('open')) === false ) {
398
+ if (this.el.wrapper?.classList.contains('mint-open') === false ) {
374
399
  this.el.wrapper.style.display = 'none';
375
400
  }
376
401
  };
@@ -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
- * Side of the window the mobile navbar enters from
29
+ * Breakpoint variables
36
30
  */
37
- static from?: mintSide;
38
-
39
- /**
40
- * Whether the navbar is fixed or not
41
- */
42
- static fixed?: boolean;
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 (typeof settings.from === 'number') {
69
- this.setFrom(settings.from);
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;