@microsoft/atlas-css 3.29.0 → 3.31.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/tokens.ts CHANGED
@@ -421,11 +421,25 @@ export class Convert {
421
421
  }
422
422
  }
423
423
 
424
- function invalidValue(typ: any, val: any, key: any = ''): never {
425
- if (key) {
426
- throw Error(`Invalid value for key "${key}". Expected type ${JSON.stringify(typ)} but got ${JSON.stringify(val)}`);
424
+ function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
425
+ const prettyTyp = prettyTypeName(typ);
426
+ const parentText = parent ? ` on ${parent}` : '';
427
+ const keyText = key ? ` for key "${key}"` : '';
428
+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
429
+ }
430
+
431
+ function prettyTypeName(typ: any): string {
432
+ if (Array.isArray(typ)) {
433
+ if (typ.length === 2 && typ[0] === undefined) {
434
+ return `an optional ${prettyTypeName(typ[1])}`;
435
+ } else {
436
+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
437
+ }
438
+ } else if (typeof typ === "object" && typ.literal !== undefined) {
439
+ return typ.literal;
440
+ } else {
441
+ return typeof typ;
427
442
  }
428
- throw Error(`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`, );
429
443
  }
430
444
 
431
445
  function jsonToJSProps(typ: any): any {
@@ -446,10 +460,10 @@ function jsToJSONProps(typ: any): any {
446
460
  return typ.jsToJSON;
447
461
  }
448
462
 
449
- function transform(val: any, typ: any, getProps: any, key: any = ''): any {
463
+ function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
450
464
  function transformPrimitive(typ: string, val: any): any {
451
465
  if (typeof typ === typeof val) return val;
452
- return invalidValue(typ, val, key);
466
+ return invalidValue(typ, val, key, parent);
453
467
  }
454
468
 
455
469
  function transformUnion(typs: any[], val: any): any {
@@ -461,17 +475,17 @@ function transform(val: any, typ: any, getProps: any, key: any = ''): any {
461
475
  return transform(val, typ, getProps);
462
476
  } catch (_) {}
463
477
  }
464
- return invalidValue(typs, val);
478
+ return invalidValue(typs, val, key, parent);
465
479
  }
466
480
 
467
481
  function transformEnum(cases: string[], val: any): any {
468
482
  if (cases.indexOf(val) !== -1) return val;
469
- return invalidValue(cases, val);
483
+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
470
484
  }
471
485
 
472
486
  function transformArray(typ: any, val: any): any {
473
487
  // val must be an array with no invalid elements
474
- if (!Array.isArray(val)) return invalidValue("array", val);
488
+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
475
489
  return val.map(el => transform(el, typ, getProps));
476
490
  }
477
491
 
@@ -481,24 +495,24 @@ function transform(val: any, typ: any, getProps: any, key: any = ''): any {
481
495
  }
482
496
  const d = new Date(val);
483
497
  if (isNaN(d.valueOf())) {
484
- return invalidValue("Date", val);
498
+ return invalidValue(l("Date"), val, key, parent);
485
499
  }
486
500
  return d;
487
501
  }
488
502
 
489
503
  function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
490
504
  if (val === null || typeof val !== "object" || Array.isArray(val)) {
491
- return invalidValue("object", val);
505
+ return invalidValue(l(ref || "object"), val, key, parent);
492
506
  }
493
507
  const result: any = {};
494
508
  Object.getOwnPropertyNames(props).forEach(key => {
495
509
  const prop = props[key];
496
510
  const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
497
- result[prop.key] = transform(v, prop.typ, getProps, prop.key);
511
+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
498
512
  });
499
513
  Object.getOwnPropertyNames(val).forEach(key => {
500
514
  if (!Object.prototype.hasOwnProperty.call(props, key)) {
501
- result[key] = transform(val[key], additional, getProps, key);
515
+ result[key] = transform(val[key], additional, getProps, key, ref);
502
516
  }
503
517
  });
504
518
  return result;
@@ -507,10 +521,12 @@ function transform(val: any, typ: any, getProps: any, key: any = ''): any {
507
521
  if (typ === "any") return val;
508
522
  if (typ === null) {
509
523
  if (val === null) return val;
510
- return invalidValue(typ, val);
524
+ return invalidValue(typ, val, key, parent);
511
525
  }
512
- if (typ === false) return invalidValue(typ, val);
526
+ if (typ === false) return invalidValue(typ, val, key, parent);
527
+ let ref: any = undefined;
513
528
  while (typeof typ === "object" && typ.ref !== undefined) {
529
+ ref = typ.ref;
514
530
  typ = typeMap[typ.ref];
515
531
  }
516
532
  if (Array.isArray(typ)) return transformEnum(typ, val);
@@ -518,7 +534,7 @@ function transform(val: any, typ: any, getProps: any, key: any = ''): any {
518
534
  return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
519
535
  : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
520
536
  : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
521
- : invalidValue(typ, val);
537
+ : invalidValue(typ, val, key, parent);
522
538
  }
523
539
  // Numbers can be parsed by Date but shouldn't be.
524
540
  if (typ === Date && typeof val !== "number") return transformDate(val);
@@ -533,6 +549,10 @@ function uncast<T>(val: T, typ: any): any {
533
549
  return transform(val, typ, jsToJSONProps);
534
550
  }
535
551
 
552
+ function l(typ: any) {
553
+ return { literal: typ };
554
+ }
555
+
536
556
  function a(typ: any) {
537
557
  return { arrayItems: typ };
538
558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/atlas-css",
3
- "version": "3.29.0",
3
+ "version": "3.31.0",
4
4
  "description": "Styles backing the Atlas Design System used by Microsoft's Developer Relations.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -73,19 +73,19 @@
73
73
  "license": "MIT",
74
74
  "devDependencies": {
75
75
  "@microsoft/stylelint-config-atlas": "4.0.2",
76
- "@parcel/transformer-sass": "^2.7.0",
77
- "css-tree": "^2.2.1",
78
- "eslint-plugin-security": "^1.5.0",
79
- "fs-extra": "^10.1.0",
80
- "parcel": "^2.7.0",
81
- "lightningcss": "1.16.0",
82
- "prettier": "^2.7.1",
83
- "quicktype-core": "^6.0.62",
76
+ "@parcel/transformer-sass": "^2.8.3",
77
+ "css-tree": "^2.3.1",
78
+ "eslint-plugin-security": "^1.7.1",
79
+ "fs-extra": "^11.1.1",
80
+ "parcel": "^2.8.3",
81
+ "lightningcss": "1.19.0",
82
+ "prettier": "^2.8.7",
83
+ "quicktype-core": "^23.0.19",
84
84
  "grass": "^1.0.2",
85
85
  "sass-export": "^2.1.2",
86
- "stylelint": "^14.13.0",
87
- "stylelint-config-prettier": "^9.0.3",
88
- "stylelint-prettier": "^2.0.0",
86
+ "stylelint": "^14.16.1",
87
+ "stylelint-config-prettier": "^9.0.5",
88
+ "stylelint-prettier": "^3.0.0",
89
89
  "wireit": "^0.9.5"
90
90
  }
91
91
  }
@@ -164,6 +164,10 @@
164
164
 
165
165
  // Alignment
166
166
 
167
+ .text-align-left {
168
+ text-align: start !important;
169
+ }
170
+
167
171
  .text-align-center {
168
172
  text-align: center !important;
169
173
  }
@@ -173,6 +177,10 @@
173
177
  }
174
178
 
175
179
  @include tablet {
180
+ .text-align-left-tablet {
181
+ text-align: start !important;
182
+ }
183
+
176
184
  .text-align-center-tablet {
177
185
  text-align: center !important;
178
186
  }
@@ -181,3 +189,9 @@
181
189
  text-align: end !important;
182
190
  }
183
191
  }
192
+
193
+ // Line height
194
+
195
+ .line-height-normal {
196
+ line-height: 1.3;
197
+ }
@@ -0,0 +1,47 @@
1
+ $banner-background: $info-background !default;
2
+ $banner-padding: $spacer-5 !default;
3
+
4
+ $banner-font-size: $font-size-7 !default;
5
+ $banner-color: $info-dark !default;
6
+
7
+ $banner-border-color: $border-white-high-contrast !default;
8
+ $banner-border-width: $border-width !default;
9
+
10
+ .banner {
11
+ @extend %layout-gap;
12
+
13
+ display: block;
14
+ position: relative;
15
+ outline-color: $text;
16
+ background-color: $banner-background;
17
+ color: $banner-color;
18
+ font-size: $banner-font-size;
19
+ padding-block: $banner-padding;
20
+ word-wrap: break-word;
21
+ word-break: break-word;
22
+ border-block: $banner-border-width solid $banner-border-color;
23
+
24
+ &.is-loading {
25
+ color: transparent;
26
+
27
+ > :first-child {
28
+ margin-inline-start: calc($banner-padding + 0.375em);
29
+ }
30
+
31
+ &::before {
32
+ @include loader;
33
+
34
+ position: absolute;
35
+ border-color: transparent transparent $banner-color $banner-color;
36
+ }
37
+ }
38
+
39
+ a:not(.button) {
40
+ color: currentColor;
41
+ font-weight: $weight-semibold;
42
+
43
+ .theme-high-contrast & {
44
+ color: $hyperlink;
45
+ }
46
+ }
47
+ }
@@ -6,6 +6,8 @@ $button-background-color: $body-background !default;
6
6
  $button-lg-font-size: $font-size-6 !default;
7
7
  $button-sm-font-size: $font-size-8 !default;
8
8
 
9
+ $button-icon-font-size: 0.875em !default;
10
+
9
11
  $button-border-color: $text-subtle !default;
10
12
  $button-border-width: $control-border-width !default;
11
13
  $button-border-radius: $control-radius !default;
@@ -48,6 +50,8 @@ $button-font-weight: $weight-semibold !default;
48
50
  }
49
51
 
50
52
  .icon {
53
+ font-size: $button-icon-font-size;
54
+
51
55
  &:only-child {
52
56
  margin: 0;
53
57
  }
@@ -1,3 +1,4 @@
1
+ @import './banner.scss';
1
2
  @import './breadcrumbs.scss';
2
3
  @import './button.scss';
3
4
  @import './buttons.scss';
@@ -9,6 +10,7 @@
9
10
  @import './link-button.scss';
10
11
  @import './markdown.scss'; // must be ordered after code-block
11
12
  @import './media.scss';
13
+ @import './notification.scss';
12
14
  @import './icon.scss';
13
15
  @import './image.scss';
14
16
  @import './popover.scss';
@@ -0,0 +1,81 @@
1
+ $notification-background: $secondary-background !default;
2
+ $notification-padding: $spacer-5 !default;
3
+
4
+ $notification-font-size: $font-size-7 !default;
5
+ $notification-color: $text !default;
6
+
7
+ $notification-border-color: $control-border !default;
8
+ $notification-border-width: $border-width !default;
9
+ $notification-border-radius: $border-radius !default;
10
+
11
+ .notification {
12
+ display: block;
13
+ position: relative;
14
+ padding: $notification-padding;
15
+ border: $notification-border-width solid $notification-border-color;
16
+ border-radius: $notification-border-radius;
17
+ outline-color: $text;
18
+ background-color: $notification-background;
19
+ color: $notification-color;
20
+ font-size: $notification-font-size;
21
+ word-wrap: break-word;
22
+ word-break: break-word;
23
+
24
+ @each $name, $color-set in $colors {
25
+ $base: nth($color-set, $color-index-base);
26
+ $dark: nth($color-set, $color-index-dark);
27
+ $background: nth($color-set, $color-index-background);
28
+
29
+ &.notification-#{$name} {
30
+ border-color: $dark;
31
+ background-color: $background;
32
+ color: $dark;
33
+
34
+ &.is-loading::before {
35
+ border-color: transparent transparent $dark $dark;
36
+ }
37
+ }
38
+ }
39
+
40
+ &.is-loading {
41
+ color: transparent;
42
+
43
+ > :first-child {
44
+ margin-inline-start: calc($notification-padding + 0.375em);
45
+ }
46
+
47
+ &::before {
48
+ @include loader;
49
+
50
+ position: absolute;
51
+ inset-block-start: $notification-padding;
52
+ inset-inline-start: $notification-padding;
53
+ border-color: transparent transparent $notification-color $notification-color;
54
+ }
55
+ }
56
+
57
+ .notification-title,
58
+ a:not(.button) {
59
+ color: currentColor;
60
+ font-weight: $weight-semibold;
61
+ }
62
+
63
+ a:not(.button) {
64
+ .theme-high-contrast & {
65
+ color: $hyperlink;
66
+ }
67
+ }
68
+
69
+ .notification-title {
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: flex-start;
73
+ margin-block-end: $layout-1;
74
+
75
+ .icon {
76
+ flex-shrink: 0;
77
+ align-self: start;
78
+ margin-inline-end: 0.375em;
79
+ }
80
+ }
81
+ }
@@ -32,3 +32,7 @@ fieldset {
32
32
  min-width: 0; // as a replaced element min-width:0 is required to enable it to work in responsive layouts
33
33
  border: none;
34
34
  }
35
+
36
+ ::target-text {
37
+ background-color: $code-highlight-background;
38
+ }
package/tokens/README.md CHANGED
@@ -4,7 +4,7 @@ A design tokens is a definition of a design-related variable, such as one that a
4
4
 
5
5
  ## Access our design tokens
6
6
 
7
- Firstly, in order to access these tokens, you must have installed atlas-css in your project. [See installation steps]('https://github.com/microsoft/atlas-design'). Once this is complete, you'll need to decide whether you want to reference them in Scss or JSON.
7
+ Firstly, in order to access these tokens, you must have installed atlas-css in your project. [See installation steps](https://github.com/microsoft/atlas-design). Once this is complete, you'll need to decide whether you want to reference them in Scss or JSON.
8
8
 
9
9
  ### Get Scss from NPM
10
10