@brightspace-ui/core 3.129.1 → 3.130.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.
@@ -5,7 +5,7 @@ import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
5
5
 
6
6
  export const descriptionListStyles = [
7
7
  _generateLabelStyles('d2l-dl-wrapper > dl > dt'),
8
- _generateBodyCompactStyles('d2l-dl-wrapper > dl > dd'),
8
+ _generateBodyCompactStyles('d2l-dl-wrapper > dl > dd', true),
9
9
  css`
10
10
  d2l-dl-wrapper {
11
11
  --d2l-dl-wrapper-dt-min-width: min-content;
@@ -3,7 +3,7 @@ import { _generateBodySmallStyles } from '../typography/styles.js';
3
3
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
4
4
 
5
5
  export const inlineHelpStyles = [
6
- _generateBodySmallStyles('.d2l-input-inline-help'),
6
+ _generateBodySmallStyles('.d2l-input-inline-help', true),
7
7
  css`
8
8
  .d2l-input-inline-help {
9
9
  margin-top: 0.3rem !important;
@@ -2,19 +2,45 @@ import '../colors/colors.js';
2
2
  import { css, unsafeCSS } from 'lit';
3
3
 
4
4
  export const _isValidCssSelector = (selector) => {
5
- if (selector === ':host') return true;
6
- const re = /([a-zA-Z0-9-_ >.#]+)(\[[a-zA-Z0-9-_]+\])?([a-zA-Z0-9-_ >.#]+)?/g;
7
- const match = selector.match(re);
5
+ const partIsValid = (part) => {
6
+ const re = /([a-zA-Z0-9-_ >.#]+)(\[[a-zA-Z0-9-_]+\])?([a-zA-Z0-9-_ >.#]+)?/g;
7
+ if (part === ':host') return true;
8
+ const match = part.match(re);
9
+ const isValid = !!match && match.length === 1 && match[0].length === part.length;
10
+ if (!isValid) {
11
+ console.warn(`Invalid CSS selector: "${part}"`);
12
+ }
13
+ return isValid;
14
+ };
8
15
 
9
- return !!match && match.length === 1 && match[0].length === selector.length;
16
+ const parts = selector.split(',');
17
+ const allValid = parts.every(part => partIsValid(part));
18
+ return allValid;
10
19
  };
11
20
 
21
+ /**
22
+ * A private helper method that should not be used by general consumers
23
+ */
24
+ export const _generateBodyStandardStyles = (selector) => {
25
+ if (!_isValidCssSelector(selector)) return;
26
+
27
+ selector = unsafeCSS(selector);
28
+ return css`
29
+ ${selector} {
30
+ font-size: 0.95rem;
31
+ font-weight: 400;
32
+ line-height: 1.4rem;
33
+ }
34
+ @media (max-width: 615px) {
35
+ ${selector} {
36
+ font-size: 0.8rem;
37
+ line-height: 1.2rem;
38
+ }
39
+ }
40
+ `;
41
+ };
12
42
  export const bodyStandardStyles = css`
13
- .d2l-body-standard {
14
- font-size: 0.95rem;
15
- font-weight: 400;
16
- line-height: 1.4rem;
17
- }
43
+ ${_generateBodyStandardStyles('.d2l-body-standard')}
18
44
  :host([skeleton]) .d2l-body-standard.d2l-skeletize::before {
19
45
  bottom: 0.35rem;
20
46
  top: 0.3rem;
@@ -29,10 +55,6 @@ export const bodyStandardStyles = css`
29
55
  max-height: 7rem;
30
56
  }
31
57
  @media (max-width: 615px) {
32
- .d2l-body-standard {
33
- font-size: 0.8rem;
34
- line-height: 1.2rem;
35
- }
36
58
  :host([skeleton]) .d2l-body-standard.d2l-skeletize::before {
37
59
  bottom: 0.3rem;
38
60
  top: 0.3rem;
@@ -72,16 +94,11 @@ export const _generateResetStyles = (selector) => {
72
94
  /**
73
95
  * A private helper method that should not be used by general consumers
74
96
  */
75
- export const _generateBodyCompactStyles = (selector) => {
97
+ export const _generateBodyCompactStyles = (selector, includeSkeleton = true) => {
76
98
  if (!_isValidCssSelector(selector)) return;
77
99
 
78
100
  selector = unsafeCSS(selector);
79
- return css`
80
- ${selector} {
81
- font-size: 0.8rem;
82
- font-weight: 400;
83
- line-height: 1.2rem;
84
- }
101
+ const skeletonStyles = includeSkeleton ? css`
85
102
  :host([skeleton]) ${selector}.d2l-skeletize::before {
86
103
  bottom: 0.3rem;
87
104
  top: 0.3rem;
@@ -95,26 +112,27 @@ export const _generateBodyCompactStyles = (selector) => {
95
112
  :host([skeleton]) ${selector}.d2l-skeletize-paragraph-5 {
96
113
  max-height: 6rem;
97
114
  }
115
+ ` : unsafeCSS('');
116
+ return css`
117
+ ${selector} {
118
+ font-size: 0.8rem;
119
+ font-weight: 400;
120
+ line-height: 1.2rem;
121
+ }
122
+ ${skeletonStyles}
98
123
  `;
99
124
  };
100
125
 
101
- export const bodyCompactStyles = _generateBodyCompactStyles('.d2l-body-compact');
126
+ export const bodyCompactStyles = _generateBodyCompactStyles('.d2l-body-compact', true);
102
127
 
103
128
  /**
104
129
  * A private helper method that should not be used by general consumers
105
130
  */
106
- export const _generateBodySmallStyles = (selector) => {
131
+ export const _generateBodySmallStyles = (selector, includeSkeleton = true) => {
107
132
  if (!_isValidCssSelector(selector)) return;
108
133
 
109
134
  selector = unsafeCSS(selector);
110
- return css`
111
- ${selector} {
112
- color: var(--d2l-color-tungsten);
113
- font-size: 0.7rem;
114
- font-weight: 400;
115
- line-height: 0.9rem;
116
- margin: auto;
117
- }
135
+ const skeletonStyles = includeSkeleton ? css`
118
136
  :host([skeleton]) ${selector}.d2l-skeletize::before {
119
137
  bottom: 0.25rem;
120
138
  top: 0.2rem;
@@ -142,19 +160,46 @@ export const _generateBodySmallStyles = (selector) => {
142
160
  :host([skeleton]) ${selector}.d2l-skeletize-paragraph-5 {
143
161
  max-height: 4.5rem;
144
162
  }
163
+ }` : unsafeCSS('');
164
+ return css`
165
+ ${selector} {
166
+ color: var(--d2l-color-tungsten);
167
+ font-size: 0.7rem;
168
+ font-weight: 400;
169
+ line-height: 0.9rem;
170
+ margin: auto;
145
171
  }
172
+ ${skeletonStyles}
146
173
  `;
147
174
  };
148
175
 
149
- export const bodySmallStyles = _generateBodySmallStyles('.d2l-body-small');
176
+ export const bodySmallStyles = _generateBodySmallStyles('.d2l-body-small', true);
150
177
 
178
+ /**
179
+ * A private helper method that should not be used by general consumers
180
+ */
181
+ export const _generateHeading1Styles = (selector) => {
182
+ if (!_isValidCssSelector(selector)) return;
183
+
184
+ selector = unsafeCSS(selector);
185
+ return css`
186
+ ${selector} {
187
+ font-size: 2rem;
188
+ font-weight: 400;
189
+ line-height: 2.4rem;
190
+ margin: 1.5rem 0 1.5rem 0;
191
+ }
192
+ @media (max-width: 615px) {
193
+ ${selector} {
194
+ font-size: 1.5rem;
195
+ line-height: 1.8rem;
196
+ }
197
+
198
+ }
199
+ `;
200
+ };
151
201
  export const heading1Styles = css`
152
- .d2l-heading-1 {
153
- font-size: 2rem;
154
- font-weight: 400;
155
- line-height: 2.4rem;
156
- margin: 1.5rem 0 1.5rem 0;
157
- }
202
+ ${_generateHeading1Styles('.d2l-heading-1')}
158
203
  :host([skeleton]) .d2l-heading-1.d2l-skeletize {
159
204
  height: 2.4rem;
160
205
  overflow: hidden;
@@ -164,10 +209,6 @@ export const heading1Styles = css`
164
209
  top: 0.45rem;
165
210
  }
166
211
  @media (max-width: 615px) {
167
- .d2l-heading-1 {
168
- font-size: 1.5rem;
169
- line-height: 1.8rem;
170
- }
171
212
  :host([skeleton]) .d2l-heading-1.d2l-skeletize {
172
213
  height: 1.8rem;
173
214
  }
@@ -178,13 +219,32 @@ export const heading1Styles = css`
178
219
  }
179
220
  `;
180
221
 
222
+ /**
223
+ * A private helper method that should not be used by general consumers
224
+ */
225
+ export const _generateHeading2Styles = (selector) => {
226
+ if (!_isValidCssSelector(selector)) return;
227
+
228
+ selector = unsafeCSS(selector);
229
+ return css`
230
+ ${selector} {
231
+ font-size: 1.5rem;
232
+ font-weight: 400;
233
+ line-height: 1.8rem;
234
+ margin: 1.5rem 0 1.5rem 0;
235
+ }
236
+ @media (max-width: 615px) {
237
+ ${selector} {
238
+ font-size: 1rem;
239
+ font-weight: 700;
240
+ line-height: 1.5rem;
241
+ }
242
+
243
+ }
244
+ `;
245
+ };
181
246
  export const heading2Styles = css`
182
- .d2l-heading-2 {
183
- font-size: 1.5rem;
184
- font-weight: 400;
185
- line-height: 1.8rem;
186
- margin: 1.5rem 0 1.5rem 0;
187
- }
247
+ ${_generateHeading2Styles('.d2l-heading-2')}
188
248
  :host([skeleton]) .d2l-heading-2.d2l-skeletize {
189
249
  height: 1.8rem;
190
250
  overflow: hidden;
@@ -194,11 +254,6 @@ export const heading2Styles = css`
194
254
  top: 0.35rem;
195
255
  }
196
256
  @media (max-width: 615px) {
197
- .d2l-heading-2 {
198
- font-size: 1rem;
199
- font-weight: 700;
200
- line-height: 1.5rem;
201
- }
202
257
  :host([skeleton]) .d2l-heading-2.d2l-skeletize {
203
258
  height: 1.5rem;
204
259
  }
@@ -209,13 +264,31 @@ export const heading2Styles = css`
209
264
  }
210
265
  `;
211
266
 
267
+ /**
268
+ * A private helper method that should not be used by general consumers
269
+ */
270
+ export const _generateHeading3Styles = (selector) => {
271
+ if (!_isValidCssSelector(selector)) return;
272
+
273
+ selector = unsafeCSS(selector);
274
+ return css`
275
+ ${selector} {
276
+ font-size: 1rem;
277
+ font-weight: 700;
278
+ line-height: 1.5rem;
279
+ margin: 1.5rem 0 1.5rem 0;
280
+ }
281
+ @media (max-width: 615px) {
282
+ ${selector} {
283
+ font-size: 0.8rem;
284
+ line-height: 1.2rem;
285
+ }
286
+
287
+ }
288
+ `;
289
+ };
212
290
  export const heading3Styles = css`
213
- .d2l-heading-3 {
214
- font-size: 1rem;
215
- font-weight: 700;
216
- line-height: 1.5rem;
217
- margin: 1.5rem 0 1.5rem 0;
218
- }
291
+ ${_generateHeading3Styles('.d2l-heading-3')}
219
292
  :host([skeleton]) .d2l-heading-3.d2l-skeletize {
220
293
  height: 1.5rem;
221
294
  overflow: hidden;
@@ -225,10 +298,6 @@ export const heading3Styles = css`
225
298
  top: 0.35rem;
226
299
  }
227
300
  @media (max-width: 615px) {
228
- .d2l-heading-3 {
229
- font-size: 0.8rem;
230
- line-height: 1.2rem;
231
- }
232
301
  :host([skeleton]) .d2l-heading-3.d2l-skeletize {
233
302
  height: 1.2rem;
234
303
  }
@@ -239,13 +308,24 @@ export const heading3Styles = css`
239
308
  }
240
309
  `;
241
310
 
311
+ /**
312
+ * A private helper method that should not be used by general consumers
313
+ */
314
+ export const _generateHeading4Styles = (selector) => {
315
+ if (!_isValidCssSelector(selector)) return;
316
+
317
+ selector = unsafeCSS(selector);
318
+ return css`
319
+ ${selector} {
320
+ font-size: 0.8rem;
321
+ font-weight: 700;
322
+ line-height: 1.2rem;
323
+ margin: 1.5rem 0 1.5rem 0;
324
+ }
325
+ `;
326
+ };
242
327
  export const heading4Styles = css`
243
- .d2l-heading-4 {
244
- font-size: 0.8rem;
245
- font-weight: 700;
246
- line-height: 1.2rem;
247
- margin: 1.5rem 0 1.5rem 0;
248
- }
328
+ ${_generateHeading4Styles('.d2l-heading-4')}
249
329
  :host([skeleton]) .d2l-heading-4.d2l-skeletize {
250
330
  height: 1.2rem;
251
331
  overflow: hidden;
@@ -259,10 +339,16 @@ export const heading4Styles = css`
259
339
  /**
260
340
  * A private helper method that should not be used by general consumers
261
341
  */
262
- export const _generateLabelStyles = (selector) => {
342
+ export const _generateLabelStyles = (selector, includeSkeleton = true) => {
263
343
  if (!_isValidCssSelector(selector)) return;
264
344
 
265
345
  selector = unsafeCSS(selector);
346
+ const skeletonStyles = includeSkeleton ? css`
347
+ :host([skeleton]) ${selector}.d2l-skeletize::before {
348
+ bottom: 0.25rem;
349
+ top: 0.15rem;
350
+ }
351
+ ` : unsafeCSS('');
266
352
  return css`
267
353
  ${selector} {
268
354
  font-size: 0.7rem;
@@ -270,14 +356,10 @@ export const _generateLabelStyles = (selector) => {
270
356
  letter-spacing: 0.2px;
271
357
  line-height: 0.9rem;
272
358
  }
273
- :host([skeleton]) ${selector}.d2l-skeletize::before {
274
- bottom: 0.25rem;
275
- top: 0.15rem;
276
- }
359
+ ${skeletonStyles}
277
360
  `;
278
361
  };
279
-
280
- export const labelStyles = _generateLabelStyles('.d2l-label-text');
362
+ export const labelStyles = _generateLabelStyles('.d2l-label-text', true);
281
363
 
282
364
  /**
283
365
  * A private helper method that should not be used by general consumers
@@ -407,3 +489,42 @@ export const fontFacesCss = `@font-face {
407
489
  url(${new URL(`${fonts.BCSansBoldItalic}.woff2`, importUrl)}) format('woff2'),
408
490
  url(${new URL(`${fonts.BCSansBoldItalic}.woff`, importUrl)}) format('woff');
409
491
  }`;
492
+
493
+ export const baseTypographyStyles = css`
494
+ ${unsafeCSS(fontFacesCss)}
495
+ html {
496
+ --d2l-document-direction: ltr;
497
+ --d2l-mirror-transform: none;
498
+ }
499
+ html[dir="rtl"] {
500
+ --d2l-document-direction: rtl;
501
+ --d2l-mirror-transform: scale(-1, 1);
502
+ }
503
+
504
+ .d2l-typography {
505
+ color: var(--d2l-color-ferrite);
506
+ display: block;
507
+ font-family: "Lato", "Lucida Sans Unicode", "Lucida Grande", sans-serif;
508
+ letter-spacing: 0.01rem;
509
+ }
510
+ ${_generateBodyStandardStyles('.d2l-typography', false)}
511
+ .d2l-typography p {
512
+ margin: 1rem 0;
513
+ }
514
+
515
+ .d2l-typography:lang(ar), .d2l-typography :lang(ar) {
516
+ font-family: "Segoe UI", "Geeza Pro", sans-serif;
517
+ }
518
+ .d2l-typography:lang(ja), .d2l-typography :lang(ja) {
519
+ font-family: "Hiragino Kaku Gothic Pro", "Meiyro", sans-serif;
520
+ }
521
+ .d2l-typography:lang(ko), .d2l-typography :lang(ko) {
522
+ font-family: "Apple SD Gothic Neo", Dotum, sans-serif;
523
+ }
524
+ .d2l-typography:lang(th), .d2l-typography :lang(th), .d2l-typography:lang(tha), .d2l-typography :lang(tha) {
525
+ font-family: "Noto Sans Thai", system-ui, Tahoma;
526
+ }
527
+ .d2l-typography:lang(zh), .d2l-typography :lang(zh) {
528
+ font-family: "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
529
+ }
530
+ `;
@@ -1,144 +1,30 @@
1
- import '../colors/colors.js';
2
- import { _generateBlockquoteStyles, fontFacesCss } from './styles.js';
1
+ import {
2
+ _generateBlockquoteStyles,
3
+ _generateBodyCompactStyles,
4
+ _generateBodySmallStyles,
5
+ _generateBodyStandardStyles,
6
+ _generateHeading1Styles,
7
+ _generateHeading2Styles,
8
+ _generateHeading3Styles,
9
+ _generateHeading4Styles,
10
+ _generateLabelStyles,
11
+ baseTypographyStyles
12
+ } from './styles.js';
3
13
 
4
14
  if (!document.head.querySelector('#d2l-typography-font-face')) {
5
15
  const style = document.createElement('style');
6
16
  style.id = 'd2l-typography-font-face';
7
17
  style.textContent = `
8
- * {
9
- --d2l-document-direction: ltr;
10
- --d2l-mirror-transform: none;
11
- }
12
-
13
- html[dir="rtl"] * {
14
- --d2l-document-direction: rtl;
15
- --d2l-mirror-transform: scale(-1, 1);
16
- }
17
-
18
- ${fontFacesCss}
19
-
20
- .d2l-typography {
21
- color: var(--d2l-color-ferrite);
22
- display: block;
23
- font-family: 'Lato', 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
24
- letter-spacing: 0.01rem;
25
- font-size: 0.95rem;
26
- font-weight: 400;
27
- line-height: 1.4rem;
28
- }
29
-
30
- .d2l-typography .d2l-body-standard {
31
- font-size: 0.95rem;
32
- font-weight: 400;
33
- line-height: 1.4rem;
34
- }
35
-
36
- .d2l-typography .d2l-body-compact {
37
- font-size: 0.8rem;
38
- font-weight: 400;
39
- line-height: 1.2rem;
40
- }
41
-
42
- .d2l-typography .d2l-body-small {
43
- color: var(--d2l-color-tungsten);
44
- font-size: 0.7rem;
45
- font-weight: 400;
46
- line-height: 0.9rem;
47
- margin: auto;
48
- }
49
-
50
- .d2l-typography .d2l-label-text {
51
- font-size: 0.7rem;
52
- line-height: 0.9rem;
53
- font-weight: 700;
54
- letter-spacing: 0.2px;
55
- }
56
-
57
- .d2l-typography p {
58
- margin: 1rem 0;
59
- }
60
-
61
- .d2l-typography:lang(ar),
62
- .d2l-typography :lang(ar) {
63
- font-family: 'Segoe UI', 'Geeza Pro', sans-serif;
64
- }
65
-
66
- .d2l-typography:lang(zh),
67
- .d2l-typography :lang(zh) {
68
- font-family: 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
69
- }
70
-
71
- .d2l-typography:lang(ko),
72
- .d2l-typography :lang(ko) {
73
- font-family: 'Apple SD Gothic Neo', Dotum, sans-serif;
74
- }
75
-
76
- .d2l-typography:lang(ja),
77
- .d2l-typography :lang(ja) {
78
- font-family: 'Hiragino Kaku Gothic Pro', 'Meiyro', sans-serif;
79
- }
80
-
81
- .d2l-typography:lang(th),
82
- .d2l-typography :lang(th),
83
- .d2l-typography:lang(tha),
84
- .d2l-typography :lang(tha) {
85
- font-family: 'Noto Sans Thai', system-ui, Tahoma;
86
- }
87
-
88
- .d2l-typography .d2l-heading-1 {
89
- font-size: 2rem;
90
- font-weight: 400;
91
- line-height: 2.4rem;
92
- margin: 1.5rem 0 1.5rem 0;
93
- }
94
-
95
- .d2l-typography .d2l-heading-2 {
96
- font-size: 1.5rem;
97
- font-weight: 400;
98
- line-height: 1.8rem;
99
- margin: 1.5rem 0 1.5rem 0;
100
- }
101
-
102
- .d2l-typography .d2l-heading-3 {
103
- font-size: 1rem;
104
- font-weight: 700;
105
- line-height: 1.5rem;
106
- margin: 1.5rem 0 1.5rem 0;
107
- }
108
-
109
- .d2l-typography .d2l-heading-4 {
110
- font-size: 0.8rem;
111
- font-weight: 700;
112
- line-height: 1.2rem;
113
- margin: 1.5rem 0 1.5rem 0;
114
- }
115
-
18
+ ${baseTypographyStyles}
19
+ ${_generateBodyStandardStyles('.d2l-typography .d2l-body-standard', false)}
20
+ ${_generateBodyCompactStyles('.d2l-typography .d2l-body-compact', false)}
21
+ ${_generateBodySmallStyles('.d2l-typography .d2l-body-small', false)}
22
+ ${_generateLabelStyles('.d2l-typography .d2l-label-text', false)}
23
+ ${_generateHeading1Styles('.d2l-typography .d2l-heading-1')}
24
+ ${_generateHeading2Styles('.d2l-typography .d2l-heading-2')}
25
+ ${_generateHeading3Styles('.d2l-typography .d2l-heading-3')}
26
+ ${_generateHeading4Styles('.d2l-typography .d2l-heading-4')}
116
27
  ${_generateBlockquoteStyles('.d2l-typography .d2l-blockquote')}
117
-
118
- @media (max-width: 615px) {
119
-
120
- .d2l-typography .d2l-body-standard {
121
- font-size: 0.8rem;
122
- line-height: 1.2rem;
123
- }
124
-
125
- .d2l-typography .d2l-heading-1 {
126
- font-size: 1.5rem;
127
- line-height: 1.8rem;
128
- }
129
-
130
- .d2l-typography .d2l-heading-2 {
131
- font-size: 1rem;
132
- font-weight: 700;
133
- line-height: 1.5rem;
134
- }
135
-
136
- .d2l-typography .d2l-heading-3 {
137
- font-size: 0.8rem;
138
- line-height: 1.2rem;
139
- }
140
-
141
- }
142
28
  `;
143
29
  document.head.appendChild(style);
144
30
  }
@@ -140,10 +140,6 @@
140
140
  font-size: 0.8rem;
141
141
  font-weight: 400;
142
142
  line-height: 1.2rem;
143
- @media (max-width: 615px) {
144
- font-size: 0.8rem;
145
- line-height: 1.2rem;
146
- }
147
143
  }
148
144
 
149
145
  @mixin d2l-body-small {
@@ -161,7 +157,6 @@
161
157
  margin: 1.5rem 0 1.5rem 0;
162
158
  @media (max-width: 615px) {
163
159
  font-size: 1.5rem;
164
- font-weight: 400;
165
160
  line-height: 1.8rem;
166
161
  }
167
162
  }
@@ -195,11 +190,6 @@
195
190
  font-weight: 700;
196
191
  line-height: 1.2rem;
197
192
  margin: 1.5rem 0 1.5rem 0;
198
- @media (max-width: 615px) {
199
- font-size: 0.8rem;
200
- font-weight: 700;
201
- line-height: 1.2rem;
202
- }
203
193
  }
204
194
 
205
195
  @mixin d2l-label-text {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.129.1",
3
+ "version": "3.130.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",