@momentum-design/components 0.4.13 → 0.4.14
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/browser/index.js +86 -31
- package/dist/browser/index.js.map +4 -4
- package/dist/components/badge/badge.component.d.ts +74 -29
- package/dist/components/badge/badge.component.js +156 -68
- package/dist/components/badge/badge.constants.d.ts +28 -4
- package/dist/components/badge/badge.constants.js +32 -5
- package/dist/components/badge/badge.styles.js +54 -12
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/custom-elements.json +230 -51
- package/dist/react/badge/index.d.ts +6 -3
- package/dist/react/badge/index.js +6 -3
- package/package.json +1 -1
- package/dist/components/badge/badge.types.d.ts +0 -1
- package/dist/components/badge/badge.types.js +0 -2
@@ -1,33 +1,23 @@
|
|
1
|
-
import { CSSResult } from 'lit';
|
1
|
+
import { CSSResult, PropertyValues, TemplateResult } from 'lit';
|
2
2
|
import { Component } from '../../models';
|
3
|
-
import type { BadgeType } from './badge.types';
|
4
3
|
/**
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
4
|
+
* A badge is a small, visually distinct element that provides additional information
|
5
|
+
* or highlights the status of an item.
|
6
|
+
* Badges are often used to display notification dot, counts, making them a useful tool for
|
7
|
+
* conveying information quickly without taking up much space.
|
8
|
+
* @dependency mdc-icon
|
9
|
+
* @dependency mdc-text
|
8
10
|
*
|
9
11
|
* @tagname mdc-badge
|
10
12
|
*/
|
11
13
|
declare class Badge extends Component {
|
12
14
|
/**
|
13
15
|
* Type of the badge
|
14
|
-
* Can be `
|
15
|
-
*
|
16
|
-
* Default: `regular`
|
17
|
-
*/
|
18
|
-
type?: BadgeType;
|
19
|
-
/**
|
20
|
-
* Scale of the badge (works in combination with length unit)
|
21
|
-
*
|
22
|
-
* Default: `1`
|
23
|
-
*/
|
24
|
-
size?: number;
|
25
|
-
/**
|
26
|
-
* Length unit attribute for scale
|
16
|
+
* Can be `dot` (notification) , `icon` and `counter`
|
27
17
|
*
|
28
|
-
* Default: `
|
18
|
+
* Default: `dot`
|
29
19
|
*/
|
30
|
-
|
20
|
+
type: string;
|
31
21
|
/**
|
32
22
|
* If `type` is set to `icon`, attribute `iconName` can
|
33
23
|
* be used to choose which icon should be shown
|
@@ -36,16 +26,71 @@ declare class Badge extends Component {
|
|
36
26
|
*/
|
37
27
|
iconName?: string;
|
38
28
|
/**
|
39
|
-
*
|
40
|
-
|
29
|
+
* badge variant
|
30
|
+
*/
|
31
|
+
variant: string;
|
32
|
+
counter?: number;
|
33
|
+
maxCounter: number;
|
34
|
+
overlay: boolean;
|
35
|
+
/**
|
36
|
+
* Aria-label attribute to be set for accessibility
|
37
|
+
*/
|
38
|
+
ariaLabel: string | null;
|
39
|
+
/**
|
40
|
+
* If `type` is set to `counter` and if `counter` is greater than `maxCounter`,
|
41
|
+
* then it will return a string the maxCounter value as string.
|
42
|
+
* Otherwise, it will return a string representation of `counter`.
|
43
|
+
* If `counter` is not a number, it will return an empty string.
|
44
|
+
* @param maxCounter - the maximum limit which can be displayed on the badge
|
45
|
+
* @param counter - the number to be displayed on the badge
|
46
|
+
* @returns the string representation of the counter
|
47
|
+
*/
|
48
|
+
private getCounterText;
|
49
|
+
/**
|
50
|
+
* Method to generate the badge icon template.
|
51
|
+
* @param iconName - name of the icon to be used.
|
52
|
+
* @param variant - variant of the badge.
|
53
|
+
* @returns the template result of the icon.
|
54
|
+
*/
|
55
|
+
private getBadgeIcon;
|
56
|
+
/**
|
57
|
+
* Method to generate the badge dot template.
|
58
|
+
* @param overlay - boolean indicating whether the badge should have an overlay.
|
59
|
+
* @returns the template result of the dot with mdc-badge-dot class.
|
60
|
+
*/
|
61
|
+
private getBadgeDot;
|
62
|
+
/**
|
63
|
+
* This method generates the CSS classes for the badge icon.
|
64
|
+
* @param overlay - boolean indicating whether the badge should have an overlay.
|
65
|
+
* @param iconVariant - the variant of the icon badge.
|
66
|
+
* @param type - the type of the badge.
|
67
|
+
* @returns - an object containing the CSS classes for the icon.
|
68
|
+
*/
|
69
|
+
private getIconClasses;
|
70
|
+
/**
|
71
|
+
* Method to generate the badge text and counter template.
|
72
|
+
* @param maxCounter - the maximum limit which can be displayed on the badge
|
73
|
+
* @param overlay - whether the badge should have an overlay.
|
74
|
+
* @param counter - the number to be displayed on the badge
|
75
|
+
* @returns the template result of the text.
|
76
|
+
*/
|
77
|
+
private getBadgeCounterText;
|
78
|
+
/**
|
79
|
+
* Method to set the role based on the aria-label provided.
|
80
|
+
* If the aria-label is provided, the role of the element will be 'img'.
|
81
|
+
* Otherwise, the role will be null.
|
82
|
+
*/
|
83
|
+
private setRoleByAriaLabel;
|
84
|
+
/**
|
85
|
+
* Generates the badge content based on the badge type.
|
86
|
+
* Utilizes various helper methods to create the appropriate badge template based on the
|
87
|
+
* current badge type. Supports 'dot', 'icon', 'counter', 'success', 'warning', and 'error'
|
88
|
+
* types, returning the corresponding template result for each type.
|
89
|
+
* @returns the TemplateResult for the current badge type.
|
41
90
|
*/
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
iconTemplate(): import("lit-html").TemplateResult<1>;
|
46
|
-
textTemplate(): import("lit-html").TemplateResult<1>;
|
47
|
-
warningTemplate(): import("lit-html").TemplateResult<1>;
|
48
|
-
render(): import("lit-html").TemplateResult<1>;
|
91
|
+
private getBadgeContentBasedOnType;
|
92
|
+
update(changedProperties: PropertyValues): void;
|
93
|
+
render(): TemplateResult<1 | 2 | 3>;
|
49
94
|
static styles: Array<CSSResult>;
|
50
95
|
}
|
51
96
|
export default Badge;
|
@@ -2,16 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const lit_1 = require("lit");
|
5
|
+
const class_map_js_1 = require("lit-html/directives/class-map.js");
|
5
6
|
const decorators_js_1 = require("lit/decorators.js");
|
6
7
|
const if_defined_js_1 = require("lit/directives/if-defined.js");
|
7
|
-
const style_map_js_1 = require("lit/directives/style-map.js");
|
8
8
|
const models_1 = require("../../models");
|
9
9
|
const badge_constants_1 = require("./badge.constants");
|
10
10
|
const badge_styles_1 = tslib_1.__importDefault(require("./badge.styles"));
|
11
11
|
/**
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
12
|
+
* A badge is a small, visually distinct element that provides additional information
|
13
|
+
* or highlights the status of an item.
|
14
|
+
* Badges are often used to display notification dot, counts, making them a useful tool for
|
15
|
+
* conveying information quickly without taking up much space.
|
16
|
+
* @dependency mdc-icon
|
17
|
+
* @dependency mdc-text
|
15
18
|
*
|
16
19
|
* @tagname mdc-badge
|
17
20
|
*/
|
@@ -20,95 +23,180 @@ class Badge extends models_1.Component {
|
|
20
23
|
super(...arguments);
|
21
24
|
/**
|
22
25
|
* Type of the badge
|
23
|
-
* Can be `
|
26
|
+
* Can be `dot` (notification) , `icon` and `counter`
|
24
27
|
*
|
25
|
-
* Default: `
|
28
|
+
* Default: `dot`
|
26
29
|
*/
|
27
30
|
this.type = badge_constants_1.DEFAULTS.TYPE;
|
28
31
|
/**
|
29
|
-
*
|
30
|
-
*
|
31
|
-
* Default: `1`
|
32
|
+
* badge variant
|
32
33
|
*/
|
33
|
-
this.
|
34
|
+
this.variant = badge_constants_1.DEFAULTS.VARIANT;
|
35
|
+
this.maxCounter = badge_constants_1.DEFAULTS.MAX_COUNTER;
|
36
|
+
this.overlay = false;
|
34
37
|
/**
|
35
|
-
*
|
36
|
-
*
|
37
|
-
* Default: `rem`
|
38
|
+
* Aria-label attribute to be set for accessibility
|
38
39
|
*/
|
39
|
-
this.
|
40
|
-
}
|
41
|
-
updateSize() {
|
42
|
-
// if (this.scale && this.lengthUnit) {
|
43
|
-
// const value = `${this.scale}${this.lengthUnit}`;
|
44
|
-
// this.style.height = value;
|
45
|
-
// if (this.type !== 'text') {
|
46
|
-
// this.style.width = value;
|
47
|
-
// }
|
48
|
-
// }
|
40
|
+
this.ariaLabel = null;
|
49
41
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
/**
|
43
|
+
* If `type` is set to `counter` and if `counter` is greater than `maxCounter`,
|
44
|
+
* then it will return a string the maxCounter value as string.
|
45
|
+
* Otherwise, it will return a string representation of `counter`.
|
46
|
+
* If `counter` is not a number, it will return an empty string.
|
47
|
+
* @param maxCounter - the maximum limit which can be displayed on the badge
|
48
|
+
* @param counter - the number to be displayed on the badge
|
49
|
+
* @returns the string representation of the counter
|
50
|
+
*/
|
51
|
+
getCounterText(maxCounter, counter) {
|
52
|
+
if (counter === undefined || typeof counter !== 'number') {
|
53
|
+
return '';
|
54
54
|
}
|
55
|
+
// At any given time, the max limit should not cross 999.
|
56
|
+
if (counter > badge_constants_1.DEFAULTS.MAX_COUNTER_LIMIT) {
|
57
|
+
return `${badge_constants_1.DEFAULTS.MAX_COUNTER_LIMIT}+`;
|
58
|
+
}
|
59
|
+
if (counter > maxCounter) {
|
60
|
+
return `${maxCounter}+`;
|
61
|
+
}
|
62
|
+
return counter.toString();
|
55
63
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
/**
|
65
|
+
* Method to generate the badge icon template.
|
66
|
+
* @param iconName - name of the icon to be used.
|
67
|
+
* @param variant - variant of the badge.
|
68
|
+
* @returns the template result of the icon.
|
69
|
+
*/
|
70
|
+
getBadgeIcon(iconName, overlay, iconVariant, type) {
|
71
|
+
return (0, lit_1.html) `
|
72
|
+
<mdc-icon
|
73
|
+
class="mdc-badge-icon ${(0, class_map_js_1.classMap)(this.getIconClasses(overlay, iconVariant, type))}"
|
74
|
+
name="${(0, if_defined_js_1.ifDefined)(iconName)}"
|
75
|
+
length-unit="${badge_constants_1.DEFAULTS.LENGTH_UNIT}"
|
76
|
+
size="${badge_constants_1.DEFAULTS.ICON_SIZE}"
|
77
|
+
></mdc-icon>
|
78
|
+
`;
|
60
79
|
}
|
61
|
-
|
62
|
-
|
80
|
+
/**
|
81
|
+
* Method to generate the badge dot template.
|
82
|
+
* @param overlay - boolean indicating whether the badge should have an overlay.
|
83
|
+
* @returns the template result of the dot with mdc-badge-dot class.
|
84
|
+
*/
|
85
|
+
getBadgeDot(overlay) {
|
86
|
+
return (0, lit_1.html) `<div class="mdc-badge-dot ${(0, class_map_js_1.classMap)({ 'mdc-badge-overlay': overlay })}"></div>`;
|
63
87
|
}
|
64
|
-
|
65
|
-
|
88
|
+
/**
|
89
|
+
* This method generates the CSS classes for the badge icon.
|
90
|
+
* @param overlay - boolean indicating whether the badge should have an overlay.
|
91
|
+
* @param iconVariant - the variant of the icon badge.
|
92
|
+
* @param type - the type of the badge.
|
93
|
+
* @returns - an object containing the CSS classes for the icon.
|
94
|
+
*/
|
95
|
+
getIconClasses(overlay, iconVariant, type) {
|
96
|
+
const overLayClass = { 'mdc-badge-overlay': overlay };
|
97
|
+
const variantTypes = type === badge_constants_1.BADGE_TYPE.ICON ? badge_constants_1.ICON_VARIANT : badge_constants_1.ICON_STATE;
|
98
|
+
const iconVariantType = Object.values(variantTypes).includes(iconVariant)
|
99
|
+
? iconVariant : badge_constants_1.DEFAULTS.VARIANT;
|
100
|
+
const backgroundClass = { [`mdc-badge-icon__${iconVariantType}`]: true };
|
101
|
+
return {
|
102
|
+
...overLayClass,
|
103
|
+
...backgroundClass,
|
104
|
+
};
|
66
105
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
106
|
+
/**
|
107
|
+
* Method to generate the badge text and counter template.
|
108
|
+
* @param maxCounter - the maximum limit which can be displayed on the badge
|
109
|
+
* @param overlay - whether the badge should have an overlay.
|
110
|
+
* @param counter - the number to be displayed on the badge
|
111
|
+
* @returns the template result of the text.
|
112
|
+
*/
|
113
|
+
getBadgeCounterText(maxCounter, overlay, counter) {
|
114
|
+
return (0, lit_1.html) `
|
115
|
+
<mdc-text
|
116
|
+
type="body-small-medium"
|
117
|
+
tagname="div"
|
118
|
+
class="mdc-badge-text ${(0, class_map_js_1.classMap)({ 'mdc-badge-overlay': overlay })}"
|
119
|
+
>
|
120
|
+
${this.getCounterText(maxCounter, counter)}
|
121
|
+
</mdc-text>
|
122
|
+
`;
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* Method to set the role based on the aria-label provided.
|
126
|
+
* If the aria-label is provided, the role of the element will be 'img'.
|
127
|
+
* Otherwise, the role will be null.
|
128
|
+
*/
|
129
|
+
setRoleByAriaLabel() {
|
130
|
+
if (this.ariaLabel) {
|
131
|
+
this.role = 'img';
|
132
|
+
}
|
133
|
+
else {
|
134
|
+
this.role = null;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
/**
|
138
|
+
* Generates the badge content based on the badge type.
|
139
|
+
* Utilizes various helper methods to create the appropriate badge template based on the
|
140
|
+
* current badge type. Supports 'dot', 'icon', 'counter', 'success', 'warning', and 'error'
|
141
|
+
* types, returning the corresponding template result for each type.
|
142
|
+
* @returns the TemplateResult for the current badge type.
|
143
|
+
*/
|
144
|
+
getBadgeContentBasedOnType() {
|
145
|
+
const { counter, iconName, maxCounter, overlay, type, variant } = this;
|
146
|
+
switch (type) {
|
147
|
+
case badge_constants_1.BADGE_TYPE.DOT:
|
148
|
+
return this.getBadgeDot(overlay);
|
149
|
+
case badge_constants_1.BADGE_TYPE.ICON:
|
150
|
+
return this.getBadgeIcon(iconName || '', overlay, variant, type);
|
151
|
+
case badge_constants_1.BADGE_TYPE.COUNTER:
|
152
|
+
return this.getBadgeCounterText(maxCounter, overlay, counter);
|
153
|
+
case badge_constants_1.BADGE_TYPE.SUCCESS:
|
154
|
+
return this.getBadgeIcon(badge_constants_1.ICON_NAMES_LIST.SUCCESS_ICON_NAME, overlay, badge_constants_1.ICON_STATE.SUCCESS);
|
155
|
+
case badge_constants_1.BADGE_TYPE.WARNING:
|
156
|
+
return this.getBadgeIcon(badge_constants_1.ICON_NAMES_LIST.WARNING_ICON_NAME, overlay, badge_constants_1.ICON_STATE.WARNING);
|
157
|
+
case badge_constants_1.BADGE_TYPE.ERROR:
|
158
|
+
return this.getBadgeIcon(badge_constants_1.ICON_NAMES_LIST.ERROR_ICON_NAME, overlay, badge_constants_1.ICON_STATE.ERROR);
|
86
159
|
default:
|
87
|
-
|
88
|
-
break;
|
160
|
+
return (0, lit_1.html) ``;
|
89
161
|
}
|
90
|
-
|
162
|
+
}
|
163
|
+
update(changedProperties) {
|
164
|
+
super.update(changedProperties);
|
165
|
+
if (changedProperties.has('ariaLabel')) {
|
166
|
+
this.setRoleByAriaLabel();
|
167
|
+
}
|
168
|
+
}
|
169
|
+
render() {
|
170
|
+
return this.getBadgeContentBasedOnType();
|
91
171
|
}
|
92
172
|
}
|
93
173
|
Badge.styles = [...models_1.Component.styles, ...badge_styles_1.default];
|
94
174
|
tslib_1.__decorate([
|
95
175
|
(0, decorators_js_1.property)({ type: String, reflect: true }),
|
96
|
-
tslib_1.__metadata("design:type",
|
176
|
+
tslib_1.__metadata("design:type", Object)
|
97
177
|
], Badge.prototype, "type", void 0);
|
98
|
-
tslib_1.__decorate([
|
99
|
-
(0, decorators_js_1.property)({ type: Number }),
|
100
|
-
tslib_1.__metadata("design:type", Number)
|
101
|
-
], Badge.prototype, "size", void 0);
|
102
|
-
tslib_1.__decorate([
|
103
|
-
(0, decorators_js_1.property)({ type: String, attribute: 'length-unit' }),
|
104
|
-
tslib_1.__metadata("design:type", String)
|
105
|
-
], Badge.prototype, "lengthUnit", void 0);
|
106
178
|
tslib_1.__decorate([
|
107
179
|
(0, decorators_js_1.property)({ type: String, attribute: 'icon-name' }),
|
108
180
|
tslib_1.__metadata("design:type", String)
|
109
181
|
], Badge.prototype, "iconName", void 0);
|
110
182
|
tslib_1.__decorate([
|
111
183
|
(0, decorators_js_1.property)({ type: String }),
|
112
|
-
tslib_1.__metadata("design:type",
|
113
|
-
], Badge.prototype, "
|
184
|
+
tslib_1.__metadata("design:type", Object)
|
185
|
+
], Badge.prototype, "variant", void 0);
|
186
|
+
tslib_1.__decorate([
|
187
|
+
(0, decorators_js_1.property)({ type: Number }),
|
188
|
+
tslib_1.__metadata("design:type", Number)
|
189
|
+
], Badge.prototype, "counter", void 0);
|
190
|
+
tslib_1.__decorate([
|
191
|
+
(0, decorators_js_1.property)({ type: Number, attribute: 'max-counter' }),
|
192
|
+
tslib_1.__metadata("design:type", Number)
|
193
|
+
], Badge.prototype, "maxCounter", void 0);
|
194
|
+
tslib_1.__decorate([
|
195
|
+
(0, decorators_js_1.property)({ type: Boolean }),
|
196
|
+
tslib_1.__metadata("design:type", Object)
|
197
|
+
], Badge.prototype, "overlay", void 0);
|
198
|
+
tslib_1.__decorate([
|
199
|
+
(0, decorators_js_1.property)({ type: String, attribute: 'aria-label' }),
|
200
|
+
tslib_1.__metadata("design:type", Object)
|
201
|
+
], Badge.prototype, "ariaLabel", void 0);
|
114
202
|
exports.default = Badge;
|
@@ -1,8 +1,32 @@
|
|
1
1
|
declare const TAG_NAME: "mdc-badge";
|
2
|
-
declare const
|
2
|
+
declare const BADGE_TYPE: {
|
3
|
+
DOT: string;
|
4
|
+
ICON: string;
|
5
|
+
COUNTER: string;
|
6
|
+
SUCCESS: string;
|
7
|
+
WARNING: string;
|
8
|
+
ERROR: string;
|
9
|
+
};
|
10
|
+
declare const ICON_NAMES_LIST: {
|
11
|
+
SUCCESS_ICON_NAME: string;
|
12
|
+
WARNING_ICON_NAME: string;
|
13
|
+
ERROR_ICON_NAME: string;
|
14
|
+
};
|
15
|
+
declare const ICON_VARIANT: {
|
16
|
+
PRIMARY: string;
|
17
|
+
SECONDARY: string;
|
18
|
+
};
|
19
|
+
declare const ICON_STATE: {
|
20
|
+
SUCCESS: string;
|
21
|
+
WARNING: string;
|
22
|
+
ERROR: string;
|
23
|
+
};
|
3
24
|
declare const DEFAULTS: {
|
4
|
-
TYPE:
|
5
|
-
SIZE: number;
|
25
|
+
TYPE: string;
|
6
26
|
LENGTH_UNIT: string;
|
27
|
+
MAX_COUNTER: number;
|
28
|
+
MAX_COUNTER_LIMIT: number;
|
29
|
+
VARIANT: string;
|
30
|
+
ICON_SIZE: number;
|
7
31
|
};
|
8
|
-
export { TAG_NAME, DEFAULTS,
|
32
|
+
export { TAG_NAME, DEFAULTS, BADGE_TYPE, ICON_STATE, ICON_VARIANT, ICON_NAMES_LIST, };
|
@@ -1,15 +1,42 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.ICON_NAMES_LIST = exports.ICON_VARIANT = exports.ICON_STATE = exports.BADGE_TYPE = exports.DEFAULTS = exports.TAG_NAME = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const tag_name_1 = tslib_1.__importDefault(require("../../utils/tag-name"));
|
6
6
|
const TAG_NAME = tag_name_1.default.constructTagName('badge');
|
7
7
|
exports.TAG_NAME = TAG_NAME;
|
8
|
-
const
|
9
|
-
|
8
|
+
const BADGE_TYPE = {
|
9
|
+
DOT: 'dot',
|
10
|
+
ICON: 'icon',
|
11
|
+
COUNTER: 'counter',
|
12
|
+
SUCCESS: 'success',
|
13
|
+
WARNING: 'warning',
|
14
|
+
ERROR: 'error',
|
15
|
+
};
|
16
|
+
exports.BADGE_TYPE = BADGE_TYPE;
|
17
|
+
const ICON_NAMES_LIST = {
|
18
|
+
SUCCESS_ICON_NAME: 'check-circle-filled',
|
19
|
+
WARNING_ICON_NAME: 'warning-filled',
|
20
|
+
ERROR_ICON_NAME: 'error-legacy-filled',
|
21
|
+
};
|
22
|
+
exports.ICON_NAMES_LIST = ICON_NAMES_LIST;
|
23
|
+
const ICON_VARIANT = {
|
24
|
+
PRIMARY: 'primary',
|
25
|
+
SECONDARY: 'secondary',
|
26
|
+
};
|
27
|
+
exports.ICON_VARIANT = ICON_VARIANT;
|
28
|
+
const ICON_STATE = {
|
29
|
+
SUCCESS: 'success',
|
30
|
+
WARNING: 'warning',
|
31
|
+
ERROR: 'error',
|
32
|
+
};
|
33
|
+
exports.ICON_STATE = ICON_STATE;
|
10
34
|
const DEFAULTS = {
|
11
|
-
TYPE:
|
12
|
-
SIZE: 1,
|
35
|
+
TYPE: BADGE_TYPE.DOT,
|
13
36
|
LENGTH_UNIT: 'rem',
|
37
|
+
MAX_COUNTER: 99,
|
38
|
+
MAX_COUNTER_LIMIT: 999,
|
39
|
+
VARIANT: ICON_VARIANT.PRIMARY,
|
40
|
+
ICON_SIZE: 1,
|
14
41
|
};
|
15
42
|
exports.DEFAULTS = DEFAULTS;
|
@@ -6,22 +6,64 @@ const styles = [
|
|
6
6
|
styles_1.hostFitContentStyles,
|
7
7
|
(0, lit_1.css) `
|
8
8
|
:host {
|
9
|
-
--mdc-badge-
|
10
|
-
--mdc-badge-
|
11
|
-
|
9
|
+
--mdc-badge-primary-foreground-color: var(--mds-color-theme-common-text-primary-normal);
|
10
|
+
--mdc-badge-primary-background-color: var(--mds-color-theme-background-accent-normal);
|
11
|
+
|
12
|
+
--mdc-badge-secondary-foreground-color: var(--mds-color-theme-text-secondary-normal);
|
13
|
+
--mdc-badge-secondary-background-color: var(--mds-color-theme-background-alert-default-normal);
|
12
14
|
|
13
|
-
|
15
|
+
--mdc-badge-success-foreground-color: var(--mds-color-theme-text-success-normal);
|
16
|
+
--mdc-badge-success-background-color: var(--mds-color-theme-background-alert-success-normal);
|
17
|
+
|
18
|
+
--mdc-badge-warning-foreground-color: var(--mds-color-theme-text-warning-normal);
|
19
|
+
--mdc-badge-warning-background-color: var(--mds-color-theme-background-alert-warning-normal);
|
20
|
+
|
21
|
+
--mdc-badge-error-foreground-color: var(--mds-color-theme-text-error-normal);
|
22
|
+
--mdc-badge-error-background-color: var(--mds-color-theme-background-alert-error-normal);
|
23
|
+
|
24
|
+
--mdc-badge-overlay-background-color: var(--mds-color-theme-background-solid-primary-normal);
|
25
|
+
|
26
|
+
color: var(--mdc-badge-primary-foreground-color);
|
27
|
+
}
|
28
|
+
.mdc-badge-overlay {
|
29
|
+
outline: 0.0625rem solid var(--mdc-badge-overlay-background-color);
|
30
|
+
}
|
31
|
+
.mdc-badge-text {
|
32
|
+
padding: 0 0.25rem;
|
33
|
+
border-radius: 6.25rem;
|
34
|
+
min-width: 1rem;
|
14
35
|
display: flex;
|
15
36
|
justify-content: center;
|
16
|
-
|
17
|
-
border-radius: 9999px;
|
18
|
-
background-color: var(--mdc-badge-icon-background-color);
|
19
|
-
color: var(--mdc-badge-icon-color);
|
37
|
+
background-color: var(--mdc-badge-primary-background-color);
|
20
38
|
}
|
21
|
-
|
22
|
-
|
23
|
-
height:
|
24
|
-
|
39
|
+
.mdc-badge-dot {
|
40
|
+
width: 0.75rem;
|
41
|
+
height: 0.75rem;
|
42
|
+
border-radius: 50%;
|
43
|
+
background-color: var(--mdc-badge-primary-background-color);
|
44
|
+
}
|
45
|
+
.mdc-badge-icon {
|
46
|
+
padding: 2px;
|
47
|
+
border-radius: 50%;
|
48
|
+
}
|
49
|
+
.mdc-badge-icon__primary {
|
50
|
+
background-color: var(--mdc-badge-primary-background-color);
|
51
|
+
}
|
52
|
+
.mdc-badge-icon__success {
|
53
|
+
background-color: var(--mdc-badge-success-background-color);
|
54
|
+
color: var(--mdc-badge-success-foreground-color);
|
55
|
+
}
|
56
|
+
.mdc-badge-icon__warning {
|
57
|
+
background-color: var(--mdc-badge-warning-background-color);
|
58
|
+
color: var(--mdc-badge-warning-foreground-color);
|
59
|
+
}
|
60
|
+
.mdc-badge-icon__error {
|
61
|
+
background-color: var(--mdc-badge-error-background-color);
|
62
|
+
color: var(--mdc-badge-error-foreground-color);
|
63
|
+
}
|
64
|
+
.mdc-badge-icon__secondary {
|
65
|
+
background-color: var(--mdc-badge-secondary-background-color);
|
66
|
+
color: var(--mdc-badge-secondary-foreground-color);
|
25
67
|
}
|
26
68
|
`,
|
27
69
|
];
|
@@ -3,5 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const badge_component_1 = tslib_1.__importDefault(require("./badge.component"));
|
5
5
|
const badge_constants_1 = require("./badge.constants");
|
6
|
+
require("../icon");
|
7
|
+
require("../text");
|
6
8
|
badge_component_1.default.register(badge_constants_1.TAG_NAME);
|
7
9
|
exports.default = badge_component_1.default;
|