@cfpb/cfpb-design-system 5.2.0 → 5.3.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +70 -1
  2. package/dist/index.css +1 -1
  3. package/dist/index.js +1761 -1708
  4. package/package.json +1 -1
  5. package/src/elements/abstracts/custom-props.css +2 -1
  6. package/src/elements/abstracts/vars.css +1 -6
  7. package/src/elements/base/base.scss +3 -0
  8. package/src/elements/base/font.scss +1 -1
  9. package/src/elements/cfpb-button/cfpb-button.scss +1 -1
  10. package/src/elements/cfpb-button/index.js +1 -1
  11. package/src/elements/cfpb-checkbox-icon/index.js +1 -1
  12. package/src/elements/cfpb-expandable/index.js +6 -8
  13. package/src/elements/cfpb-expandable/{cfpb-expandable.component.scss → styles.component.scss} +1 -1
  14. package/src/elements/cfpb-file-upload/index.js +1 -1
  15. package/src/elements/cfpb-file-upload/styles.component.css +7 -0
  16. package/src/elements/cfpb-flag-usa/index.js +1 -1
  17. package/src/elements/cfpb-flag-usa/{cfpb-flag-usa.component.scss → styles.component.css} +2 -2
  18. package/src/elements/cfpb-form-alert/index.js +21 -11
  19. package/src/elements/cfpb-form-alert/styles.component.scss +14 -0
  20. package/src/elements/cfpb-form-choice/index.js +1 -1
  21. package/src/elements/cfpb-form-choice/{cfpb-form-choice.component.scss → styles.component.scss} +5 -6
  22. package/src/elements/cfpb-form-search/index.js +5 -5
  23. package/src/elements/cfpb-form-search/skeleton.css +8 -0
  24. package/src/elements/cfpb-form-search/{cfpb-form-search.component.scss → styles.component.scss} +3 -3
  25. package/src/elements/cfpb-form-search-input/index.js +6 -9
  26. package/src/elements/cfpb-form-search-input/{cfpb-form-search-input.component.scss → styles.component.scss} +6 -8
  27. package/src/elements/cfpb-icon/index.js +43 -0
  28. package/src/elements/cfpb-icon/styles.component.css +48 -0
  29. package/src/elements/cfpb-icon-text/index.js +1 -1
  30. package/src/elements/cfpb-icon-text/{cfpb-icon-text.component.scss → styles.component.scss} +2 -3
  31. package/src/elements/cfpb-label/index.js +1 -1
  32. package/src/elements/cfpb-label/{cfpb-label.component.scss → styles.component.scss} +5 -5
  33. package/src/elements/{cfpb-list → cfpb-listbox}/index.js +10 -9
  34. package/src/elements/{cfpb-list → cfpb-listbox}/index.spec.js +9 -9
  35. package/src/elements/{cfpb-list/cfpb-list.component.scss → cfpb-listbox/styles.component.scss} +1 -5
  36. package/src/elements/{cfpb-list-item → cfpb-listbox-item}/index.js +5 -5
  37. package/src/elements/{cfpb-list-item/cfpb-list-item.component.scss → cfpb-listbox-item/styles.component.scss} +2 -2
  38. package/src/elements/cfpb-pagination/index.js +6 -5
  39. package/src/elements/cfpb-pagination/{cfpb-pagination.component.scss → styles.component.scss} +6 -6
  40. package/src/elements/cfpb-select/index.js +9 -12
  41. package/src/elements/cfpb-select/multiple-select-event-proxy.js +2 -2
  42. package/src/elements/cfpb-select/single-select-event-proxy.js +1 -1
  43. package/src/elements/cfpb-select/{cfpb-select.component.scss → styles.component.scss} +5 -6
  44. package/src/elements/cfpb-tag-filter/index.js +1 -1
  45. package/src/elements/cfpb-tag-filter/{cfpb-tag-filter.component.scss → styles.component.scss} +6 -8
  46. package/src/elements/cfpb-tag-group/index.js +1 -1
  47. package/src/elements/cfpb-tag-group/{cfpb-tag-group.component.scss → styles.component.scss} +3 -4
  48. package/src/elements/cfpb-tag-topic/index.js +1 -1
  49. package/src/elements/cfpb-tag-topic/{cfpb-tag-topic.component.scss → styles.component.scss} +2 -2
  50. package/src/elements/cfpb-tagline/index.js +1 -1
  51. package/src/elements/cfpb-tagline/skeleton.css +7 -0
  52. package/src/elements/cfpb-tagline/{cfpb-tagline.component.scss → styles.component.scss} +3 -4
  53. package/src/elements/cfpb-utilities/fallback/wc-fallback.css +31 -0
  54. package/src/elements/cfpb-utilities/fallback/wc-fallback.js +65 -0
  55. package/src/elements/cfpb-utilities/shared-config.js +41 -0
  56. package/src/elements/cfpb-utilities/skeleton.css +33 -0
  57. package/src/elements/cfpb-utilities/transition/{transition.scss → transition.css} +11 -11
  58. package/src/elements/index.js +11 -2
  59. package/src/index.js +1 -5
  60. package/src/index.scss +1 -1
  61. package/src/tokens/abstracts/custom-props.json +13 -1
  62. package/src/utilities/functions.scss +20 -0
  63. package/src/elements/base/index.js +0 -2
  64. package/src/elements/cfpb-file-upload/cfpb-file-upload.component.scss +0 -10
  65. package/src/elements/cfpb-form-alert/cfpb-form-alert.component.scss +0 -36
  66. /package/src/elements/cfpb-button/{cfpb-button.component.scss → styles.component.scss} +0 -0
  67. /package/src/elements/cfpb-checkbox-icon/{cfpb-checkbox-icon.component.scss → styles.component.scss} +0 -0
@@ -0,0 +1,41 @@
1
+ const DEFAULT_CONFIG = {
2
+ iconPath: './icons/',
3
+ };
4
+
5
+ let config = { ...DEFAULT_CONFIG };
6
+ let initialized = false;
7
+
8
+ const ALLOWED_KEYS = Object.keys(DEFAULT_CONFIG);
9
+
10
+ /**
11
+ * Set the shared configuration for the project.
12
+ * @param {object} userConfig - User supplied settings that override DEFAULT_CONFIG settings.
13
+ */
14
+ export function setSharedConfig(userConfig) {
15
+ if (initialized) {
16
+ // eslint-disable-next-line no-console
17
+ console.warn('CFPB Design System config already initialized');
18
+ return;
19
+ }
20
+
21
+ for (const key of Object.keys(userConfig)) {
22
+ if (!ALLOWED_KEYS.includes(key)) {
23
+ // eslint-disable-next-line no-console
24
+ console.warn(`CFPB Design System invalid config key: ${key}`);
25
+ }
26
+ }
27
+
28
+ config = {
29
+ ...config,
30
+ ...userConfig,
31
+ };
32
+
33
+ initialized = true;
34
+ }
35
+
36
+ /**
37
+ * @returns {object} The shared config used in the project.
38
+ */
39
+ export function getSharedConfig() {
40
+ return config;
41
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ This file defines a "loading skeleton", which is a wireframe-esque box that loads
3
+ in before a web component has been initialized.
4
+
5
+ Each component that has a loading skeleton also has a file similar to this one,
6
+ which defines the dimensions of the box that should load.
7
+
8
+ Having a loading skeleton avoids a layout shift when the component is actually
9
+ initialized and rendered.
10
+ */
11
+ *:not(:defined) {
12
+ display: block;
13
+ width: 100%;
14
+
15
+ box-shadow: 0 0 3px rgb(90, 93, 97, 10%) inset;
16
+ border-radius: 4px;
17
+
18
+ animation: pulse-background 1.5s infinite;
19
+ }
20
+
21
+ @keyframes pulse-background {
22
+ 0% {
23
+ background-color: transparent;
24
+ }
25
+
26
+ 50% {
27
+ background-color: rgb(90, 93, 97, 5%);
28
+ }
29
+
30
+ 100% {
31
+ background-color: transparent;
32
+ }
33
+ }
@@ -9,9 +9,9 @@
9
9
  transition-duration: 0s !important;
10
10
  }
11
11
 
12
- //
13
- // Utility classes for moving an element using transform translate values.
14
- //
12
+ /**
13
+ * Utility classes for moving an element using transform translate values.
14
+ */
15
15
 
16
16
  .u-move-transition {
17
17
  transition: transform 0.25s ease-out;
@@ -25,7 +25,7 @@
25
25
  transform: translate3d(-100%, 0, 0);
26
26
  }
27
27
 
28
- // TODO: Look into adding a mixin for movement multiples.
28
+ /* TODO: Look into adding a mixin for movement multiples. */
29
29
  .u-move-left-2x {
30
30
  transform: translate3d(-200%, 0, 0);
31
31
  }
@@ -42,9 +42,9 @@
42
42
  transform: translate3d(0, -100%, 0);
43
43
  }
44
44
 
45
- //
46
- // Utility classes for setting an element's opacity.
47
- //
45
+ /**
46
+ * Utility classes for setting an element's opacity.
47
+ */
48
48
 
49
49
  .u-alpha-transition {
50
50
  transition: opacity 0.25s linear;
@@ -58,15 +58,15 @@
58
58
  opacity: 0;
59
59
  }
60
60
 
61
- //
62
- // Utility classes for setting an element's height.
63
- //
61
+ /**
62
+ * Utility classes for setting an element's height.
63
+ */
64
64
 
65
65
  .u-max-height-transition {
66
66
  overflow: hidden;
67
67
  contain: paint;
68
68
 
69
- // Duration is set here, but it is actually overridden in the JavaScript.
69
+ /* Duration is set here, but it is actually overridden in the JavaScript. */
70
70
  transition: max-height 0.2s ease-out;
71
71
  }
72
72
 
@@ -3,14 +3,23 @@
3
3
  ========================================================================== */
4
4
 
5
5
  // TODO: aggregate and export the component subdirectories automatically.
6
+
7
+ // Base styles.
8
+ export * from './abstracts';
9
+
10
+ // Shared config.
11
+ export * from './cfpb-utilities/shared-config';
12
+
13
+ // Component styles.
6
14
  export * from './cfpb-button';
7
15
  export * from './cfpb-form-alert';
8
16
  export * from './cfpb-expandable';
9
17
  export * from './cfpb-form-choice';
10
18
  export * from './cfpb-file-upload';
19
+ export * from './cfpb-icon';
11
20
  export * from './cfpb-label';
12
- export * from './cfpb-list';
13
- export * from './cfpb-list-item';
21
+ export * from './cfpb-listbox';
22
+ export * from './cfpb-listbox-item';
14
23
  export * from './cfpb-form-search';
15
24
  export * from './cfpb-form-search-input';
16
25
  export * from './cfpb-tagline';
package/src/index.js CHANGED
@@ -2,9 +2,7 @@
2
2
  Design System
3
3
  ========================================================================== */
4
4
 
5
- export * from './elements/abstracts';
6
-
7
- export * from './elements/base';
5
+ export * from './elements';
8
6
 
9
7
  export * from './components/cfpb-buttons';
10
8
  export * from './components/cfpb-expandables';
@@ -17,5 +15,3 @@ export * from './components/cfpb-tables';
17
15
  export * from './components/cfpb-typography';
18
16
 
19
17
  export * from './utilities';
20
-
21
- export * from './elements';
package/src/index.scss CHANGED
@@ -74,4 +74,4 @@
74
74
  @forward 'elements/cfpb-button/vars';
75
75
 
76
76
  // cfpb-icon-text
77
- @forward 'elements/cfpb-icon-text/cfpb-icon-text.component';
77
+ @forward 'elements/cfpb-icon-text/styles.component';
@@ -2321,7 +2321,7 @@
2321
2321
  },
2322
2322
  "font-stack": {
2323
2323
  "$type": "string",
2324
- "$value": "system-ui,sans-serif",
2324
+ "$value": "var(--font-stack-branded, system-ui, sans-serif)",
2325
2325
  "$extensions": {
2326
2326
  "com.figma.variableId": "VariableID:8191:7009",
2327
2327
  "com.figma.scopes": [
@@ -2331,6 +2331,18 @@
2331
2331
  "com.figma.isOverride": true
2332
2332
  }
2333
2333
  },
2334
+ "font-stack-branded": {
2335
+ "$type": "string",
2336
+ "$value": "initial",
2337
+ "$extensions": {
2338
+ "com.figma.variableId": "VariableID:9617:2",
2339
+ "com.figma.scopes": [
2340
+ "ALL_SCOPES"
2341
+ ],
2342
+ "com.figma.type": "string",
2343
+ "com.figma.isOverride": true
2344
+ }
2345
+ },
2334
2346
  "$extensions": {
2335
2347
  "com.figma.modeName": "default"
2336
2348
  }
@@ -0,0 +1,20 @@
1
+ @use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
2
+
3
+ /*
4
+ The native CSS implementation of the below would look like:
5
+
6
+ @function --rem-from-px(--px <length>, --base <length>: 16px) returns <length> {
7
+ result: calc((var(--px) / var(--base)) * 1rem);
8
+ }
9
+
10
+ This can be swapped in when browser coverage is added to Firefox and Safari
11
+ See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@function
12
+ */
13
+
14
+ @function rem-from-px($px, $base: $base-font-size-px) {
15
+ @return calc(($px / $base) * 1rem);
16
+ }
17
+
18
+ @function unitless-from-px($px, $base: $base-font-size-px) {
19
+ @return calc($px / $base);
20
+ }
@@ -1,2 +0,0 @@
1
- export * as normalizeStyles from './normalize.scss';
2
- export * as baseStyles from './base.scss';
@@ -1,10 +0,0 @@
1
- @use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
2
- @use '@cfpb/cfpb-design-system/src/elements/cfpb-button/vars' as *;
3
-
4
- :host {
5
- // This prevents the child button from having an empty gap after the button.
6
- display: flex;
7
- width: fit-content;
8
-
9
- flex-direction: column;
10
- }
@@ -1,36 +0,0 @@
1
- @use 'sass:math';
2
- @use '@cfpb/cfpb-design-system/src/elements/abstracts' as *;
3
- @use '@cfpb/cfpb-design-system/src/components/cfpb-icons/icon' as *;
4
-
5
- :host {
6
- .a-form-alert {
7
- // Theme
8
- --form-alert-icon-color: var(--form-alert-icon-color-default);
9
-
10
- margin-top: math.div(15px, $base-font-size-px) + rem;
11
- display: flex;
12
- gap: math.div(5px, $base-font-size-px) + rem;
13
-
14
- .cf-icon-svg {
15
- color: var(--form-alert-icon-color);
16
- flex: none;
17
- margin-top: math.div(1px, $base-font-size-px) + rem;
18
- }
19
-
20
- &__text {
21
- display: block;
22
- }
23
-
24
- &--success .cf-icon-svg {
25
- --form-alert-icon-color: var(--form-alert-icon-color-success);
26
- }
27
-
28
- &--warning .cf-icon-svg {
29
- --form-alert-icon-color: var(--form-alert-icon-color-warning);
30
- }
31
-
32
- &--error .cf-icon-svg {
33
- --form-alert-icon-color: var(--form-alert-icon-color-error);
34
- }
35
- }
36
- }