@momentum-design/components 0.4.18 → 0.5.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.
@@ -119,8 +119,7 @@ class Badge extends Component {
119
119
  getIconClasses(overlay, iconVariant, type) {
120
120
  const overLayClass = { 'mdc-badge-overlay': overlay };
121
121
  const variantTypes = type === BADGE_TYPE.ICON ? ICON_VARIANT : ICON_STATE;
122
- const iconVariantType = Object.values(variantTypes).includes(iconVariant)
123
- ? iconVariant : DEFAULTS.VARIANT;
122
+ const iconVariantType = Object.values(variantTypes).includes(iconVariant) ? iconVariant : DEFAULTS.VARIANT;
124
123
  const backgroundClass = { [`mdc-badge-icon__${iconVariantType}`]: true };
125
124
  return {
126
125
  ...overLayClass,
@@ -166,10 +165,11 @@ class Badge extends Component {
166
165
  * @returns the TemplateResult for the current badge type.
167
166
  */
168
167
  getBadgeContentBasedOnType() {
168
+ if (this.variant && !Object.values(ICON_VARIANT).includes(this.variant)) {
169
+ this.variant = ICON_VARIANT.PRIMARY;
170
+ }
169
171
  const { counter, iconName, maxCounter, overlay, type, variant } = this;
170
172
  switch (type) {
171
- case BADGE_TYPE.DOT:
172
- return this.getBadgeDot(overlay);
173
173
  case BADGE_TYPE.ICON:
174
174
  return this.getBadgeIcon(iconName || '', overlay, variant, type);
175
175
  case BADGE_TYPE.COUNTER:
@@ -180,8 +180,10 @@ class Badge extends Component {
180
180
  return this.getBadgeIcon(ICON_NAMES_LIST.WARNING_ICON_NAME, overlay, ICON_STATE.WARNING);
181
181
  case BADGE_TYPE.ERROR:
182
182
  return this.getBadgeIcon(ICON_NAMES_LIST.ERROR_ICON_NAME, overlay, ICON_STATE.ERROR);
183
+ case BADGE_TYPE.DOT:
183
184
  default:
184
- return html ``;
185
+ this.type = BADGE_TYPE.DOT;
186
+ return this.getBadgeDot(overlay);
185
187
  }
186
188
  }
187
189
  update(changedProperties) {
@@ -204,7 +206,7 @@ __decorate([
204
206
  __metadata("design:type", String)
205
207
  ], Badge.prototype, "iconName", void 0);
206
208
  __decorate([
207
- property({ type: String }),
209
+ property({ type: String, reflect: true }),
208
210
  __metadata("design:type", Object)
209
211
  ], Badge.prototype, "variant", void 0);
210
212
  __decorate([
@@ -212,7 +214,7 @@ __decorate([
212
214
  __metadata("design:type", Number)
213
215
  ], Badge.prototype, "counter", void 0);
214
216
  __decorate([
215
- property({ type: Number, attribute: 'max-counter' }),
217
+ property({ type: Number, attribute: 'max-counter', reflect: true }),
216
218
  __metadata("design:type", Number)
217
219
  ], Badge.prototype, "maxCounter", void 0);
218
220
  __decorate([
@@ -29,4 +29,4 @@ declare const DEFAULTS: {
29
29
  VARIANT: string;
30
30
  ICON_SIZE: number;
31
31
  };
32
- export { TAG_NAME, DEFAULTS, BADGE_TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST, };
32
+ export { TAG_NAME, DEFAULTS, BADGE_TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST };
@@ -30,4 +30,4 @@ const DEFAULTS = {
30
30
  VARIANT: ICON_VARIANT.PRIMARY,
31
31
  ICON_SIZE: 1,
32
32
  };
33
- export { TAG_NAME, DEFAULTS, BADGE_TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST, };
33
+ export { TAG_NAME, DEFAULTS, BADGE_TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST };
@@ -146,7 +146,8 @@
146
146
  "kind": "field",
147
147
  "name": "variant",
148
148
  "description": "Type of the variant can be `primary` or `secondary`.\nIt defines the background and foreground color of the icon.",
149
- "attribute": "variant"
149
+ "attribute": "variant",
150
+ "reflects": true
150
151
  },
151
152
  {
152
153
  "kind": "field",
@@ -164,7 +165,8 @@
164
165
  "text": "number"
165
166
  },
166
167
  "description": "The maximum number can be set up to 999, anything about that will be rendered as _999+_.\nThe max counter can be `9`, `99` or `999`.",
167
- "attribute": "max-counter"
168
+ "attribute": "max-counter",
169
+ "reflects": true
168
170
  },
169
171
  {
170
172
  "kind": "field",
package/package.json CHANGED
@@ -37,5 +37,5 @@
37
37
  "@momentum-design/icons": "*",
38
38
  "@momentum-design/tokens": "*"
39
39
  },
40
- "version": "0.4.18"
40
+ "version": "0.5.0"
41
41
  }