Skip to content

Commit

Permalink
refactor: use sx rather than styled (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh authored Jan 17, 2023
1 parent c9f9a52 commit ee3bfd7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
20 changes: 15 additions & 5 deletions src/components/DataKeyPair.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, styled } from '@mui/material'
import { Box } from '@mui/material'
import type { ComponentProps } from 'react'
import React, { useCallback, useMemo, useState } from 'react'

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

const IconBox = styled(props => <Box {...props} component='span'/>)`
cursor: pointer;
padding-left: 0.7rem;
` as typeof Box
type IconBoxProps = ComponentProps<typeof Box>

const IconBox: React.FC<IconBoxProps> = (props) => (
<Box
component='span'
{...props}
sx={{
cursor: 'pointer',
paddingLeft: '0.7rem',
...props.sx
}}
/>
)

export const DataKeyPair: React.FC<DataKeyPairProps> = (props) => {
const { value, path, nestedIndex } = props
Expand Down
19 changes: 15 additions & 4 deletions src/components/mui/DataBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { Box, styled } from '@mui/material'
import { Box } from '@mui/material'
import type { ComponentProps } from 'react'
import React from 'react'

export const DataBox = styled(props => <Box component='div' {...props}/>)`
display: inline-block;
` as typeof Box
type DataBoxProps = ComponentProps<typeof Box>

export const DataBox: React.FC<DataBoxProps> = props => (
<Box
component='div'
{...props}
sx={{
display: 'inline-block',
...props.sx
}}
/>
)

0 comments on commit ee3bfd7

Please sign in to comment.