@c2n/badge 0.0.6
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/badge.js +98 -0
- package/package.json +61 -0
- package/types/src/badge.d.ts +95 -0
- package/types/src/badge.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nguyen Thai Vinh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @c2n/badge
|
|
2
|
+
|
|
3
|
+
Badge built with Lit: a tinted pill for status text, counts and dots, optionally pinned to a corner of another element.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @c2n/badge
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script type="module">
|
|
11
|
+
import '@c2n/badge'
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<c2-badge tone="success">Active</c2-badge>
|
|
15
|
+
<c2-badge tone="danger" count="120"></c2-badge>
|
|
16
|
+
<c2-badge dot tone="success" pulse></c2-badge>
|
|
17
|
+
<c2-badge tone="danger" count="5">
|
|
18
|
+
<button slot="anchor">Inbox</button>
|
|
19
|
+
</c2-badge>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- **Tones**: `tone="neutral|primary|success|warning|danger|info"` picks a background/text pair; each pair is a CSS variable (`--c2-badge__success--background`, `--c2-badge__success--color`, …) and `--c2-badge--background` / `--c2-badge--color` override whichever tone is active.
|
|
23
|
+
- **Count**: `count` shows a number instead of the slotted text, clamped at `max` (default `99`, rendered as `99+`). A count of `0` hides the badge unless `show-zero` is set.
|
|
24
|
+
- **Dot**: `dot` renders a small circle in the tone colour; `pulse` adds a fading ring animation (disabled under `prefers-reduced-motion`).
|
|
25
|
+
- **Anchor**: put an element in the `anchor` slot and the badge becomes an overlay pinned to a corner chosen with `placement="top-right|top-left|bottom-right|bottom-left"`, ringed by `--c2-badge__anchor--border`. Add `overlap="circular"` for round anchors (avatars, icon buttons) so it lands on the edge of the circle; `--c2-badge__anchor--offset-x/y` fine-tune the position.
|
|
26
|
+
- **Icon**: the `prefix-icon` slot places an icon before the text, sized by `--c2-badge__icon--size`.
|
|
27
|
+
|
|
28
|
+
Shape and typography are CSS custom properties (`--c2-badge--height`, `--c2-badge--border-radius`, `--c2-badge--font-size`, `--c2-badge--text-transform`, …). For an outlined badge set `--c2-badge--background: transparent` and `--c2-badge--border: 1px solid currentColor`. The full list is in `custom-elements.json` and on the docs site.
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { LitElement, html, isServer, nothing, unsafeCSS } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
+
//#region src/badge.scss?inline
|
|
5
|
+
var badge_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n position: relative;\n vertical-align: middle;\n flex: none;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.c2-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n white-space: nowrap;\n user-select: none;\n height: var(--c2-badge--height,20px);\n min-width: var(--c2-badge--min-width,20px);\n padding-left: var(--c2-badge--padding-left,6px);\n padding-right: var(--c2-badge--padding-right,6px);\n gap: var(--c2-badge--gap,4px);\n border-radius: var(--c2-badge--border-radius,999px);\n border: var(--c2-badge--border,none);\n box-shadow: var(--c2-badge--box-shadow);\n font-family: var(--c2-badge--font-family,inherit);\n font-size: var(--c2-badge--font-size,12px);\n font-weight: var(--c2-badge--font-weight,500);\n line-height: var(--c2-badge--line-height,1);\n letter-spacing: var(--c2-badge--letter-spacing);\n text-transform: var(--c2-badge--text-transform,none);\n background: var(--c2-badge--background,var(--c2-badge__neutral--background,#f4f4f5));\n color: var(--c2-badge--color,var(--c2-badge__neutral--color,#52525b));\n}\n\n:host([tone=primary]) .c2-badge {\n background: var(--c2-badge--background,var(--c2-badge__primary--background,#edf1fe));\n color: var(--c2-badge--color,var(--c2-badge__primary--color,#0265dc));\n}\n\n:host([tone=success]) .c2-badge {\n background: var(--c2-badge--background,var(--c2-badge__success--background,#dcfce7));\n color: var(--c2-badge--color,var(--c2-badge__success--color,#166534));\n}\n\n:host([tone=warning]) .c2-badge {\n background: var(--c2-badge--background,var(--c2-badge__warning--background,#fef3c7));\n color: var(--c2-badge--color,var(--c2-badge__warning--color,#92400e));\n}\n\n:host([tone=danger]) .c2-badge {\n background: var(--c2-badge--background,var(--c2-badge__danger--background,#fee2e2));\n color: var(--c2-badge--color,var(--c2-badge__danger--color,#dc2626));\n}\n\n:host([tone=info]) .c2-badge {\n background: var(--c2-badge--background,var(--c2-badge__info--background,#e0f2fe));\n color: var(--c2-badge--color,var(--c2-badge__info--color,#075985));\n}\n\n::slotted([slot=prefix-icon]) {\n display: block;\n flex: none;\n width: var(--c2-badge__icon--size,12px);\n height: var(--c2-badge__icon--size,12px);\n}\n\n.c2-badge.is-dot {\n position: relative;\n box-sizing: content-box;\n width: var(--c2-badge__dot--size,8px);\n height: var(--c2-badge__dot--size,8px);\n min-width: 0;\n padding: 0;\n background: currentColor;\n border-radius: 999px;\n}\n.c2-badge.is-dot.is-pulse::after {\n content: \"\";\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: currentColor;\n animation: c2-badge-pulse var(--c2-badge__pulse--animation-duration,1.5s) cubic-bezier(0, 0, 0.2, 1) infinite;\n}\n\n@keyframes c2-badge-pulse {\n from {\n transform: scale(1);\n opacity: 0.6;\n }\n to {\n transform: scale(2.6);\n opacity: 0;\n }\n}\n.c2-badge.is-anchored {\n --_offset-x: var(--c2-badge__anchor--offset-x,0px);\n --_offset-y: var(--c2-badge__anchor--offset-y,0px);\n position: absolute;\n z-index: 1;\n border: var(--c2-badge__anchor--border,2px solid #ffffff);\n}\n\n:host([overlap=circular]) .c2-badge.is-anchored {\n --_offset-x: var(--c2-badge__anchor--offset-x, 14.6%);\n --_offset-y: var(--c2-badge__anchor--offset-y, 14.6%);\n}\n\n:host([placement=top-right]) .c2-badge.is-anchored,\n:host(:not([placement])) .c2-badge.is-anchored {\n top: var(--_offset-y);\n right: var(--_offset-x);\n transform: translate(50%, -50%);\n}\n\n:host([placement=top-left]) .c2-badge.is-anchored {\n top: var(--_offset-y);\n left: var(--_offset-x);\n transform: translate(-50%, -50%);\n}\n\n:host([placement=bottom-right]) .c2-badge.is-anchored {\n bottom: var(--_offset-y);\n right: var(--_offset-x);\n transform: translate(50%, 50%);\n}\n\n:host([placement=bottom-left]) .c2-badge.is-anchored {\n bottom: var(--_offset-y);\n left: var(--_offset-x);\n transform: translate(-50%, 50%);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .c2-badge.is-dot.is-pulse::after {\n animation: none;\n }\n}";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
|
|
8
|
+
function __decorate(decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/badge.ts
|
|
16
|
+
var Badge = class Badge extends LitElement {
|
|
17
|
+
constructor(..._args) {
|
|
18
|
+
super(..._args);
|
|
19
|
+
this.tone = "neutral";
|
|
20
|
+
this.count = void 0;
|
|
21
|
+
this.max = 99;
|
|
22
|
+
this.showZero = false;
|
|
23
|
+
this.dot = false;
|
|
24
|
+
this.pulse = false;
|
|
25
|
+
this.placement = "top-right";
|
|
26
|
+
this.overlap = "rectangular";
|
|
27
|
+
this.hasAnchor = false;
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.styles = unsafeCSS(badge_default);
|
|
31
|
+
}
|
|
32
|
+
/** Read the anchor before the first render so a server-rendered badge hydrates in its final position. */
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
if (!isServer) this.hasAnchor = this.querySelector(":scope > [slot=\"anchor\"]") !== null;
|
|
36
|
+
}
|
|
37
|
+
/** `slotchange` does not fire for server-rendered slots, so read the anchor once after the first render. */
|
|
38
|
+
firstUpdated() {
|
|
39
|
+
const slot = this.renderRoot.querySelector("slot[name=\"anchor\"]");
|
|
40
|
+
if (slot) this.updateAnchor(slot);
|
|
41
|
+
}
|
|
42
|
+
handleAnchorChange(event) {
|
|
43
|
+
this.updateAnchor(event.target);
|
|
44
|
+
}
|
|
45
|
+
updateAnchor(slot) {
|
|
46
|
+
this.hasAnchor = slot.assignedElements({ flatten: true }).length > 0;
|
|
47
|
+
}
|
|
48
|
+
/** Text shown for `count`, clamped at `max`. */
|
|
49
|
+
get displayCount() {
|
|
50
|
+
if (this.count === void 0) return "";
|
|
51
|
+
return this.count > this.max ? `${this.max}+` : String(this.count);
|
|
52
|
+
}
|
|
53
|
+
get visible() {
|
|
54
|
+
if (this.dot) return true;
|
|
55
|
+
return this.count === void 0 || this.count !== 0 || this.showZero;
|
|
56
|
+
}
|
|
57
|
+
renderBadge() {
|
|
58
|
+
if (!this.visible) return nothing;
|
|
59
|
+
const classes = classMap({
|
|
60
|
+
"c2-badge": true,
|
|
61
|
+
"is-dot": this.dot,
|
|
62
|
+
"is-pulse": this.dot && this.pulse,
|
|
63
|
+
"is-anchored": this.hasAnchor
|
|
64
|
+
});
|
|
65
|
+
if (this.dot) return html`<span class=${classes} part="badge"></span>`;
|
|
66
|
+
return html`
|
|
67
|
+
<span class=${classes} part="badge">
|
|
68
|
+
<slot name="prefix-icon"></slot>
|
|
69
|
+
${this.count !== void 0 ? this.displayCount : html`<slot></slot>`}
|
|
70
|
+
</span>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
return html`<slot name="anchor" @slotchange=${this.handleAnchorChange}></slot>${this.renderBadge()}`;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
__decorate([property({ reflect: true })], Badge.prototype, "tone", void 0);
|
|
78
|
+
__decorate([property({ type: Number })], Badge.prototype, "count", void 0);
|
|
79
|
+
__decorate([property({ type: Number })], Badge.prototype, "max", void 0);
|
|
80
|
+
__decorate([property({
|
|
81
|
+
type: Boolean,
|
|
82
|
+
reflect: true,
|
|
83
|
+
attribute: "show-zero"
|
|
84
|
+
})], Badge.prototype, "showZero", void 0);
|
|
85
|
+
__decorate([property({
|
|
86
|
+
type: Boolean,
|
|
87
|
+
reflect: true
|
|
88
|
+
})], Badge.prototype, "dot", void 0);
|
|
89
|
+
__decorate([property({
|
|
90
|
+
type: Boolean,
|
|
91
|
+
reflect: true
|
|
92
|
+
})], Badge.prototype, "pulse", void 0);
|
|
93
|
+
__decorate([property({ reflect: true })], Badge.prototype, "placement", void 0);
|
|
94
|
+
__decorate([property({ reflect: true })], Badge.prototype, "overlap", void 0);
|
|
95
|
+
__decorate([state()], Badge.prototype, "hasAnchor", void 0);
|
|
96
|
+
Badge = __decorate([customElement("c2-badge")], Badge);
|
|
97
|
+
//#endregion
|
|
98
|
+
export { Badge };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@c2n/badge",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/badge.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"default": "./dist/badge.js",
|
|
9
|
+
"types": "./types/src/badge.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./custom-elements.json": "./custom-elements.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"types"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"badge",
|
|
19
|
+
"web component",
|
|
20
|
+
"lit"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "code2nguyen@gmail.com",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"registry": "https://registry.npmjs.org",
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/code2nguyen/web-components.git"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"build": "wireit",
|
|
35
|
+
"build:only": "vite build",
|
|
36
|
+
"type-check": "wireit"
|
|
37
|
+
},
|
|
38
|
+
"wireit": {
|
|
39
|
+
"type-check": {
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"../../core:build"
|
|
42
|
+
],
|
|
43
|
+
"command": "tsc -p tsconfig.lib.json --composite false"
|
|
44
|
+
},
|
|
45
|
+
"build": {
|
|
46
|
+
"dependencies": [
|
|
47
|
+
"type-check"
|
|
48
|
+
],
|
|
49
|
+
"command": "vite build"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@c2n/core": "0.0.6",
|
|
54
|
+
"lit": "3.3.3"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@c2n/config": "*"
|
|
58
|
+
},
|
|
59
|
+
"customElements": "custom-elements.json",
|
|
60
|
+
"gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
|
|
61
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export type BadgeTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
3
|
+
export type BadgePlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
4
|
+
export type BadgeOverlap = 'rectangular' | 'circular';
|
|
5
|
+
/**
|
|
6
|
+
* Small status label: a tinted pill with text, a number or an icon, or a plain dot. Six `tone`s carry meaning
|
|
7
|
+
* (neutral, primary, success, warning, danger, info); each is a pair of CSS variables so a design system can recolour
|
|
8
|
+
* them without touching the markup. Give it a `count` to show a number clamped at `max` (`99+`), or `dot` for a
|
|
9
|
+
* presence indicator that can `pulse`. Put an element in the `anchor` slot and the badge pins itself to one of its
|
|
10
|
+
* corners (`placement`), for example a notification count on an icon button; `overlap="circular"` moves it onto the
|
|
11
|
+
* edge of a round anchor such as an avatar.
|
|
12
|
+
*
|
|
13
|
+
* @tag c2-badge
|
|
14
|
+
*
|
|
15
|
+
* @slot - Label text. Ignored while `count` or `dot` is set.
|
|
16
|
+
* @slot prefix-icon - Icon shown before the text, sized by `--c2-badge__icon--size`.
|
|
17
|
+
* @slot anchor - Element the badge is pinned to. When filled the badge becomes an overlay at the `placement` corner.
|
|
18
|
+
*
|
|
19
|
+
* @cssproperty {pixel} [--c2-badge--height=20px]
|
|
20
|
+
* @cssproperty {pixel} [--c2-badge--min-width=20px] - Keeps single digits round.
|
|
21
|
+
* @cssproperty {padding} [--c2-badge--padding-left=6px]
|
|
22
|
+
* @cssproperty {padding} [--c2-badge--padding-right=6px]
|
|
23
|
+
* @cssproperty {pixel} [--c2-badge--gap=4px] - Space between the icon and the text.
|
|
24
|
+
* @cssproperty {border-radius} [--c2-badge--border-radius=999px]
|
|
25
|
+
* @cssproperty {border} [--c2-badge--border=none] - Set a border for an outlined look, together with a transparent background.
|
|
26
|
+
* @cssproperty {box-shadow} --c2-badge--box-shadow
|
|
27
|
+
* @cssproperty {background} --c2-badge--background - Overrides the tone background.
|
|
28
|
+
* @cssproperty {color} --c2-badge--color - Overrides the tone text colour.
|
|
29
|
+
*
|
|
30
|
+
* @cssproperty {font-family} [--c2-badge--font-family=inherit]
|
|
31
|
+
* @cssproperty {font-size} [--c2-badge--font-size=12px]
|
|
32
|
+
* @cssproperty {font-weight} [--c2-badge--font-weight=500]
|
|
33
|
+
* @cssproperty {line-height} [--c2-badge--line-height=1]
|
|
34
|
+
* @cssproperty {pixel} --c2-badge--letter-spacing
|
|
35
|
+
* @cssproperty {text-transform} [--c2-badge--text-transform=none]
|
|
36
|
+
*
|
|
37
|
+
* @cssproperty {pixel} [--c2-badge__icon--size=12px]
|
|
38
|
+
*
|
|
39
|
+
* @cssproperty {background} [--c2-badge__neutral--background=#f4f4f5]
|
|
40
|
+
* @cssproperty {color} [--c2-badge__neutral--color=#52525b]
|
|
41
|
+
* @cssproperty {background} [--c2-badge__primary--background=#edf1fe]
|
|
42
|
+
* @cssproperty {color} [--c2-badge__primary--color=#0265dc]
|
|
43
|
+
* @cssproperty {background} [--c2-badge__success--background=#dcfce7]
|
|
44
|
+
* @cssproperty {color} [--c2-badge__success--color=#166534]
|
|
45
|
+
* @cssproperty {background} [--c2-badge__warning--background=#fef3c7]
|
|
46
|
+
* @cssproperty {color} [--c2-badge__warning--color=#92400e]
|
|
47
|
+
* @cssproperty {background} [--c2-badge__danger--background=#fee2e2]
|
|
48
|
+
* @cssproperty {color} [--c2-badge__danger--color=#dc2626]
|
|
49
|
+
* @cssproperty {background} [--c2-badge__info--background=#e0f2fe]
|
|
50
|
+
* @cssproperty {color} [--c2-badge__info--color=#075985]
|
|
51
|
+
*
|
|
52
|
+
* @cssproperty {pixel} [--c2-badge__dot--size=8px] - Diameter of the `dot` badge; its colour is the tone text colour.
|
|
53
|
+
* @cssproperty {time} [--c2-badge__pulse--animation-duration=1.5s] - Length of one `pulse` cycle; respects reduced motion.
|
|
54
|
+
*
|
|
55
|
+
* @cssproperty {border} [--c2-badge__anchor--border=2px solid #ffffff] - Ring around an anchored badge, in the page background colour. Drawn outside a `dot`.
|
|
56
|
+
* @cssproperty {pixel} [--c2-badge__anchor--offset-x=0px] - Moves an anchored badge inwards horizontally (`14.6%` with `overlap="circular"`).
|
|
57
|
+
* @cssproperty {pixel} [--c2-badge__anchor--offset-y=0px] - Moves an anchored badge inwards vertically (`14.6%` with `overlap="circular"`).
|
|
58
|
+
*/
|
|
59
|
+
export declare class Badge extends LitElement {
|
|
60
|
+
static styles: import("lit").CSSResult;
|
|
61
|
+
/** Colour role of the badge. */
|
|
62
|
+
tone: BadgeTone;
|
|
63
|
+
/** Number to display instead of the slotted text. Hidden when it is `0` unless `show-zero` is set. */
|
|
64
|
+
count: number | undefined;
|
|
65
|
+
/** Upper bound for `count`; larger values render as `<max>+`. */
|
|
66
|
+
max: number;
|
|
67
|
+
/** Keeps a `count` of `0` visible. */
|
|
68
|
+
showZero: boolean;
|
|
69
|
+
/** Renders a small dot without text. */
|
|
70
|
+
dot: boolean;
|
|
71
|
+
/** Animates a fading ring around a `dot` badge to draw attention. */
|
|
72
|
+
pulse: boolean;
|
|
73
|
+
/** Corner of the `anchor` element the badge is pinned to. */
|
|
74
|
+
placement: BadgePlacement;
|
|
75
|
+
/** Shape of the anchor: `circular` pulls the badge onto the edge of a round anchor instead of its bounding-box corner. */
|
|
76
|
+
overlap: BadgeOverlap;
|
|
77
|
+
private hasAnchor;
|
|
78
|
+
/** Read the anchor before the first render so a server-rendered badge hydrates in its final position. */
|
|
79
|
+
connectedCallback(): void;
|
|
80
|
+
/** `slotchange` does not fire for server-rendered slots, so read the anchor once after the first render. */
|
|
81
|
+
firstUpdated(): void;
|
|
82
|
+
private handleAnchorChange;
|
|
83
|
+
private updateAnchor;
|
|
84
|
+
/** Text shown for `count`, clamped at `max`. */
|
|
85
|
+
get displayCount(): string;
|
|
86
|
+
private get visible();
|
|
87
|
+
private renderBadge;
|
|
88
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
89
|
+
}
|
|
90
|
+
declare global {
|
|
91
|
+
interface HTMLElementTagNameMap {
|
|
92
|
+
'c2-badge': Badge;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../src/badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,KAAK,CAAA;AAKpE,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AACzF,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAA;AACtF,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,UAAU,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,qBACa,KAAM,SAAQ,UAAU;IACnC,OAAgB,MAAM,0BAAoB;IAE1C,gCAAgC;IACH,IAAI,EAAE,SAAS,CAAY;IAExD,sGAAsG;IAC1E,KAAK,EAAE,MAAM,GAAG,SAAS,CAAY;IAEjE,iEAAiE;IACrC,GAAG,SAAK;IAEpC,sCAAsC;IAC8B,QAAQ,UAAQ;IAEpF,wCAAwC;IACI,GAAG,UAAQ;IAEvD,qEAAqE;IACzB,KAAK,UAAQ;IAEzD,6DAA6D;IAChC,SAAS,EAAE,cAAc,CAAc;IAEpE,0HAA0H;IAC7F,OAAO,EAAE,YAAY,CAAgB;IAEzD,OAAO,CAAC,SAAS,CAAQ;IAElC,yGAAyG;IAChG,iBAAiB;IAK1B,4GAA4G;IACnG,YAAY;IAKrB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,YAAY;IAIpB,gDAAgD;IAChD,IAAI,YAAY,IAAI,MAAM,CAGzB;IAED,OAAO,KAAK,OAAO,GAGlB;IAED,OAAO,CAAC,WAAW;IAiBV,MAAM;CAGhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,KAAK,CAAA;KAClB;CACF"}
|