@momentum-design/components 0.120.7 → 0.120.9

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.
@@ -38,11 +38,6 @@ declare const Badge_base: import("../../utils/mixins/index.types").Constructor<i
38
38
  *
39
39
  * @csspart badge-dot - The dot notification badge.
40
40
  * @csspart badge-icon - The icon badge.
41
- * @csspart badge-icon__error - The error icon badge.
42
- * @csspart badge-icon__primary - The primary icon badge.
43
- * @csspart badge-icon__secondary - The secondary icon badge.
44
- * @csspart badge-icon__success - The success icon badge.
45
- * @csspart badge-icon__warning - The warning icon badge.
46
41
  * @csspart badge-overlay - The overlay badge.
47
42
  * @csspart badge-text - The text badge.
48
43
  */
@@ -93,7 +88,6 @@ declare class Badge extends Badge_base {
93
88
  /**
94
89
  * Method to generate the badge icon.
95
90
  * @param iconName - the name of the icon from the icon set
96
- * @param backgroundPartPostfix - postfix for the part to style the badge icon.
97
91
  * @returns the template result of the icon.
98
92
  */
99
93
  private getBadgeIcon;
@@ -14,7 +14,7 @@ import { Component } from '../../models';
14
14
  import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
15
15
  import { ROLE } from '../../utils/roles';
16
16
  import { TYPE as FONT_TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
17
- import { DEFAULTS, ICON_NAMES_LIST, ICON_STATE, ICON_VARIANT, TYPE as BADGE_TYPE } from './badge.constants';
17
+ import { DEFAULTS, ICON_NAMES_LIST, ICON_VARIANT, TYPE as BADGE_TYPE } from './badge.constants';
18
18
  import styles from './badge.styles';
19
19
  /**
20
20
  * The `mdc-badge` component is a versatile UI element used to
@@ -52,11 +52,6 @@ import styles from './badge.styles';
52
52
  *
53
53
  * @csspart badge-dot - The dot notification badge.
54
54
  * @csspart badge-icon - The icon badge.
55
- * @csspart badge-icon__error - The error icon badge.
56
- * @csspart badge-icon__primary - The primary icon badge.
57
- * @csspart badge-icon__secondary - The secondary icon badge.
58
- * @csspart badge-icon__success - The success icon badge.
59
- * @csspart badge-icon__warning - The warning icon badge.
60
55
  * @csspart badge-overlay - The overlay badge.
61
56
  * @csspart badge-text - The text badge.
62
57
  */
@@ -113,13 +108,12 @@ class Badge extends IconNameMixin(Component) {
113
108
  /**
114
109
  * Method to generate the badge icon.
115
110
  * @param iconName - the name of the icon from the icon set
116
- * @param backgroundPartPostfix - postfix for the part to style the badge icon.
117
111
  * @returns the template result of the icon.
118
112
  */
119
- getBadgeIcon(iconName, backgroundPartPostfix) {
113
+ getBadgeIcon(iconName) {
120
114
  return html `
121
115
  <mdc-icon
122
- part="badge-icon ${this.overlay ? 'badge-overlay' : ''} badge-icon__${backgroundPartPostfix}"
116
+ part="badge-icon ${this.overlay ? 'badge-overlay' : ''}"
123
117
  name="${ifDefined(iconName)}"
124
118
  size="${DEFAULTS.ICON_SIZE}"
125
119
  ></mdc-icon>
@@ -171,18 +165,18 @@ class Badge extends IconNameMixin(Component) {
171
165
  if (this.variant && !Object.values(ICON_VARIANT).includes(this.variant)) {
172
166
  this.variant = DEFAULTS.VARIANT;
173
167
  }
174
- const { iconName, type, variant } = this;
168
+ const { iconName, type } = this;
175
169
  switch (type) {
176
170
  case BADGE_TYPE.ICON:
177
- return this.getBadgeIcon(iconName || '', variant);
171
+ return this.getBadgeIcon(iconName || '');
178
172
  case BADGE_TYPE.COUNTER:
179
173
  return this.getBadgeCounterText();
180
174
  case BADGE_TYPE.SUCCESS:
181
- return this.getBadgeIcon(ICON_NAMES_LIST.SUCCESS_ICON_NAME, ICON_STATE.SUCCESS);
175
+ return this.getBadgeIcon(ICON_NAMES_LIST.SUCCESS_ICON_NAME);
182
176
  case BADGE_TYPE.WARNING:
183
- return this.getBadgeIcon(ICON_NAMES_LIST.WARNING_ICON_NAME, ICON_STATE.WARNING);
177
+ return this.getBadgeIcon(ICON_NAMES_LIST.WARNING_ICON_NAME);
184
178
  case BADGE_TYPE.ERROR:
185
- return this.getBadgeIcon(ICON_NAMES_LIST.ERROR_ICON_NAME, ICON_STATE.ERROR);
179
+ return this.getBadgeIcon(ICON_NAMES_LIST.ERROR_ICON_NAME);
186
180
  case BADGE_TYPE.DOT:
187
181
  default:
188
182
  this.type = BADGE_TYPE.DOT;
@@ -1,3 +1,4 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-badge";
2
3
  declare const TYPE: {
3
4
  readonly DOT: "dot";
@@ -8,26 +9,14 @@ declare const TYPE: {
8
9
  readonly ERROR: "error";
9
10
  };
10
11
  declare const ICON_NAMES_LIST: {
11
- readonly SUCCESS_ICON_NAME: "check-circle-badge-filled";
12
- readonly WARNING_ICON_NAME: "warning-badge-filled";
13
- readonly ERROR_ICON_NAME: "error-legacy-badge-filled";
12
+ readonly SUCCESS_ICON_NAME: Extract<IconNames, "check-circle-badge-filled">;
13
+ readonly WARNING_ICON_NAME: Extract<IconNames, "warning-badge-filled">;
14
+ readonly ERROR_ICON_NAME: Extract<IconNames, "error-legacy-badge-filled">;
14
15
  };
15
16
  declare const ICON_VARIANT: {
16
17
  readonly PRIMARY: "primary";
17
18
  readonly SECONDARY: "secondary";
18
19
  };
19
- declare const ICON_STATE: {
20
- readonly SUCCESS: "success";
21
- readonly WARNING: "warning";
22
- readonly ERROR: "error";
23
- };
24
- declare const BACKGROUND_STYLES: {
25
- readonly SUCCESS: "success";
26
- readonly WARNING: "warning";
27
- readonly ERROR: "error";
28
- readonly PRIMARY: "primary";
29
- readonly SECONDARY: "secondary";
30
- };
31
20
  declare const DEFAULTS: {
32
21
  readonly TYPE: "dot";
33
22
  readonly MAX_COUNTER: 99;
@@ -35,4 +24,4 @@ declare const DEFAULTS: {
35
24
  readonly VARIANT: "primary";
36
25
  readonly ICON_SIZE: 1;
37
26
  };
38
- export { TAG_NAME, DEFAULTS, TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST, BACKGROUND_STYLES };
27
+ export { TAG_NAME, DEFAULTS, TYPE, ICON_VARIANT, ICON_NAMES_LIST };
@@ -17,15 +17,6 @@ const ICON_VARIANT = {
17
17
  PRIMARY: 'primary',
18
18
  SECONDARY: 'secondary',
19
19
  };
20
- const ICON_STATE = {
21
- SUCCESS: 'success',
22
- WARNING: 'warning',
23
- ERROR: 'error',
24
- };
25
- const BACKGROUND_STYLES = {
26
- ...ICON_VARIANT,
27
- ...ICON_STATE,
28
- };
29
20
  const DEFAULTS = {
30
21
  TYPE: TYPE.DOT,
31
22
  MAX_COUNTER: 99,
@@ -33,4 +24,4 @@ const DEFAULTS = {
33
24
  VARIANT: ICON_VARIANT.PRIMARY,
34
25
  ICON_SIZE: 1,
35
26
  };
36
- export { TAG_NAME, DEFAULTS, TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST, BACKGROUND_STYLES };
27
+ export { TAG_NAME, DEFAULTS, TYPE, ICON_VARIANT, ICON_NAMES_LIST };
@@ -44,26 +44,26 @@ const styles = [
44
44
  padding: 2px;
45
45
  border-radius: 50%;
46
46
  }
47
- :host::part(badge-icon__primary) {
47
+ :host([type='icon'][variant='primary'])::part(badge-icon) {
48
48
  background-color: var(--mdc-badge-primary-background-color);
49
49
  color: var(--mdc-badge-primary-foreground-color);
50
50
  }
51
- :host::part(badge-icon__success) {
51
+ :host([type='icon'][variant='secondary'])::part(badge-icon) {
52
+ background-color: var(--mdc-badge-secondary-background-color);
53
+ color: var(--mdc-badge-secondary-foreground-color);
54
+ }
55
+ :host([type='success'])::part(badge-icon) {
52
56
  background-color: var(--mdc-badge-success-background-color);
53
57
  color: var(--mdc-badge-success-foreground-color);
54
58
  }
55
- :host::part(badge-icon__warning) {
59
+ :host([type='warning'])::part(badge-icon) {
56
60
  background-color: var(--mdc-badge-warning-background-color);
57
61
  color: var(--mdc-badge-warning-foreground-color);
58
62
  }
59
- :host::part(badge-icon__error) {
63
+ :host([type='error'])::part(badge-icon) {
60
64
  background-color: var(--mdc-badge-error-background-color);
61
65
  color: var(--mdc-badge-error-foreground-color);
62
66
  }
63
- :host::part(badge-icon__secondary) {
64
- background-color: var(--mdc-badge-secondary-background-color);
65
- color: var(--mdc-badge-secondary-foreground-color);
66
- }
67
67
 
68
68
  /* High Contrast Mode */
69
69
  @media (forced-colors: active) {