Skip to content

Commit bc0117c

Browse files
authored
feat(icons): new throb and fade animations (#5122)
Co-authored-by: Jacob Müller
1 parent 92d504f commit bc0117c

File tree

7 files changed

+644
-591
lines changed

7 files changed

+644
-591
lines changed

src/_variables.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ $b-custom-file-height-inner-sm: calc(
6464
$b-icon-vertical-offset: -0.15em;
6565

6666
// Animations
67+
$b-icon-animation-cylon-duration: 0.75s !default;
68+
$b-icon-animation-cylon-vertical-duration: $b-icon-animation-cylon-duration !default;
69+
$b-icon-animation-fade-duration: 0.75s !default;
6770
$b-icon-animation-spin-duration: 2s !default;
6871
$b-icon-animation-spin-reverse-duration: $b-icon-animation-spin-duration !default;
6972
$b-icon-animation-spin-pulse-duration: 1s !default;
7073
$b-icon-animation-spin-reverse-pulse-duration: $b-icon-animation-spin-pulse-duration !default;
71-
$b-icon-animation-cylon-duration: 0.75s !default;
72-
$b-icon-animation-cylon-vertical-duration: $b-icon-animation-cylon-duration !default;
74+
$b-icon-animation-throb-duration: 0.75s !default;
7375

7476
// --- Sidebar ---
7577

src/icons/README.md

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Vue.use(BootstrapVueIcons)
127127
BootstrapVue icons SCSS/CSS does not depend on any Bootstrap SASS variables, mixins, functions or
128128
CSS classes (other than the Bootstrap `text-{variant}` text color utility classes, if using the
129129
`variant` prop). Please note that the icons CSS is _also_ included in the main BootstrapVue SCSS/CSS
130-
files.
130+
files. Animations effects require BootstrapVue custom SCSS/CSS.
131131

132132
### Browser
133133

@@ -439,18 +439,32 @@ affected. If you need to shift the border/background with the icon, use Bootstra
439439

440440
BootstrapVue includes the following built-in animations for icons:
441441

442+
- `'cylon'` slides the icon left-right
443+
- `'cylon-vertical'` slides the icon up-down
444+
- `'fade'` fades the icon in and out <span class="badge badge-info small">2.12.0+</span>
442445
- `'spin'` smoothly spins the icon clockwise
443446
- `'spin-reverse'` smoothly spins the icon counter-clockwise
444447
- `'spin-pulse'` spins the icon clockwise, but in a pulsed step style
445448
- `'spin-reverse-pulse'` spins the icon counter-clockwise, but in a pulsed step style
446-
- `'cylon'` slides the icon left-right
447-
- '`cylon-vertical'` slides the icon up-down
449+
- `'throb'` scales the icon in and out <span class="badge badge-info small">2.12.0+</span>
448450

449451
To use the animation, set the `animation` prop to one of the animation names above.
450452

451453
```html
452454
<template>
453455
<b-row class="text-md-center">
456+
<b-col md="6" class="mb-3">
457+
<p>Cylon animation:</p>
458+
<b-icon icon="three-dots" animation="cylon" font-scale="4"></b-icon>
459+
</b-col>
460+
<b-col md="6" class="mb-3">
461+
<p>Vertical cylon animation:</p>
462+
<b-icon icon="three-dots-vertical" animation="cylon-vertical" font-scale="4"></b-icon>
463+
</b-col>
464+
<b-col md="6" class="mb-3">
465+
<p>Fade animation:</p>
466+
<b-icon icon="star-fill" animation="fade" font-scale="4"></b-icon>
467+
</b-col>
454468
<b-col md="6" class="mb-3">
455469
<p>Spinning animation:</p>
456470
<b-icon icon="arrow-clockwise" animation="spin" font-scale="4"></b-icon>
@@ -468,23 +482,15 @@ To use the animation, set the `animation` prop to one of the animation names abo
468482
<b-icon icon="arrow-counterclockwise" animation="spin-reverse-pulse" font-scale="4"></b-icon>
469483
</b-col>
470484
<b-col md="6" class="mb-3">
471-
<p>Cylon animation:</p>
472-
<b-icon icon="three-dots" animation="cylon" font-scale="4"></b-icon>
473-
</b-col>
474-
<b-col md="6" class="mb-3">
475-
<p>Vertical cylon animation:</p>
476-
<b-icon icon="three-dots-vertical" animation="cylon-vertical" font-scale="4"></b-icon>
485+
<p>Throb animation:</p>
486+
<b-icon icon="circle-fill" animation="throb" font-scale="4"></b-icon>
477487
</b-col>
478488
</div>
479489
</template>
480490

481491
<!-- b-icon-aminations.vue -->
482492
```
483493

484-
Note with the `cylon` animations, the left-right movement (or up-down movement) extends past the
485-
icon's bounding box by `+/- 25%`, so you may need to adjust padding or margins to compensate for
486-
your use case.
487-
488494
As the animations are CSS based, they are applied _after_ any SVG transforms have taken place:
489495

490496
```html
@@ -504,13 +510,18 @@ Need a different style animation? Just create a custom class defining the animat
504510
class to the icon component, or create a new animation class in the form of
505511
`b-icon-animation-{animationName}` and pass the custom animation name to the `animation` prop.
506512

507-
**Note:** The BootstrapVue defined animation effects of this component is dependent on the
508-
`prefers-reduced-motion` media query. See the
509-
[reduced motion section of our accessibility documentation](/docs/reference/accessibility) for
510-
additional details.
513+
**Animation notes:**
511514

512-
Side note: the `cylon` animation gets its name from the "eye" of the Cylons from the _original_
513-
[1978 Battlestar Galactica TV series](https://www.youtube.com/watch?v=5a5bEIf0UaU).
515+
- With the `cylon` animations, the left-right movement (or up-down movement) extends _past_ the
516+
icon's bounding box by `+/- 25%`, so you may need to adjust padding or margins to compensate for
517+
your use case.
518+
- Animation durations can be [configured via SASS SCSS variables](/docs/reference/theming)
519+
- The BootstrapVue defined animation effects of this component is dependent on the
520+
`prefers-reduced-motion` media query. See the
521+
[reduced motion section of our accessibility documentation](/docs/reference/accessibility#reduced-motion)
522+
for additional details.
523+
- The `cylon` animation gets its name from the "eye" of the Cylons from the _original_
524+
[1978 Battlestar Galactica TV series](https://www.youtube.com/watch?v=5a5bEIf0UaU).
514525

515526
## Stacking icons
516527

@@ -572,7 +583,7 @@ available on individual icons.
572583

573584
Stacked icon notes:
574585

575-
- Remember to set the `stacked` prop on the inner icon components
586+
- Remember to set the `stacked` prop on the inner icon components!
576587
- The `font-scale` prop cannot be used on the inner icon components
577588
- The `width` and `height` attributes cannot be applied to the inner icon components
578589
- Stacked icons **cannot** be stacked inside another `<b-iconstack>`
@@ -603,7 +614,7 @@ Individual icons within the icon stack can also be animated (except on IE 11):
603614
<b-icon
604615
stacked
605616
icon="camera"
606-
animation="spin"
617+
animation="throb"
607618
variant="info"
608619
scale="0.75"
609620
></b-icon>
@@ -644,20 +655,19 @@ font scaled by 125%).
644655
<template>
645656
<div>
646657
<b-button size="sm" class="mb-2">
647-
<b-icon icon="gear-fill"></b-icon> Settings
658+
<b-icon icon="gear-fill" aria-hidden="true"></b-icon> Settings
648659
</b-button>
649660
<br>
650661
<b-button variant="primary" class="mb-2">
651-
Pay now <b-icon icon="credit-card"></b-icon>
662+
Pay now <b-icon icon="credit-card" aria-hidden="true"></b-icon>
652663
</b-button>
653664
<br>
654665
<b-button variant="outline-info" class="mb-2">
655-
<b-icon icon="power"></b-icon> Logout
666+
<b-icon icon="power" aria-hidden="true"></b-icon> Logout
656667
</b-button>
657668
<br>
658669
<b-button size="lg" variant="primary" class="mb-2">
659-
<b-icon icon="question-circle-fill" aria-hidden="true"></b-icon>
660-
<span class="sr-only">Help</span>
670+
<b-icon icon="question-circle-fill" aria-label="Help"></b-icon>
661671
</b-button>
662672
</div>
663673
</template>

src/icons/_icons.scss

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@
88
vertical-align: $b-icon-vertical-offset;
99
}
1010

11+
&.b-icon-animation-cylon,
12+
&.b-iconstack .b-icon-animation-cylon > g {
13+
transform-origin: center;
14+
animation: $b-icon-animation-cylon-duration infinite ease-in-out alternate
15+
b-icon-animation-cylon;
16+
17+
@media (prefers-reduced-motion: reduce) {
18+
animation: none;
19+
}
20+
}
21+
22+
&.b-icon-animation-cylon-vertical,
23+
&.b-iconstack .b-icon-animation-cylon-vertical > g {
24+
transform-origin: center;
25+
animation: $b-icon-animation-cylon-vertical-duration infinite ease-in-out alternate
26+
b-icon-animation-cylon-vertical;
27+
28+
@media (prefers-reduced-motion: reduce) {
29+
animation: none;
30+
}
31+
}
32+
33+
&.b-icon-animation-fade,
34+
&.b-iconstack .b-icon-animation-fade > g {
35+
transform-origin: center;
36+
animation: $b-icon-animation-throb-duration infinite ease-in-out alternate b-icon-animation-fade;
37+
38+
@media (prefers-reduced-motion: reduce) {
39+
animation: none;
40+
}
41+
}
42+
1143
&.b-icon-animation-spin,
1244
&.b-iconstack .b-icon-animation-spin > g {
1345
transform-origin: center;
@@ -49,54 +81,63 @@
4981
}
5082
}
5183

52-
&.b-icon-animation-cylon,
53-
&.b-iconstack .b-icon-animation-cylon > g {
84+
&.b-icon-animation-throb,
85+
&.b-iconstack .b-icon-animation-throb > g {
5486
transform-origin: center;
55-
animation: $b-icon-animation-cylon-duration infinite ease-in-out alternate
56-
b-icon-animation-cylon;
87+
animation: $b-icon-animation-throb-duration infinite ease-in-out alternate
88+
b-icon-animation-throb;
5789

5890
@media (prefers-reduced-motion: reduce) {
5991
animation: none;
6092
}
6193
}
94+
}
6295

63-
&.b-icon-animation-cylon-vertical,
64-
&.b-iconstack .b-icon-animation-cylon-vertical > g {
65-
transform-origin: center;
66-
animation: $b-icon-animation-cylon-vertical-duration infinite ease-in-out alternate
67-
b-icon-animation-cylon-vertical;
96+
// Animation for spinning icons
97+
@keyframes b-icon-animation-cylon {
98+
0% {
99+
transform: translateX(-25%);
100+
}
101+
100% {
102+
transform: translateX(25%);
103+
}
104+
}
68105

69-
@media (prefers-reduced-motion: reduce) {
70-
animation: none;
71-
}
106+
@keyframes b-icon-animation-cylon-vertical {
107+
0% {
108+
transform: translateY(25%);
109+
}
110+
100% {
111+
transform: translateY(-25%);
72112
}
73113
}
74114

75-
// Animation for spinning icons
76-
@keyframes b-icon-animation-spin {
115+
@keyframes b-icon-animation-fade {
77116
0% {
78-
transform: rotate(0deg);
117+
opacity: 0.1;
79118
}
80119
100% {
81-
transform: rotate(359deg);
120+
opacity: 1;
82121
}
83122
}
84123

85-
@keyframes b-icon-animation-cylon {
124+
@keyframes b-icon-animation-spin {
86125
0% {
87-
transform: translateX(-25%);
126+
transform: rotate(0deg);
88127
}
89128
100% {
90-
transform: translateX(25%);
129+
transform: rotate(359deg);
91130
}
92131
}
93132

94-
@keyframes b-icon-animation-cylon-vertical {
133+
@keyframes b-icon-animation-throb {
95134
0% {
96-
transform: translateY(25%);
135+
opacity: 0.5;
136+
transform: scale(0.5);
97137
}
98138
100% {
99-
transform: translateY(-25%);
139+
opacity: 1;
140+
transform: scale(1);
100141
}
101142
}
102143

src/icons/icons.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// --- BEGIN AUTO-GENERATED FILE ---
22
//
33
// @IconsVersion: 1.0.0-alpha3
4-
// @Generated: 2020-03-19T18:55:36.736Z
4+
// @Generated: 2020-04-13T19:59:46.519Z
55
//
66
// This file is generated on each build. Do not edit this file!
77

src/icons/icons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// --- BEGIN AUTO-GENERATED FILE ---
22
//
33
// @IconsVersion: 1.0.0-alpha3
4-
// @Generated: 2020-03-19T18:55:36.736Z
4+
// @Generated: 2020-04-13T19:59:46.519Z
55
//
66
// This file is generated on each build. Do not edit this file!
77

0 commit comments

Comments
 (0)