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

Getting the JSON themes to match #975

Merged
merged 3 commits into from
Feb 7, 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
25 changes: 24 additions & 1 deletion src/components/tables/cells/logs/MessageCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TableCell, Typography } from '@mui/material';
import { jsonObjectPreview_key, jsonObjectPreview_value } from 'context/Theme';
import { isEmpty } from 'lodash';
import { ObjectPreview } from 'react-inspector';
import { BaseTypographySx } from './shared';
Expand All @@ -22,7 +23,29 @@ function MessageCell({ fields, message }: Props) {
</Typography>

{!isEmpty(fields) ? (
<Typography component="div" sx={{ ...BaseTypographySx }}>
<Typography
component="div"
sx={{
...BaseTypographySx,
// The object preview does not accept themeing so manually setting these on the wrapper
// obviously these are fairly brittle. They prevent some styling to come through (like color for types of data)
// but I think that is okay given
'& > span span:first-of-type': {
color: (theme) =>
`${
jsonObjectPreview_key[theme.palette.mode]
} !important`,
[`& + span`]: {
color: (theme) =>
`${
jsonObjectPreview_value[
theme.palette.mode
]
} !important`,
},
},
}}
>
<ObjectPreview data={fields} />
</Typography>
) : null}
Expand Down
10 changes: 10 additions & 0 deletions src/context/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ export const jsonViewTheme: {
dark: `bright`,
};

// Based on the colors in the theme above
export const jsonObjectPreview_key = {
light: `rgb(26, 25, 26)`,
dark: `rgb(255, 255, 255)`,
};
export const jsonObjectPreview_value = {
light: `rgb(246, 103, 30)`,
dark: `rgb(252, 109, 36)`,
};

// Styles

export const tableAlternateRowsSx: SxProps<Theme> = {
Expand Down