Skip to content

Commit 684bb25

Browse files
authored
Add attention attribute to <wa-badge>; fixes #940 (#962)
* add attention attribute; fixes #940 * add bounce * update changelog * reword
1 parent 1f2ebf5 commit 684bb25

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

docs/docs/components/badge.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,34 @@ Use the `pill` attribute to give badges rounded edges.
8989
<wa-badge variant="danger" pill>Danger</wa-badge>
9090
```
9191

92-
### Pulsating Badges
92+
### Drawing Attention
9393

94-
Use the `pulse` attribute to draw attention to the badge with a subtle animation.
94+
Use the `attention` attribute to draw attention to the badge with a subtle animation. Supported effects are `bounce`, `pulse` and `none`.
9595

9696
```html {.example}
97-
<div class="badge-pulse">
98-
<wa-badge variant="brand" pill pulse>1</wa-badge>
99-
<wa-badge variant="success" pill pulse>1</wa-badge>
100-
<wa-badge variant="neutral" pill pulse>1</wa-badge>
101-
<wa-badge variant="warning" pill pulse>1</wa-badge>
102-
<wa-badge variant="danger" pill pulse>1</wa-badge>
97+
<div class="badge-attention">
98+
<wa-badge variant="brand" attention="pulse" pill>1</wa-badge>
99+
<wa-badge variant="success" attention="pulse" pill>1</wa-badge>
100+
<wa-badge variant="neutral" attention="pulse" pill>1</wa-badge>
101+
<wa-badge variant="warning" attention="pulse" pill>1</wa-badge>
102+
<wa-badge variant="danger" attention="pulse" pill>1</wa-badge>
103+
</div>
104+
105+
<div class="badge-attention">
106+
<wa-badge variant="brand" attention="bounce" pill>1</wa-badge>
107+
<wa-badge variant="success" attention="bounce" pill>1</wa-badge>
108+
<wa-badge variant="neutral" attention="bounce" pill>1</wa-badge>
109+
<wa-badge variant="warning" attention="bounce" pill>1</wa-badge>
110+
<wa-badge variant="danger" attention="bounce" pill>1</wa-badge>
103111
</div>
104112

105113
<style>
106-
.badge-pulse wa-badge:not(:last-of-type) {
107-
margin-right: 1rem;
114+
.badge-attention {
115+
margin-block-end: var(--wa-space-m);
116+
117+
wa-badge:not(:last-of-type) {
118+
margin-right: 1rem;
119+
}
108120
}
109121
</style>
110122
```

docs/docs/resources/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ During the alpha period, things might break! We take breaking changes very serio
1515
## Next
1616

1717
- 🚨 BREAKING: Renamed the `classic` theme to `shoelace`
18+
- 🚨 BREAKING: Renamed `pulse` attribute in `<wa-badge>` to `attention="pulse"` and added `attention="bounce"` [issue:#940]
1819
- Fixed a bug in `<wa-radio-group>` that caused radios to uncheck when assigning a numeric value [issue:924]
1920

2021
## 3.0.0-alpha.13

src/components/badge/badge.css

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
border-radius: var(--wa-border-radius-pill);
2424
}
2525

26-
/* Pulse modifier */
27-
:host([pulse]) {
26+
/* Pulse attention */
27+
:host([attention='pulse']) {
2828
--pulse-color: var(--background-color);
2929

3030
animation: pulse 1.5s infinite;
@@ -42,6 +42,27 @@
4242
}
4343
}
4444

45+
/* Bounce attention */
46+
:host([attention='bounce']) {
47+
animation: bounce 1s cubic-bezier(0.28, 0.84, 0.42, 1) infinite;
48+
}
49+
50+
@keyframes bounce {
51+
0%,
52+
20%,
53+
50%,
54+
80%,
55+
100% {
56+
transform: translateY(0);
57+
}
58+
40% {
59+
transform: translateY(-5px);
60+
}
61+
60% {
62+
transform: translateY(-2px);
63+
}
64+
}
65+
4566
::slotted(wa-icon) {
4667
margin-inline-end: var(--wa-space-2xs, 0.25em);
4768
opacity: 90%;

src/components/badge/badge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class WaBadge extends WebAwesomeElement {
3939
@property({ type: Boolean, reflect: true }) pill = false;
4040

4141
/** Makes the badge pulsate to draw attention. */
42-
@property({ type: Boolean, reflect: true }) pulse = false;
42+
@property({ reflect: true }) attention: 'none' | 'pulse' = 'none';
4343

4444
render() {
4545
return html` <slot part="base" role="status"></slot>`;

0 commit comments

Comments
 (0)