Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve part of ui not covered by theme color #446

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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