1
1
// Copyright (C) 2022-2025 Intel Corporation
2
2
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
3
3
4
- import { CSSProperties } from 'react' ;
5
-
6
- import clsx from 'clsx' ;
4
+ import { motion } from 'framer-motion' ;
7
5
8
6
import { ColorMode } from '../quiet-button/quiet-action-button.component' ;
9
7
10
- import classes from './three-dots-flashing.component.module.scss' ;
11
-
12
8
type Sizes = 'S' | 'M' ;
13
9
14
10
interface ThreeDotsFlashingProps {
@@ -17,40 +13,57 @@ interface ThreeDotsFlashingProps {
17
13
className ?: string ;
18
14
}
19
15
16
+ const DOT_COLORS : Record < ColorMode , string > = {
17
+ [ ColorMode . DARK ] : 'var(--spectrum-global-color-gray-800)' ,
18
+ [ ColorMode . LIGHT ] : 'var(--spectrum-global-color-gray-50)' ,
19
+ [ ColorMode . BLUE ] : 'var(--spectrum-global-color-gray-800)' ,
20
+ } ;
21
+
22
+ const DOT_SIZES : Record < Sizes , number > = {
23
+ S : 8 ,
24
+ M : 16 ,
25
+ } ;
26
+
20
27
export const ThreeDotsFlashing = ( {
21
28
mode = ColorMode . DARK ,
22
29
size = 'M' ,
23
30
className,
24
31
} : ThreeDotsFlashingProps ) : JSX . Element => {
25
- const colors : Record < ColorMode , CSSProperties > = {
26
- [ ColorMode . DARK ] : {
27
- '--bgColorStartAnimation' : 'var(--spectrum-global-color-gray-800)' ,
28
- '--bgColorEndAnimation' : 'var(--white-down)' ,
29
- } as CSSProperties ,
30
- [ ColorMode . LIGHT ] : {
31
- '--bgColorStartAnimation' : 'var(--spectrum-global-color-gray-50)' ,
32
- '--bgColorEndAnimation' : 'var(--dark-down)' ,
33
- } as CSSProperties ,
34
- [ ColorMode . BLUE ] : {
35
- '--bgColorStartAnimation' : 'var(--spectrum-global-color-gray-800)' ,
36
- '--bgColorEndAnimation' : 'var(--white-down)' ,
37
- } as CSSProperties ,
38
- } ;
32
+ const dotColor = DOT_COLORS [ mode ] ;
33
+ const dotSize = DOT_SIZES [ size ] ;
39
34
40
- const sizes : Record < Sizes , CSSProperties > = {
41
- S : {
42
- '--dotSize' : 'var(--spectrum-global-dimension-size-25)' ,
43
- } as CSSProperties ,
44
- M : {
45
- '--dotSize' : 'var(--spectrum-global-dimension-size-50)' ,
46
- } as CSSProperties ,
35
+ const dotVariants = {
36
+ pulse : {
37
+ scale : [ 1 , 1.5 , 1 ] ,
38
+ transition : {
39
+ duration : 1.2 ,
40
+ repeat : Infinity ,
41
+ ease : 'easeInOut' ,
42
+ } ,
43
+ } ,
47
44
} ;
48
45
49
46
return (
50
47
< div
51
- style = { { ...colors [ mode ] , ...sizes [ size ] } }
52
- className = { clsx ( classes . flashingAnimation , className ) }
53
- aria-label = { 'three dots flashing animation' }
54
- > </ div >
48
+ style = { { display : 'flex' , gap : dotSize , alignItems : 'center' , justifyContent : 'center' } }
49
+ aria-label = 'three dots flashing animation'
50
+ className = { className }
51
+ >
52
+ { [ 0 , 1 , 2 ] . map ( ( i ) => (
53
+ < motion . div
54
+ key = { i }
55
+ variants = { dotVariants }
56
+ animate = 'pulse'
57
+ transition = { { delay : i * 0.2 } }
58
+ style = { {
59
+ width : dotSize ,
60
+ height : dotSize ,
61
+ borderRadius : '50%' ,
62
+ background : dotColor ,
63
+ willChange : 'transform' ,
64
+ } }
65
+ />
66
+ ) ) }
67
+ </ div >
55
68
) ;
56
69
} ;
0 commit comments