@sonardigital/carbon-ui 1.2.15 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/atoms/bounce/Bounce.tsx +55 -0
- package/src/components/atoms/bounce/index.ts +2 -0
- package/src/components/atoms/index.ts +2 -0
- package/src/components/atoms/pulsing-badge/PulsingBadge.tsx +106 -0
- package/src/components/atoms/pulsing-badge/index.ts +1 -0
- package/src/theme/constants/components.ts +42 -50
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { motion, useReducedMotion, type Transition } from 'framer-motion';
|
|
2
|
+
|
|
3
|
+
export type BounceProps = React.PropsWithChildren<{
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
tapScale?: number;
|
|
8
|
+
tapY?: number;
|
|
9
|
+
transition?: Transition;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export function Bounce({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
style,
|
|
16
|
+
disabled = false,
|
|
17
|
+
tapScale = 0.98,
|
|
18
|
+
tapY = 0,
|
|
19
|
+
transition,
|
|
20
|
+
}: BounceProps): React.ReactElement {
|
|
21
|
+
const reducedMotion = useReducedMotion();
|
|
22
|
+
|
|
23
|
+
const effectiveDisabled = disabled || reducedMotion;
|
|
24
|
+
const effectiveTransition: Transition = transition ?? {
|
|
25
|
+
type: 'spring',
|
|
26
|
+
stiffness: 520,
|
|
27
|
+
damping: 22,
|
|
28
|
+
mass: 0.55,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<motion.span
|
|
33
|
+
className={className}
|
|
34
|
+
style={{
|
|
35
|
+
display: 'inline-flex',
|
|
36
|
+
willChange: effectiveDisabled ? undefined : 'transform',
|
|
37
|
+
transform: effectiveDisabled ? undefined : 'translateZ(0)',
|
|
38
|
+
backfaceVisibility: 'hidden',
|
|
39
|
+
transformOrigin: 'center',
|
|
40
|
+
...style,
|
|
41
|
+
}}
|
|
42
|
+
whileTap={
|
|
43
|
+
effectiveDisabled
|
|
44
|
+
? undefined
|
|
45
|
+
: {
|
|
46
|
+
...(tapScale != null ? { scale: tapScale } : null),
|
|
47
|
+
...(tapY ? { y: tapY } : null),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
transition={effectiveTransition}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</motion.span>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Box, keyframes, type BoxProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
const pulseRing = keyframes`
|
|
4
|
+
0% {
|
|
5
|
+
transform: scale(1);
|
|
6
|
+
opacity: 0.5;
|
|
7
|
+
}
|
|
8
|
+
100% {
|
|
9
|
+
transform: scale(1.35);
|
|
10
|
+
opacity: 0;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const pulseScale = keyframes`
|
|
15
|
+
0%, 100% {
|
|
16
|
+
transform: scale(1);
|
|
17
|
+
}
|
|
18
|
+
50% {
|
|
19
|
+
transform: scale(1.04);
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export type PulsingBadgeProps = BoxProps & {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
showBadge?: boolean;
|
|
26
|
+
badgePosition?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
27
|
+
badgeSize?: number;
|
|
28
|
+
badgeColor?: string;
|
|
29
|
+
pulseContent?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function PulsingBadge({
|
|
33
|
+
children,
|
|
34
|
+
showBadge = true,
|
|
35
|
+
badgePosition = 'top-right',
|
|
36
|
+
badgeSize = 10,
|
|
37
|
+
badgeColor = 'primary.main',
|
|
38
|
+
pulseContent = false,
|
|
39
|
+
sx,
|
|
40
|
+
...props
|
|
41
|
+
}: PulsingBadgeProps): React.ReactElement {
|
|
42
|
+
const badgeOffsets =
|
|
43
|
+
badgePosition === 'top-left'
|
|
44
|
+
? { top: -4, left: -4 }
|
|
45
|
+
: badgePosition === 'bottom-right'
|
|
46
|
+
? { bottom: -4, right: -4 }
|
|
47
|
+
: badgePosition === 'bottom-left'
|
|
48
|
+
? { bottom: -4, left: -4 }
|
|
49
|
+
: { top: -4, right: -4 };
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Box
|
|
53
|
+
{...props}
|
|
54
|
+
sx={{
|
|
55
|
+
position: 'relative',
|
|
56
|
+
display: 'inline-flex',
|
|
57
|
+
'& > *': {
|
|
58
|
+
position: 'relative',
|
|
59
|
+
zIndex: 1,
|
|
60
|
+
...(pulseContent
|
|
61
|
+
? { animation: `${pulseScale} 2s ease-in-out infinite` }
|
|
62
|
+
: null),
|
|
63
|
+
},
|
|
64
|
+
...(showBadge
|
|
65
|
+
? {
|
|
66
|
+
'& .PulsingBadge-badge': {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
zIndex: 2,
|
|
69
|
+
width: badgeSize,
|
|
70
|
+
height: badgeSize,
|
|
71
|
+
borderRadius: 999,
|
|
72
|
+
backgroundColor: badgeColor,
|
|
73
|
+
boxShadow: theme =>
|
|
74
|
+
`0 0 0 2px ${theme.palette.background.paper}`,
|
|
75
|
+
pointerEvents: 'none',
|
|
76
|
+
...badgeOffsets,
|
|
77
|
+
'&::before': {
|
|
78
|
+
content: '""',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
inset: -6,
|
|
81
|
+
borderRadius: 999,
|
|
82
|
+
border: '2px solid',
|
|
83
|
+
borderColor: badgeColor,
|
|
84
|
+
opacity: 0.6,
|
|
85
|
+
animation: `${pulseRing} 1.8s ease-out infinite`,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
: null),
|
|
90
|
+
'@media (prefers-reduced-motion: reduce)': {
|
|
91
|
+
'& .PulsingBadge-badge::before': {
|
|
92
|
+
animation: 'none',
|
|
93
|
+
opacity: 0,
|
|
94
|
+
},
|
|
95
|
+
'& > *': { animation: 'none' },
|
|
96
|
+
},
|
|
97
|
+
...sx,
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
{showBadge ? (
|
|
102
|
+
<Box component="span" className="PulsingBadge-badge" />
|
|
103
|
+
) : null}
|
|
104
|
+
</Box>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PulsingBadge';
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Theme } from '@emotion/react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ButtonProps,
|
|
4
|
+
Components,
|
|
5
|
+
CssVarsTheme,
|
|
6
|
+
linearProgressClasses,
|
|
7
|
+
} from '@mui/material';
|
|
3
8
|
import { palette } from './palette';
|
|
4
9
|
|
|
5
10
|
const defaultButtonStyle = {
|
|
@@ -13,6 +18,27 @@ const defaultButtonStyle = {
|
|
|
13
18
|
|
|
14
19
|
const borderRadius = 1;
|
|
15
20
|
|
|
21
|
+
const generateButtonVariants = (
|
|
22
|
+
color: Exclude<NonNullable<ButtonProps['color']>, 'inherit'>,
|
|
23
|
+
) => {
|
|
24
|
+
return {
|
|
25
|
+
props: {
|
|
26
|
+
variant: 'contained' as const,
|
|
27
|
+
color,
|
|
28
|
+
},
|
|
29
|
+
style: ({ theme }: any) => ({
|
|
30
|
+
...defaultButtonStyle,
|
|
31
|
+
backgroundColor: theme.palette[color].light,
|
|
32
|
+
color: theme.palette[color].main,
|
|
33
|
+
'&:hover': {
|
|
34
|
+
boxShadow: 0,
|
|
35
|
+
backgroundColor: theme.palette[color].main,
|
|
36
|
+
color: 'white',
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
16
42
|
export const components: Components<
|
|
17
43
|
Omit<Theme, 'components' | 'palette'> & CssVarsTheme
|
|
18
44
|
> = {
|
|
@@ -202,7 +228,15 @@ export const components: Components<
|
|
|
202
228
|
},
|
|
203
229
|
},
|
|
204
230
|
},
|
|
205
|
-
|
|
231
|
+
MuiSkeleton: {
|
|
232
|
+
defaultProps: {
|
|
233
|
+
variant: 'rounded',
|
|
234
|
+
animation: 'wave',
|
|
235
|
+
sx: {
|
|
236
|
+
bgcolor: 'grey.100',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
206
240
|
MuiAccordionDetails: {
|
|
207
241
|
defaultProps: {
|
|
208
242
|
sx: {
|
|
@@ -290,54 +324,12 @@ export const components: Components<
|
|
|
290
324
|
},
|
|
291
325
|
MuiButton: {
|
|
292
326
|
variants: [
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
...defaultButtonStyle,
|
|
300
|
-
backgroundColor: theme.palette.primary.light,
|
|
301
|
-
color: theme.palette.primary.main,
|
|
302
|
-
'&:hover': {
|
|
303
|
-
boxShadow: 0,
|
|
304
|
-
backgroundColor: theme.palette.primary.main,
|
|
305
|
-
color: 'white',
|
|
306
|
-
},
|
|
307
|
-
}),
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
props: {
|
|
311
|
-
variant: 'contained',
|
|
312
|
-
color: 'secondary',
|
|
313
|
-
},
|
|
314
|
-
style: ({ theme }) => ({
|
|
315
|
-
...defaultButtonStyle,
|
|
316
|
-
backgroundColor: theme.palette.secondary.light,
|
|
317
|
-
color: theme.palette.secondary.main,
|
|
318
|
-
'&:hover': {
|
|
319
|
-
boxShadow: 0,
|
|
320
|
-
backgroundColor: theme.palette.secondary.main,
|
|
321
|
-
color: 'white',
|
|
322
|
-
},
|
|
323
|
-
}),
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
props: {
|
|
327
|
-
variant: 'contained',
|
|
328
|
-
color: 'info',
|
|
329
|
-
},
|
|
330
|
-
style: ({ theme }) => ({
|
|
331
|
-
...defaultButtonStyle,
|
|
332
|
-
paddingTop: 10,
|
|
333
|
-
backgroundColor: theme.palette.info.light,
|
|
334
|
-
color: theme.palette.info.main,
|
|
335
|
-
'&:hover': {
|
|
336
|
-
backgroundColor: theme.palette.info.main,
|
|
337
|
-
color: 'white',
|
|
338
|
-
},
|
|
339
|
-
}),
|
|
340
|
-
},
|
|
327
|
+
generateButtonVariants('primary'),
|
|
328
|
+
generateButtonVariants('secondary'),
|
|
329
|
+
generateButtonVariants('info'),
|
|
330
|
+
generateButtonVariants('error'),
|
|
331
|
+
generateButtonVariants('success'),
|
|
332
|
+
generateButtonVariants('warning'),
|
|
341
333
|
{
|
|
342
334
|
props: {
|
|
343
335
|
variant: 'text',
|