-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore(website): [playground] add tabs to ast viewer and update design #6735
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
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
.searchContainer { | ||
display: flex; | ||
margin: 0 0 0.5rem 0; | ||
position: sticky; | ||
top: 0; | ||
left: 0; | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,6 @@ | ||
export const detailTabs = [ | ||
{ value: false as const, label: 'Errors' }, | ||
{ value: 'es' as const, label: 'ESTree' }, | ||
{ value: 'ts' as const, label: 'TypeScript' }, | ||
{ value: 'scope' as const, label: 'Scope' }, | ||
]; |
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
30 changes: 30 additions & 0 deletions
30
packages/website/src/components/layout/EditorTabs.module.css
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,30 @@ | ||
.tabContainer { | ||
display: flex; | ||
justify-content: space-between; | ||
background: var(--playground-main-color); | ||
border-bottom: 1px solid var(--ifm-color-emphasis-200); | ||
} | ||
|
||
.tabStyle { | ||
--ifm-button-padding-horizontal: 1rem; | ||
--ifm-button-background-color: var(--ifm-background-surface-color); | ||
--ifm-button-color: var(--ifm-color-emphasis-700); | ||
--ifm-button-border-color: var(--ifm-color-emphasis-200); | ||
|
||
font-size: 0.75rem; | ||
} | ||
|
||
.tabStyle svg { | ||
margin-left: 0.3rem; | ||
} | ||
|
||
.tabStyle:hover { | ||
--ifm-button-background-color: var(--playground-secondary-color); | ||
} | ||
|
||
.tabStyle:disabled { | ||
--ifm-button-background-color: var(--playground-secondary-color); | ||
--ifm-button-color: var(--ifm-color-emphasis-900); | ||
|
||
opacity: 1; | ||
} |
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,55 @@ | ||
import EditIcon from '@site/src/icons/edit.svg'; | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
|
||
import styles from './EditorTabs.module.css'; | ||
|
||
export interface EditorTabsProps<T extends string | boolean> { | ||
readonly tabs: ({ value: T; label: string } | T)[]; | ||
readonly active: T; | ||
readonly showVisualEditor?: boolean; | ||
readonly change: (name: T) => void; | ||
readonly showModal?: (name: T) => void; | ||
armano2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function EditorTabs<T extends string | boolean>({ | ||
tabs, | ||
active, | ||
showVisualEditor, | ||
change, | ||
showModal, | ||
}: EditorTabsProps<T>): JSX.Element { | ||
const tabsWithLabels = tabs.map(tab => | ||
typeof tab !== 'object' ? { value: tab, label: String(tab) } : tab, | ||
); | ||
|
||
return ( | ||
<div className={clsx(styles.tabContainer, 'padding--xs')}> | ||
<div role="tablist" className="button-group"> | ||
{tabsWithLabels.map(item => ( | ||
<button | ||
role="tab" | ||
className={clsx(styles.tabStyle, 'button')} | ||
key={item.label} | ||
aria-selected={active === item.value} | ||
disabled={active === item.value} | ||
onClick={(): void => change(item.value)} | ||
> | ||
{item.label} | ||
</button> | ||
))} | ||
</div> | ||
{showVisualEditor && ( | ||
<button | ||
className={clsx(styles.tabStyle, 'button')} | ||
onClick={(): void => showModal?.(active)} | ||
> | ||
Visual Editor | ||
<EditIcon width={12} height={12} /> | ||
</button> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default EditorTabs; |
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
File renamed without changes.
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.