|
1 | 1 | import React from 'react' |
2 | | -import {merge, type SxProp} from '../../sx' |
3 | | -import {type CSSProperties} from 'react' |
| 2 | +import {type CSSProperties, type HTMLProps} from 'react' |
4 | 3 | import {clsx} from 'clsx' |
5 | 4 | import classes from './SkeletonBox.module.css' |
6 | | -import {defaultSxProp} from '../../utils/defaultSxProp' |
7 | | -import Box from '../../Box' |
| 5 | +import {merge} from '../sx' |
8 | 6 |
|
9 | | -type SkeletonBoxProps = { |
| 7 | +export type SkeletonBoxProps = { |
10 | 8 | /** Height of the skeleton "box". Accepts any valid CSS `height` value. */ |
11 | 9 | height?: CSSProperties['height'] |
12 | 10 | /** Width of the skeleton "box". Accepts any valid CSS `width` value. */ |
13 | 11 | width?: CSSProperties['width'] |
14 | 12 | /** The className of the skeleton box */ |
15 | 13 | className?: string |
16 | | -} & SxProp & |
17 | | - React.ComponentPropsWithoutRef<'div'> |
| 14 | +} & HTMLProps<HTMLDivElement> |
18 | 15 |
|
19 | 16 | export const SkeletonBox = React.forwardRef<HTMLDivElement, SkeletonBoxProps>(function SkeletonBox( |
20 | | - {height, width, className, style, sx: sxProp = defaultSxProp, ...props}, |
| 17 | + {height, width, className, style, ...props}, |
21 | 18 | ref, |
22 | 19 | ) { |
23 | | - if (sxProp !== defaultSxProp) { |
24 | | - return ( |
25 | | - <Box |
26 | | - as="div" |
27 | | - className={clsx(className, classes.SkeletonBox)} |
28 | | - style={merge( |
29 | | - style as CSSProperties, |
30 | | - { |
31 | | - height, |
32 | | - width, |
33 | | - } as CSSProperties, |
34 | | - )} |
35 | | - {...props} |
36 | | - ref={ref} |
37 | | - sx={sxProp} |
38 | | - /> |
39 | | - ) |
40 | | - } |
41 | 20 | return ( |
42 | 21 | <div |
43 | 22 | className={clsx(className, classes.SkeletonBox)} |
|
0 commit comments