@uqds/header 0.0.5-alpha.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 ADDED
@@ -0,0 +1,30 @@
1
+ # `@uqds/header`
2
+
3
+ > Header component
4
+
5
+ ## Usage
6
+
7
+ ### Installation
8
+
9
+ With Yarn:
10
+ ```shell
11
+ yarn add @uqds/header
12
+ ```
13
+
14
+ With NPM:
15
+ ```shell
16
+ npm i @uqds/header
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Dependency graph
22
+
23
+ ```shell
24
+ @uqds/header
25
+ ├─ @uqds/core
26
+ ├─ @uqds/grid
27
+ │ └─ @uqds/core
28
+ └─ @uqds/icon
29
+ └─ @uqds/core
30
+ ```
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@uqds/header",
3
+ "version": "0.0.5-alpha.0",
4
+ "description": "Header component",
5
+ "keywords": [
6
+ "uqds",
7
+ "uq",
8
+ "University of Queensland",
9
+ "design system",
10
+ "scss",
11
+ "sass",
12
+ "css",
13
+ "header"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "author": {
19
+ "name": "University of Queensland",
20
+ "email": "webservices@uq.edu.au",
21
+ "url": "https://uq.edu.au"
22
+ },
23
+ "homepage": "https://github.com/uq-its-ss/design-system#readme",
24
+ "license": "ISC",
25
+ "directories": {
26
+ "lib": "src"
27
+ },
28
+ "files": [
29
+ "src/*"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/uq-its-ss/design-system.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/uq-its-ss/design-system/issues"
37
+ },
38
+ "dependencies": {
39
+ "@uqds/core": "^0.0.5-alpha.0",
40
+ "@uqds/grid": "^0.0.5-alpha.0",
41
+ "@uqds/icon": "^0.0.5-alpha.0"
42
+ },
43
+ "gitHead": "0d2250c3ff44460d2902ea08102e6423b3fcc3aa"
44
+ }
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Header module
5
+ * @file Handles interaction behaviour for the Header. Does not output any
6
+ * HTML elements.
7
+ * TODO: make this class configurable
8
+ */
9
+
10
+ class header {
11
+ constructor() {
12
+ this.init();
13
+ }
14
+
15
+ init() {
16
+ this.toggle = document.querySelector('.uq-header__search-toggle-button');
17
+ this.search = document.querySelector('.uq-header__search');
18
+ this.searchInput = document.querySelector('.uq-header__search-query-input');
19
+ this.meta = document.querySelector('meta.uq-header__mq--desktop');
20
+ this.navigation = document.querySelector('.uq-header__navigation');
21
+
22
+ if (this.meta == null) {
23
+ this.meta = document.createElement('meta');
24
+ this.meta.classList.add('uq-header__mq--desktop');
25
+ document.head.appendChild(this.meta);
26
+ };
27
+
28
+ this.mqLarge = window.getComputedStyle(this.meta).getPropertyValue('font-family');
29
+ this.mqLarge = this.mqLarge.trim().slice(1, -1); // browsers re-quote string style values
30
+ this.mqLargeList = window.matchMedia(this.mqLarge);
31
+
32
+ this.toggle.addEventListener('click', () => {
33
+ this.handleToggle();
34
+ });
35
+ }
36
+
37
+ handleToggle() {
38
+ this.toggle.classList.toggle('uq-header__search-toggle-button--icon-close');
39
+ this.search.classList.toggle('uq-header__search--open');
40
+ this.navigation.classList.toggle('uq-header__navigation--open');
41
+
42
+ if (this.search.classList.contains('uq-header__search--open')) {
43
+ if (this.mqLargeList.matches) {
44
+ this.searchInput.focus();
45
+ } else {
46
+ this.toggle.blur();
47
+ }
48
+ } else {
49
+ this.toggle.blur();
50
+ }
51
+ }
52
+ };
53
+
54
+ export {header as default};
@@ -0,0 +1,391 @@
1
+ @use '@uqds/core/src/scss/global' as core;
2
+ @use '@uqds/grid/src/scss/global' as grid;
3
+ @use "@uqds/icon/src/scss/global" as icon-constants;
4
+ @use '@uqds/form/src/scss/global' as form;
5
+ @use 'global' as *;
6
+
7
+ .uq-header {
8
+ background: core.$uq-purple;
9
+ background: core.$uq-purple-gradient;
10
+ box-sizing: border-box;
11
+ font-family: core.$font-body;
12
+ font-weight: core.$font-weight-thin;
13
+ line-height: core.$line-height;
14
+
15
+ &__container {
16
+ @include grid.layout-containment;
17
+ position: relative;
18
+ padding: core.$space core.$space-s 0;
19
+ display: grid;
20
+ grid-template-columns: auto auto;
21
+ grid-template-areas:
22
+ "logo toggle"
23
+ "search search"
24
+ "nav nav";
25
+ justify-items: center;
26
+
27
+ @media #{core.$screen-lg-up} {
28
+ padding: core.$space-m core.$space 0;
29
+ gap: core.$space-m;
30
+ grid-template-columns: auto auto min-content;
31
+ grid-template-areas:
32
+ "logo nav toggle"
33
+ "search search search";
34
+ }
35
+ }
36
+
37
+ &__logo {
38
+ grid-area: logo;
39
+ justify-self: start;
40
+
41
+ img {
42
+ height: 2.625rem;
43
+ vertical-align: middle;
44
+ }
45
+
46
+ &--large {
47
+ display: none;
48
+
49
+ @media only screen and (min-width: 78.5rem) {
50
+ display: block;
51
+ }
52
+ }
53
+
54
+ &--small {
55
+ @media only screen and (min-width: 78.5rem) {
56
+ display: none;
57
+ }
58
+ }
59
+ }
60
+
61
+ &__navigation {
62
+ grid-area: nav;
63
+
64
+ @media #{core.$screen-lg-up} {
65
+ justify-self: end;
66
+ display: flex;
67
+ }
68
+
69
+ &-container {
70
+ -webkit-column-count: 3;
71
+ -moz-column-count: 3;
72
+ column-count: 3;
73
+ list-style: none;
74
+ margin-bottom: core.$space;
75
+ padding: core.$space-none;
76
+ height: 0;
77
+ overflow: hidden;
78
+ width: 100%;
79
+
80
+ @media #{core.$screen-lg-up} {
81
+ justify-self: end;
82
+ display: flex;
83
+ align-content: flex-end;
84
+ align-items: center;
85
+ justify-content: center;
86
+ gap: core.$space-m;
87
+ margin: core.$space-none;
88
+ height: auto;
89
+ visibility: visible;
90
+ overflow: initial;
91
+
92
+ li {
93
+ margin: core.$space-none;
94
+ }
95
+ }
96
+ }
97
+
98
+ &--open {
99
+ width: 100%;
100
+
101
+ @media #{core.$screen-lg-up} {
102
+ width: auto;
103
+ }
104
+
105
+ .uq-header__navigation-container {
106
+ height: auto;
107
+ visibility: visible;
108
+ overflow: initial;
109
+ }
110
+ }
111
+
112
+
113
+
114
+ &-link {
115
+ color: core.$uq-white;
116
+ font-size: core.$font-size-s;
117
+ font-weight: core.$font-weight-thin;
118
+ text-decoration: none;
119
+
120
+ &:hover,
121
+ &:focus {
122
+ color: core.$uq-white;
123
+ text-decoration: underline;
124
+ }
125
+ }
126
+ }
127
+
128
+ &__search {
129
+ grid-area: search;
130
+ height: 0;
131
+ overflow: hidden;
132
+ visibility: hidden;
133
+ transition: height .25s, padding-top .25s, padding-bottom .25s;
134
+
135
+ &--open {
136
+ height: auto;
137
+ visibility: visible;
138
+ overflow: initial;
139
+ padding-top: core.$space-m;
140
+ padding-bottom: core.$space;
141
+ width: 100%;
142
+ }
143
+
144
+ &-toggle {
145
+ grid-area: toggle;
146
+ justify-self: end;
147
+
148
+ &-button {
149
+ margin: core.$space-s core.$space-none core.$space-none core.$space-none;
150
+ padding: core.$space-xs;
151
+ border: 0;
152
+ width: 1.5rem;
153
+ height: 1.5rem;
154
+ background-color: transparent;
155
+ text-indent: -100vw;
156
+ overflow: hidden;
157
+ position: relative;
158
+ cursor: pointer;
159
+ background-position: center center;
160
+
161
+ @media #{core.$screen-lg-up} {
162
+ margin: .75rem core.$space-none core.$space-none core.$space-none;
163
+ }
164
+
165
+ &::before {
166
+ content: "";
167
+ position: absolute;
168
+ display: block;
169
+ top: 0;
170
+ left: 0;
171
+ width: 100%;
172
+ height: 100%;
173
+ background-size: 100%;
174
+ background-image: url(icon-constants.get-icon('standard--search', core.$uq-white));
175
+ }
176
+
177
+ &--icon-close {
178
+ &::before {
179
+ background-image: url(icon-constants.get-icon('standard--close', core.$uq-white));
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ &-title {
186
+ color: core.$uq-white;
187
+ font-family: core.$merriweather;
188
+ font-size: core.$font-size;
189
+ font-style: italic;
190
+ font-weight: core.$font-weight-normal;
191
+ margin-bottom: form.$form-spacing;
192
+ line-height: core.$line-height-h;
193
+ padding: 0;
194
+
195
+ @media #{core.$screen-lg-up} {
196
+ display: inline-block;
197
+ float: left;
198
+ vertical-align: baseline;
199
+ }
200
+
201
+ @media #{core.$screen-xl-up} {
202
+ font-size: core.$font-size-l;
203
+ }
204
+ }
205
+
206
+ fieldset {
207
+ border: 0;
208
+ padding: 0;
209
+ margin: 0;
210
+ }
211
+
212
+ input[type="radio"] {
213
+ color: core.$uq-white;
214
+ border-radius: 50%;
215
+ appearance: none;
216
+ display: inline-block;
217
+ border: form.$form-checkbox-border-width solid form.$form-border-color;
218
+ cursor: pointer;
219
+ height: form.$form-checkbox-size;
220
+ width: form.$form-checkbox-size;
221
+ vertical-align: top;
222
+ position: absolute;
223
+
224
+ &:focus {
225
+ border-color: form.$form-focus-color;
226
+ box-shadow: 0 0 0 1px form.$form-focus-color;
227
+ outline: none;
228
+ }
229
+
230
+ + label {
231
+ color: core.$uq-white;
232
+ display: inline-block;
233
+ font-size: core.$font-size-s;
234
+ font-weight: core.$font-weight-normal;
235
+ line-height: core.$line-height-h;
236
+ margin-bottom: core.$space-none;
237
+ margin-left: core.$space-s;
238
+ margin-right: form.$form-spacing;
239
+ padding-top: core.$space-xs;
240
+ padding-left: core.$space-m;
241
+ vertical-align: top;
242
+ cursor: pointer;
243
+ }
244
+
245
+ &:checked {
246
+ border-width: 0.125rem;
247
+ border-color: core.$uq-white;
248
+
249
+ &::after {
250
+ border-radius: 50%;
251
+ background-color: core.$uq-white;
252
+ content: "";
253
+ display: block;
254
+ position: absolute;
255
+ top: 3px;
256
+ left: 3px;
257
+ height: form.$form-checkbox-size - 10px;
258
+ width: form.$form-checkbox-size - 10px;
259
+ }
260
+
261
+ &:focus {
262
+ border-color: form.$form-focus-color;
263
+ box-shadow: 0 0 0 1px form.$form-focus-color;
264
+ }
265
+ }
266
+ }
267
+
268
+ &-range {
269
+ display: block;
270
+ margin-bottom: core.$space;
271
+
272
+ @media #{core.$screen-lg-up} {
273
+ display: inline-block;
274
+ margin-left: core.$space;
275
+ line-height: 1.4;
276
+ }
277
+ }
278
+
279
+ &-query {
280
+ position: relative;
281
+ display: inline-block;
282
+ max-width: 100%;
283
+ min-width: 100%;
284
+ border-radius: 2px;
285
+ background-color: core.$uq-white;
286
+ background-position: 1rem;
287
+ margin-bottom: core.$space-s;
288
+
289
+ @media #{core.$screen-xl-up} {
290
+ margin-bottom: core.$space-m;
291
+ }
292
+
293
+ &-input {
294
+ background: transparent;
295
+ margin: core.$space-none !important;
296
+ width: 100%;
297
+ padding: .75rem 1rem;
298
+ border: 1px solid #e2e2e2;
299
+ border-radius: 2px;
300
+ box-shadow: none;
301
+ font-family: sans-serif;
302
+ font-size: core.$font-size;
303
+ line-height: 1;
304
+ color: core.$uq-neutral-dark80;
305
+ height: auto;
306
+ outline: none;
307
+
308
+ &:focus {
309
+ border-color: core.$link;
310
+ outline: none;
311
+ }
312
+ }
313
+
314
+ &-button {
315
+ background-clip: padding-box;
316
+ background-color: core.$uq-white;
317
+ border-radius: 5px;
318
+ border: 2px solid transparent;
319
+ color: core.$uq-purple;
320
+ display: inline-block;
321
+ font-size: core.$font-size;
322
+ height: 2.75rem;
323
+ line-height: core.$line-height;
324
+ margin-bottom: core.$space-none;
325
+ margin-right: core.$space-none;
326
+ overflow: hidden;
327
+ position: absolute;
328
+ right: 0;
329
+ text-decoration: none;
330
+ text-indent: 0;
331
+ top: calc(50% - 1.375rem);
332
+ transition: color .2s, background-color .2s, border-color .2s;
333
+ width: 2.75rem;
334
+
335
+ &:hover {
336
+ background-color: core.$uq-white;
337
+ border-color: core.$uq-purple;
338
+ color: core.$uq-purple
339
+ }
340
+
341
+ &::before {
342
+ content: "";
343
+ position: absolute;
344
+ display: block;
345
+ width: 1.5rem;
346
+ height: 1.5rem;
347
+ top: .5rem;
348
+ left: .5rem;
349
+ background-size: 100%;
350
+ background-image: url(icon-constants.get-icon('standard--search', core.$uq-purple));
351
+ }
352
+ }
353
+
354
+ &-submit {
355
+ color: transparent;
356
+ position: relative;
357
+ display: block;
358
+ width: 100%;
359
+ height: 100%;
360
+ margin: core.$space-none;
361
+ border: 0;
362
+ background-color: transparent;
363
+ z-index: 3;
364
+ cursor: pointer;
365
+ outline-offset: -2px;
366
+ font-size: core.$font-size;
367
+ }
368
+ }
369
+ }
370
+
371
+ // Visibility utility classes
372
+ .hidden {
373
+ display: none;
374
+ }
375
+
376
+ .visually-hidden {
377
+ position: absolute !important;
378
+ overflow: hidden;
379
+ clip: rect(1px,1px,1px,1px);
380
+ width: 1px;
381
+ height: 1px;
382
+ word-wrap: normal;
383
+ margin: core.$space-none;
384
+ padding: core.$space-none;
385
+ }
386
+
387
+ // JS helpers:
388
+ &__mq--desktop {
389
+ font-family: "#{core.$screen-lg-up}";
390
+ }
391
+ }
@@ -0,0 +1 @@
1
+ // Variables, functions, and mixins