Skip to content

Commit

Permalink
fix: improve part of ui not covered by theme color
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Jan 24, 2024
1 parent a173bd0 commit 7579197
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/DataTypes/Object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,24 @@ const PreObjectType: FC<DataItemProps<object>> = (props) => {

const PostObjectType: FC<DataItemProps<object>> = (props) => {
const metadataColor = useJsonViewerStore(store => store.colorspace.base04)
const textColor = useTextColor()
const isArray = useMemo(() => Array.isArray(props.value), [props.value])
const isEmptyValue = useMemo(() => getValueSize(props.value) === 0, [props.value])
const sizeOfValue = useMemo(() => inspectMetadata(props.value), [props.value])
const displaySize = useJsonViewerStore(store => store.displaySize)
const shouldDisplaySize = useMemo(() => typeof displaySize === 'function' ? displaySize(props.path, props.value) : displaySize, [displaySize, props.path, props.value])

return (
<Box component='span' className='data-object-end'>
<Box
component='span'
className='data-object-end'
sx={{
lineHeight: 1.5,
color: textColor,
letterSpacing: 0.5,
opacity: 0.8
}}
>
{isArray ? arrayRb : objectRb}
{shouldDisplaySize && (isEmptyValue || !props.inspect)
? (
Expand Down
8 changes: 7 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,18 @@ export const JsonViewer = function JsonViewer<Value> (props: JsonViewerProps<Val
: themeType === 'dark'
? darkColorspace.base00
: lightColorspace.base00
const foregroundColor = typeof themeType === 'object'
? themeType.base07
: themeType === 'dark'
? darkColorspace.base07
: lightColorspace.base07
return createTheme({
components: {
MuiPaper: {
styleOverrides: {
root: {
backgroundColor
backgroundColor,
color: foregroundColor
}
}
}
Expand Down

0 comments on commit 7579197

Please sign in to comment.