-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore(website): update config editor and add tabs to playground #5088
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3462032
chore(website): fix issues with ts < 4.0.5, in case of fatal parsing …
armano2 a672e6c
fix: ensure all libs are loaded correctly for all ts targets
armano2 146994b
chore(website): remove unused LintMessage map from sandboxServices
armano2 4326f73
Merge remote-tracking branch 'origin/main' into fix/fallback-errors-t…
armano2 d6fd7b5
chore(website): do not report errors for imported dynamic libraries
armano2 e031ecd
chore(website): use sandbox for config editing
armano2 3354fe9
chore(website): remove json editor from modal
armano2 ffae163
chore(website): add basic styles to editor tabs
armano2 b015c79
chore(website): move visual editor to right side of tabs
armano2 b3b22e7
chore(website): add supper basic display fo mobile views
armano2 e527453
chore(website): deduplicate code and ensure that config provided by u…
armano2 14c6415
chore(website): do not warn of additionalProperties and minor adjustm…
armano2 b51b6b6
chore(website): refine config editor
armano2 3e48bc1
chore(website): drop no longer used jsonField property
armano2 c6363a5
Merge remote-tracking branch 'origin/main' into feat/poc-playground-tabs
armano2 2441068
fix: apply changes from code review
armano2 27e4a64
fix: correct regression with recursive elements
armano2 3d2d1f3
Merge remote-tracking branch 'origin/main' into feat/poc-playground-tabs
armano2 1b8d493
fix: add missing role tablist and role tab
armano2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React, { useMemo } from 'react'; | ||
|
||
import ASTViewer from './ast/ASTViewer'; | ||
import type { ASTViewerBaseProps, ASTViewerModelMap } from './ast/types'; | ||
import type { ASTViewerBaseProps } from './ast/types'; | ||
|
||
import { serialize } from './ast/serializer/serializer'; | ||
import { createScopeSerializer } from './ast/serializer/serializerScope'; | ||
|
||
export interface ASTScopeViewerProps extends ASTViewerBaseProps { | ||
readonly value: Record<string, unknown> | string; | ||
readonly value: Record<string, unknown>; | ||
} | ||
|
||
export default function ASTViewerScope({ | ||
value, | ||
onSelectNode, | ||
}: ASTScopeViewerProps): JSX.Element { | ||
const [model, setModel] = useState<string | ASTViewerModelMap>(''); | ||
|
||
useEffect(() => { | ||
if (typeof value === 'string') { | ||
setModel(value); | ||
} else { | ||
const scopeSerializer = createScopeSerializer(); | ||
setModel(serialize(value, scopeSerializer)); | ||
} | ||
}, [value]); | ||
const model = useMemo( | ||
() => serialize(value, createScopeSerializer()), | ||
[value], | ||
); | ||
|
||
return <ASTViewer value={model} onSelectNode={onSelectNode} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import type { TabType } from './types'; | ||
import styles from './Playground.module.css'; | ||
import EditIcon from '@site/src/icons/edit.svg'; | ||
|
||
export interface FileTabsProps { | ||
readonly tabs: TabType[]; | ||
readonly activeTab: TabType; | ||
readonly change: (tab: TabType) => void; | ||
readonly showModal: () => void; | ||
} | ||
|
||
export default function EditorTabs({ | ||
tabs, | ||
activeTab, | ||
change, | ||
showModal, | ||
}: FileTabsProps): JSX.Element { | ||
return ( | ||
<div className={styles.tabContainer}> | ||
<div role="tablist"> | ||
{tabs.map(item => { | ||
return ( | ||
<button | ||
role="tab" | ||
className={styles.tabStyle} | ||
key={item} | ||
aria-selected={activeTab === item} | ||
disabled={activeTab === item} | ||
onClick={(): void => change(item)} | ||
> | ||
{item} | ||
</button> | ||
); | ||
})} | ||
</div> | ||
{activeTab !== 'code' && ( | ||
<button className={styles.tabStyle} onClick={showModal}> | ||
Visual Editor | ||
<EditIcon width={12} height={12} /> | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.