Skip to content

Commit 018ca10

Browse files
committed
✨(frontend) add animated WarningIcon
In the same way of SuccessIcon, we need to have an animated svg warning icon
1 parent 920244a commit 018ca10

File tree

8 files changed

+151
-15
lines changed

8 files changed

+151
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unrealeased]
1010

11+
### Added
12+
13+
- Add WarningIcon component
14+
1115
### Changed
1216

1317
- Improve Lyra error management to abort payment properly

src/frontend/js/components/SuccessIcon/_styles.scss

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,7 @@
1212
max-height: 100%;
1313
stroke: currentColor;
1414
width: 4.5rem;
15-
16-
@keyframes wave {
17-
0% {
18-
transform: scale(1);
19-
}
20-
33% {
21-
transform: scale(1.2);
22-
}
23-
66% {
24-
transform: scale(0.8);
25-
}
26-
100% {
27-
transform: scale(1);
28-
}
29-
}
15+
@extend %keyframe-wave;
3016

3117
& > * {
3218
fill: none;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.warning-icon {
2+
$duration: 1.1s;
3+
align-items: center;
4+
animation: wave $duration * 0.95 backwards;
5+
border-radius: 100vw;
6+
color: r-theme-val(steps-content, icon-warning-color);
7+
display: inline-flex;
8+
fill: none;
9+
height: 4.5rem;
10+
justify-content: center;
11+
margin-bottom: 1.25rem;
12+
max-height: 100%;
13+
stroke: currentColor;
14+
width: 4.5rem;
15+
@extend %keyframe-wave;
16+
17+
.circle,
18+
.exclamation-mark {
19+
color: r-theme-val(steps-content, icon-warning-background);
20+
&.back {
21+
color: lighten(r-theme-val(steps-content, icon-warning-background), 20%);
22+
}
23+
}
24+
25+
.circle,
26+
.exclamation-mark path {
27+
fill: none;
28+
stroke: currentColor;
29+
stroke-linecap: round;
30+
stroke-width: 2;
31+
}
32+
33+
.exclamation-mark circle {
34+
fill: currentColor;
35+
}
36+
37+
.exclamation-mark path {
38+
$length: 11px;
39+
@include keyframe-strokedLineAppear(exclamationMarkLineAppear, $length, true);
40+
animation: exclamationMarkLineAppear $duration * 0.5 $duration * 0.3 backwards $r-ease-out;
41+
stroke-dasharray: $length;
42+
}
43+
44+
.exclamation-mark circle {
45+
@keyframes exclamationMarkCircleAppear {
46+
0% {
47+
transform: scale(0);
48+
}
49+
66% {
50+
transform: scale(1.2);
51+
}
52+
100% {
53+
transform: scale(1);
54+
}
55+
}
56+
animation: exclamationMarkCircleAppear $duration * 0.5 $duration * 0.2 backwards $r-ease-out;
57+
transform-origin: 16px 23px;
58+
}
59+
60+
.exclamation-mark:nth-of-type(1) {
61+
& > path {
62+
animation-delay: 0;
63+
animation-duration: $duration * 0.2;
64+
}
65+
& > circle {
66+
animation-delay: 0;
67+
animation-duration: $duration * 0.1;
68+
}
69+
}
70+
71+
.circle {
72+
$PI: 3.14159265;
73+
$radius: 16px;
74+
@include keyframe-strokedLineAppear(circleAppear, 2 * $PI * $radius, true);
75+
animation: circleAppear $duration $r-ease-out;
76+
stroke-dasharray: 2 * $PI * $radius;
77+
transform-origin: center center;
78+
transform: rotateZ(-45deg);
79+
80+
&:nth-of-type(1) {
81+
animation-duration: $duration * 0.9;
82+
}
83+
}
84+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const WarningIcon = () => {
2+
return (
3+
<svg className="warning-icon" role="img" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
4+
<circle className="circle back" cx="16" cy="16" r="14" />
5+
<circle className="circle" cx="16" cy="16" r="14" />
6+
<g className="exclamation-mark back">
7+
<path d="M16 8V19" />
8+
<circle cx="16" cy="23" r="1" />
9+
</g>
10+
<g className="exclamation-mark">
11+
<path d="M16 8V19" />
12+
<circle cx="16" cy="23" r="1" />
13+
</g>
14+
</svg>
15+
);
16+
};
17+
18+
export default WarningIcon;

src/frontend/scss/colors/_theme.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ $r-theme: (
561561
icon-big-color: r-color('charcoal'),
562562
icon-success-background: r-color('mantis'),
563563
icon-success-color: r-color('white'),
564+
icon-warning-background: r-color('warning-500'),
565+
icon-warning-color: r-color('white'),
564566
title-color: r-color('charcoal'),
565567
summary-hover-color: r-color('grey59'),
566568
subtitle-color: r-color(purplish-grey),

src/frontend/scss/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
@import '../../js/components/SaleTunnel/Sponsors/SaleTunnelSponsors';
1414
@import '../../js/components/SaleTunnel/SaleTunnelSuccess/styles';
1515
@import '../../js/components/SuccessIcon/styles';
16+
@import '../../js/components/WarningIcon/styles';
1617
@import '../../js/components/RegisteredAddress/styles';
1718
@import '../../js/components/SearchInput/styles';
1819
@import '../../js/components/Spinner/styles';

src/frontend/scss/tools/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@import './features';
99
@import './flexbox';
1010
@import './hero';
11+
@import './keyframes';
1112
@import './list-group';
1213
@import './shapes';
1314
@import './spacing';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// keyframe-strokedLineAppear
3+
//
4+
// Generate a keyframe to make svg stroked element appears slightly
5+
//
6+
// @param {string} name the keyframe's name to use from `animation`
7+
// @param {length} length the full length of the stroke line`
8+
// @param {reverse} reverse animation direction`
9+
@mixin keyframe-strokedLineAppear($name, $length, $reverse: false) {
10+
$direction: 1;
11+
@if $reverse == true {
12+
$direction: -1;
13+
}
14+
15+
@keyframes #{$name} {
16+
from {
17+
stroke-dashoffset: $direction * $length;
18+
}
19+
to {
20+
stroke-dashoffset: 0;
21+
}
22+
}
23+
}
24+
25+
%keyframe-wave {
26+
@keyframes wave {
27+
0% {
28+
transform: scale(1);
29+
}
30+
33% {
31+
transform: scale(1.2);
32+
}
33+
66% {
34+
transform: scale(0.8);
35+
}
36+
100% {
37+
transform: scale(1);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)