Skip to content

Commit f77431c

Browse files
feat: add loader confirmation messages (#281)
1 parent 7fae866 commit f77431c

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

components/loader/checkmark.module.scss

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
height: 80px;
44
border-radius: 50%;
55
display: block;
6-
stroke-width: 2;
7-
stroke: rgba(0, 0, 0, 0.3);
6+
stroke-width: 4;
7+
stroke: var(--background);
88
stroke-miterlimit: 10;
99
margin: 10% auto;
1010
animation: spinner 0.4s linear infinite;
1111
}
1212

13-
:global(.dark) .checkmark {
14-
stroke: var(--background);
15-
}
16-
1713
.checked {
1814
animation: fill 0.3s ease-in-out 0.15s forwards,
1915
scale 0.4s ease-in-out 0.6s both;
@@ -32,7 +28,7 @@
3228
stroke-dashoffset: 80;
3329
stroke-width: 3;
3430
stroke-miterlimit: 10;
35-
stroke: white;
31+
stroke: var(--on-background);
3632
fill: none;
3733
}
3834

@@ -69,6 +65,6 @@
6965

7066
@keyframes fill {
7167
100% {
72-
box-shadow: inset 0px 0px 0px 40px white;
68+
box-shadow: inset 0px 0px 0px 40px var(--on-background);
7369
}
7470
}

components/loader/index.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import { useEffect, useState } from 'react';
1+
import { ReactNode, useEffect, useState } from 'react';
22
import cn from 'classnames';
33

44
import Checkmark from './checkmark';
55
import styles from './loader.module.scss';
66

7-
interface Props {
8-
readonly active: boolean;
9-
readonly checked?: boolean;
7+
export interface LoaderProps {
8+
active: boolean;
9+
checked?: boolean;
10+
children?: ReactNode;
1011
}
1112

12-
export default function Loader({ active, checked }: Props): JSX.Element {
13+
export default function Loader({
14+
active,
15+
checked,
16+
children,
17+
}: LoaderProps): JSX.Element {
1318
const [visible, setVisible] = useState<boolean>(active);
1419
const [closing, setClosing] = useState<boolean>(false);
1520

@@ -39,9 +44,10 @@ export default function Loader({ active, checked }: Props): JSX.Element {
3944
className={styles.overlayCheckmark}
4045
checked={checked}
4146
/>
47+
<article className={cn(styles.message, { [styles.visible]: checked })}>
48+
{children}
49+
</article>
4250
</div>
4351
</div>
4452
);
4553
}
46-
47-
Loader.defaultProps = { checked: false };

components/loader/loader.module.scss

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.overlay {
22
position: absolute;
3-
top: -1px;
4-
bottom: -1px;
5-
left: -1px;
6-
right: -1px;
7-
background: rgba(0, 0, 0, 0.3);
3+
top: 0;
4+
bottom: 0;
5+
left: 0;
6+
right: 0;
7+
background: var(--background);
88
opacity: 0;
99
z-index: 1;
1010
visibility: hidden;
@@ -27,6 +27,8 @@
2727
left: 50%;
2828
transform: translate(-50%, -50%);
2929
text-align: center;
30+
width: 100%;
31+
padding: 24px;
3032
}
3133

3234
.overlayCheckmark {
@@ -37,3 +39,16 @@
3739
box-sizing: border-box;
3840
display: inline-block;
3941
}
42+
43+
article.message {
44+
font-size: 14px;
45+
font-weight: 400;
46+
line-height: 1.25;
47+
transition: opacity 0.4s ease 1.2s;
48+
will-change: opacity;
49+
opacity: 0;
50+
51+
&.visible {
52+
opacity: 1;
53+
}
54+
}

components/user/request-form.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ export default function RequestForm({
217217

218218
return (
219219
<form className={styles.card} onSubmit={onSubmit}>
220-
<Loader active={loading} checked={checked} />
220+
<Loader active={loading} checked={checked}>
221+
That’s it! You’ve been CC-ed on an email notifying {volunteer.firstName}{' '}
222+
of your booking. Feel free to reach out directly; their contact info is
223+
in that email.
224+
</Loader>
221225
<div className={styles.inputs}>
222226
{!creating && (
223227
<UserSelect

0 commit comments

Comments
 (0)