Skip to content

Commit

Permalink
docs: fix logo and tweak playground theme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Oct 2, 2023
1 parent 85f2c46 commit 03a6ceb
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const config = {
title: "JSON P3",
logo: {
alt: "JSON P3",
src: "img/p3_v2_dark.svg",
srcDark: "img/p3_v2_light.svg",
src: "img/p3_v2_dark_path.svg",
srcDark: "img/p3_v2_light_path.svg",
},
items: [
{
Expand Down
31 changes: 24 additions & 7 deletions docs/src/components/JSONPathPlayground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ const commonEditorOptions = {
padding: { bottom: 10, top: 10 },
};

function QueryEditor({ defaultQuery, theme, onChange }) {
function QueryEditor({ defaultQuery, theme, beforeMount, onMount, onChange }) {
return (
<Editor
height="100%"
language="text"
theme={theme}
defaultValue={defaultQuery}
beforeMount={beforeMount}
onChange={onChange}
onMount={onMount}
options={{ ...commonEditorOptions, fontSize: 16, lineNumbers: "off" }}
/>
);
Expand Down Expand Up @@ -64,14 +66,13 @@ function JSONEditor({ onChange, theme }) {
);
}

function ResultsEditor({ result, theme, beforeMount }) {
function ResultsEditor({ result, theme }) {
return (
<Editor
height="100%"
language="json"
theme={theme}
value={result}
beforeMount={beforeMount}
options={{
...commonEditorOptions,
wordWrap: "on",
Expand Down Expand Up @@ -118,20 +119,28 @@ export default function Playground() {
const [data, setData] = useState(defaultData);

const { colorMode } = useColorMode();
const initTheme = colorMode === "light" ? "light" : "vs-dark";
const initTheme = colorMode === "light" ? "Cobalt" : "vs-dark";
const monacoRef = useRef(null);

function handleEditorWillMount(monaco) {
monacoRef.current = monaco;
}

function handleEditorDidMount(_, monaco) {
import("monaco-themes/themes/Cobalt.json")
.then((themeData) => {
monaco.editor.defineTheme("Cobalt", themeData);
})
.then((_) => monaco.editor.setTheme("Cobalt"));
}

/**
* Synchronize colorMode with editor theme.
*/
useEffect(() => {
if (colorMode && monacoRef.current !== null) {
monacoRef.current.editor.setTheme(
colorMode === "light" ? "light" : "vs-dark",
colorMode === "light" ? "Cobalt" : "vs-dark",
);
}
}, [colorMode]);
Expand Down Expand Up @@ -185,14 +194,21 @@ export default function Playground() {
<h1 className={styles.heading}>JSONPath Playground</h1>
<hr className={styles.headingRule} />
</Grid>
<Grid xs={12} sx={{ height: "70vh", border: "1px solid" }}>
<Grid
xs={12}
sx={{
height: "70vh",
border: "1px solid var(--ifm-hr-background-color)",
}}
>
<Allotment minSize={100} vertical>
<Allotment.Pane preferredSize={60} maxSize={200} minSize={60}>
<QueryEditor
defaultQuery={defaultQuery}
theme={initTheme}
onChange={onQueryChange}
beforeMount={handleEditorWillMount}
onMount={handleEditorDidMount}
onChange={onQueryChange}
/>
</Allotment.Pane>
<Allotment.Pane>
Expand All @@ -218,6 +234,7 @@ export default function Playground() {
alignItems: "center",
fontSize: "14px",
textAlign: "center",
marginTop: "3px",
}}
>
<p>
Expand Down
1 change: 0 additions & 1 deletion docs/src/components/JSONPathPlayground/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@

.headingRule {
margin-top: 1em;
margin-bottom: 2em;
}
57 changes: 57 additions & 0 deletions docs/static/img/p3_v2_dark_path.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/static/img/p3_v2_light_path.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03a6ceb

Please sign in to comment.