diff --git a/docsite/src/components/FileExample.tsx b/docsite/src/components/FileExample.tsx index a939073f..53e2786d 100644 --- a/docsite/src/components/FileExample.tsx +++ b/docsite/src/components/FileExample.tsx @@ -7,6 +7,7 @@ import { Simulate } from "react-dom/test-utils"; import { useTypedLocalStorage } from "./useLocalStorage"; import ButtonGroup from "./ButtonGroup"; import EditorFetch from '@site/src/components/Schema/SchemaEditorFetch'; +import {useWindowSize} from '@docusaurus/theme-common'; export interface FileProps extends Omit { data: string | object @@ -14,6 +15,7 @@ export interface FileProps extends Omit { schemaName?: string interactive?: boolean defaultDisplay?: 'plain' | 'interactive' + readOnlyAtWidth?: number } const FileExample = (props: FileProps) => { @@ -23,14 +25,19 @@ const FileExample = (props: FileProps) => { defaultDisplay = 'interactive', schemaName, filePathName, + readOnlyAtWidth = 1, ...rest } = props; const [fileExampleShow, setFileExampleShow] = useTypedLocalStorage('docusaurus.tab.fileExampleShow', defaultDisplay, false); + const windowSize = useWindowSize({desktopBreakpoint: readOnlyAtWidth}); + let displaySwitch = null; - if (interactive) { + const isInteractive = interactive && windowSize === 'desktop' + + if (isInteractive) { displaySwitch = ( { } let fileNameContent = null; - if(filePathName !== undefined && (!interactive || fileExampleShow === 'interactive')) { + if(filePathName !== undefined && (isInteractive && fileExampleShow === 'interactive')) { fileNameContent = {filePathName} } let header = null; - if(displaySwitch !== null || filePathName !== null) { + if(displaySwitch !== null || fileNameContent !== null) { header = (
{displaySwitch}{fileNameContent} @@ -58,7 +65,7 @@ const FileExample = (props: FileProps) => { } const codeBlockContent = useMemo(() =>{ - if(interactive && fileExampleShow === 'interactive') { + if(isInteractive && fileExampleShow === 'interactive') { return null; } if(typeof data !== 'string') { @@ -69,8 +76,8 @@ const FileExample = (props: FileProps) => { return ( {header} - {!interactive || fileExampleShow === 'plain' ? {codeBlockContent} : null} - {interactive && fileExampleShow === 'interactive' ? : null} + {!isInteractive || fileExampleShow === 'plain' ? {codeBlockContent} : null} + {isInteractive && fileExampleShow === 'interactive' ? : null} ); } diff --git a/docsite/src/components/GenericConfiguration.mdx b/docsite/src/components/GenericConfiguration.mdx index 843146a1..07862d38 100644 --- a/docsite/src/components/GenericConfiguration.mdx +++ b/docsite/src/components/GenericConfiguration.mdx @@ -5,6 +5,7 @@ import ExplorerFetch from '@site/src/components/Schema/ExplorerFetch'; import EditorFetch from '@site/src/components/Schema/SchemaEditorFetch'; import './GenericConfiguration.scss'; import FileConfigExample from './FileConfigExample'; +import {useWindowSize} from '@docusaurus/theme-common'; @@ -26,7 +27,8 @@ import FileConfigExample from './FileConfigExample';
-
+
+
This displays an **example config file** of a [File Configuration](/configuration?configType=aio#configuration-types) that adheres to the shown **Config Structure**. @@ -37,11 +39,20 @@ import FileConfigExample from './FileConfigExample'; After you finish editing, switch to **text** and then copy all text to get a completed config. +
+
+ + This displays an **example config file** of a [File Configuration](/configuration?configType=aio#configuration-types) that adheres to the shown **Config Structure**. + + The example config file editor is meant for a larger screen experience so **only the read-only example is shown.** Please use this site on a tablet/laptop/desktop to enable file editor features. + +
@@ -63,7 +74,8 @@ import FileConfigExample from './FileConfigExample'; -
+
+
This displays an **example config file** of a [all-in-one (`config.json`) configuration](/configuration?configType=aio#configuration-types) that includes a that adheres to the shown **Config Structure**. @@ -74,12 +86,21 @@ import FileConfigExample from './FileConfigExample'; After you finish editing, switch to **text** and then copy all text to get a completed config. +
+
+ + This displays an **example config file** of a [all-in-one (`config.json`) configuration](/configuration?configType=aio#configuration-types) that includes a that adheres to the shown **Config Structure**. + + The example config file editor is meant for a larger screen experience so **only the read-only example is shown.** Please use this site on a tablet/laptop/desktop to enable file editor features. + +
diff --git a/docsite/src/components/GenericConfiguration.scss b/docsite/src/components/GenericConfiguration.scss index 1e76e977..527c9c18 100644 --- a/docsite/src/components/GenericConfiguration.scss +++ b/docsite/src/components/GenericConfiguration.scss @@ -6,6 +6,10 @@ column-gap: 1em; } +.fileEditorMobile { + display: none; +} + @media screen and (max-width: 1378px) { .schemaWrapper { flex-direction: column; @@ -16,4 +20,7 @@ .fileEditor { display: none; } + .fileEditorMobile { + display: block + } } \ No newline at end of file diff --git a/docsite/src/components/Playground.scss b/docsite/src/components/Playground.scss index 729a41db..80236a00 100644 --- a/docsite/src/components/Playground.scss +++ b/docsite/src/components/Playground.scss @@ -6,6 +6,10 @@ column-gap: 1em; } +.fileEditorMobile2 { + display: none; +} + @media screen and (max-width: 1280px) { .schemaWrapper2 { flex-direction: column; @@ -16,4 +20,7 @@ .fileEditor2 { display: none; } + .fileEditorMobile2 { + display: block + } } \ No newline at end of file diff --git a/docsite/src/components/PlaygroundInner.tsx b/docsite/src/components/PlaygroundInner.tsx index 9fafea18..6b879dc4 100644 --- a/docsite/src/components/PlaygroundInner.tsx +++ b/docsite/src/components/PlaygroundInner.tsx @@ -1,6 +1,7 @@ import React, {useEffect, useState} from "react" import BrowserOnly from "@docusaurus/BrowserOnly" -import {useColorMode} from '@docusaurus/theme-common'; +import {useColorMode, useWindowSize} from '@docusaurus/theme-common'; +import CodeBlock from '@theme/CodeBlock'; import Schema from "@site/static/schemas/aio.json"; import ConfigExample from "@site/static/configExample.json"; @@ -33,6 +34,7 @@ function PlaygroundInner(): JSX.Element { // colorModeChoice, // the color mode chosen by the user, can be null // setColorMode, // set the color mode chosen by the user } = useColorMode(); + const windowSize = useWindowSize({desktopBreakpoint: 500}); const [data, setData] = useState({json: ConfigExample }); @@ -45,17 +47,18 @@ function PlaygroundInner(): JSX.Element {

Use this to understand how to write a valid config.

+ name="Todos Model" + schema={Schema} + expanded={false} + hideTopBar={false} + renderRootTreeLines={true} + emptyText="No schema defined" + defaultExpandedDepth={0} + markup + />
-
+
+

This displays an example config file of a all-in-one (config.json) configuration that adheres to the shown Config Structure. @@ -74,15 +77,29 @@ function PlaygroundInner(): JSX.Element {

After you finish editing, switch to text and then copy all text to get a completed config.

- +
+ +

+ This displays an example config file of a all-in-one (config.json) configuration that adheres to the shown Config Structure. +

+

+ The example config file editor is meant for a larger screen experience so only the read-only example is shown. Please use this site on a tablet/laptop/desktop to enable file editor features. +

+
+
+ {windowSize === 'mobile' ? ({JSON.stringify(data, null, 2)}) : ( + - + )}
+ ) }