Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): [playground] add tabs to ast viewer and update design (…
- Loading branch information
Showing
11 changed files
with
123 additions
and
111 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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; | ||
} | ||
|
||
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 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.