Skip to content

Commit

Permalink
PrettyJson theme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Apr 17, 2024
1 parent ecf1111 commit 034d0ca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/components/PrettyJson/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export const PrettyJson = ({ json }: { json: AnyObject }) => {
const Value = ({ children }: { children: React.ReactNode }) => (
<div className="PrettyJson__value">{children}</div>
);
const ValueType = ({
children,
type,
}: {
children: React.ReactNode;
type: string;
}) => <span className={`PrettyJson__value--${type}`}>{children}</span>;
const Quotes = () => <span className="PrettyJson__quotes">{'"'}</span>;
const Colon = () => <span className="PrettyJson__colon">{":"}</span>;
const Comma = () => <span className="PrettyJson__comma">{","}</span>;
Expand Down Expand Up @@ -147,7 +154,13 @@ export const PrettyJson = ({ json }: { json: AnyObject }) => {
<Quotes />
</>
) : (
`"${item}"`
<>
<Quotes />
<ValueType type={isNaN(Number(item)) ? "string" : "number"}>
{item}
</ValueType>
<Quotes />
</>
)}
<Comma />
</Value>
Expand All @@ -162,7 +175,7 @@ export const PrettyJson = ({ json }: { json: AnyObject }) => {
default:
return (
<Value>
{`${item}`}
<ValueType type={typeof item}>{`${item}`}</ValueType>
<Comma />
</Value>
);
Expand Down
20 changes: 18 additions & 2 deletions src/components/PrettyJson/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,30 @@
}

&__value {
color: var(--sds-clr-gray-11);
white-space: nowrap;

&--string {
color: var(--sds-clr-navy-11);
}

&--number {
color: var(--sds-clr-lime-11);
}

&--boolean {
color: var(--sds-clr-pink-11);
}
}

&__value,
&__comma,
&__quotes,
&__bracket,
&__key {
color: var(--sds-clr-gray-11);
color: var(--sds-clr-gray-12);
}

.Link {
font-family: var(--sds-ff-monospace);
}
}

0 comments on commit 034d0ca

Please sign in to comment.