Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,4 @@ | ||
| .searchContainer { | ||
| display: flex; | ||
| margin: 0 0 0.5rem 0; | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const detailTabs = [ | ||
| { value: false as const, label: 'Errors' }, | ||
armano2 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| { value: 'es' as const, label: 'ESTree' }, | ||
| { value: 'ts' as const, label: 'TypeScript' }, | ||
| { value: 'scope' as const, label: 'Scope' }, | ||
| ]; | ||
| 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; | ||
| } |
| 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 resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| 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; | ||