Skip to content

Commit ee3bfd7

Browse files
authored
refactor: use sx rather than styled (#182)
1 parent c9f9a52 commit ee3bfd7

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

src/components/DataKeyPair.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Box, styled } from '@mui/material'
1+
import { Box } from '@mui/material'
2+
import type { ComponentProps } from 'react'
23
import React, { useCallback, useMemo, useState } from 'react'
34

45
import { useTextColor } from '../hooks/useColor'
@@ -25,10 +26,19 @@ export type DataKeyPairProps = {
2526
path: (string | number)[]
2627
}
2728

28-
const IconBox = styled(props => <Box {...props} component='span'/>)`
29-
cursor: pointer;
30-
padding-left: 0.7rem;
31-
` as typeof Box
29+
type IconBoxProps = ComponentProps<typeof Box>
30+
31+
const IconBox: React.FC<IconBoxProps> = (props) => (
32+
<Box
33+
component='span'
34+
{...props}
35+
sx={{
36+
cursor: 'pointer',
37+
paddingLeft: '0.7rem',
38+
...props.sx
39+
}}
40+
/>
41+
)
3242

3343
export const DataKeyPair: React.FC<DataKeyPairProps> = (props) => {
3444
const { value, path, nestedIndex } = props

src/components/mui/DataBox.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
import { Box, styled } from '@mui/material'
1+
import { Box } from '@mui/material'
2+
import type { ComponentProps } from 'react'
3+
import React from 'react'
24

3-
export const DataBox = styled(props => <Box component='div' {...props}/>)`
4-
display: inline-block;
5-
` as typeof Box
5+
type DataBoxProps = ComponentProps<typeof Box>
6+
7+
export const DataBox: React.FC<DataBoxProps> = props => (
8+
<Box
9+
component='div'
10+
{...props}
11+
sx={{
12+
display: 'inline-block',
13+
...props.sx
14+
}}
15+
/>
16+
)

0 commit comments

Comments
 (0)