Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
armano2 merged 2 commits intov6fromchore/website-editor-tabs
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletionspackages/website/src/components/ESQueryFilter.module.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
.searchContainer {
display: flex;
margin: 0 0 0.5rem 0;
position: sticky;
top: 0;
left: 0;
}
46 changes: 0 additions & 46 deletionspackages/website/src/components/EditorTabs.tsx
View file
Open in desktop

This file was deleted.

16 changes: 0 additions & 16 deletionspackages/website/src/components/OptionsSelector.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,13 +22,6 @@ export interface OptionsSelectorParams {
readonly isLoading: boolean;
}

const ASTOptions = [
{ value: false, label: 'Disabled' },
{ value: 'es', label: 'ESTree' },
{ value: 'ts', label: 'TypeScript' },
{ value: 'scope', label: 'Scope' },
] as const;

function OptionsSelectorContent({
state,
setState,
Expand DownExpand Up@@ -109,15 +102,6 @@ function OptionsSelectorContent({
className={styles.optionCheckbox}
/>
</label>
<label className={styles.optionLabel}>
AST Viewer
<Dropdown
name="showAST"
value={state.showAST}
onChange={(e): void => setState({ showAST: e })}
options={ASTOptions}
/>
</label>
<label className={styles.optionLabel}>
Source type
<Dropdown
Expand Down
32 changes: 5 additions & 27 deletionspackages/website/src/components/Playground.module.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,39 +45,17 @@
z-index: calc(var(--ifm-z-index-fixed) - 1);
}

.tabContainer {
display: flex;
justify-content: space-between;
background: var(--playground-main-color);
border-bottom: 1px solid var(--playground-secondary-color);
.playgroundInfoHeader {
position: sticky;
top: 0;
left: 0;
z-index: 1;
}

.tabCode {
height: calc(100% - 32px);
}

.tabStyle {
border: none;
border-right: 1px solid var(--playground-secondary-color);
background: var(--playground-main-color);
color: var(--ifm-color-emphasis-700);
padding: 0.5rem 1rem;
cursor: pointer;
}

.tabStyle svg {
margin-left: 0.3rem;
}

.tabStyle:hover {
background: var(--playground-secondary-color);
}

.tabStyle:disabled {
background: var(--playground-secondary-color);
color: var(--ifm-color-emphasis-900);
}

@media only screen and (max-width: 996px) {
.codeContainer {
display: block;
Expand Down
39 changes: 23 additions & 16 deletionspackages/website/src/components/Playground.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
import ASTViewerScope from '@site/src/components/ASTViewerScope';
import ConfigEslint from '@site/src/components/config/ConfigEslint';
import ConfigTypeScript from '@site/src/components/config/ConfigTypeScript';
import {
defaultEslintConfig,
defaultTsConfig,
} from '@site/src/components/config/utils';
import EditorTabs from '@site/src/components/EditorTabs';
import { ErrorsViewer, ErrorViewer } from '@site/src/components/ErrorsViewer';
import { ESQueryFilter } from '@site/src/components/ESQueryFilter';
import type { TSESTree } from '@typescript-eslint/utils';
import clsx from 'clsx';
import type * as ESQuery from 'esquery';
Expand All@@ -17,10 +7,18 @@ import type { SourceFile } from 'typescript';

import { useMediaQuery } from '../hooks/useMediaQuery';
import ASTViewerESTree from './ASTViewerESTree';
import ASTViewerScope from './ASTViewerScope';
import ASTViewerTS from './ASTViewerTS';
import { detailTabs } from './config';
import ConfigEslint from './config/ConfigEslint';
import ConfigTypeScript from './config/ConfigTypeScript';
import { defaultEslintConfig, defaultTsConfig } from './config/utils';
import { EditorEmbed } from './editor/EditorEmbed';
import { LoadingEditor } from './editor/LoadingEditor';
import { ErrorsViewer, ErrorViewer } from './ErrorsViewer';
import { ESQueryFilter } from './ESQueryFilter';
import useHashState from './hooks/useHashState';
import EditorTabs from './layout/EditorTabs';
import Loader from './layout/Loader';
import { shallowEqual } from './lib/shallowEqual';
import OptionsSelector from './OptionsSelector';
Expand DownExpand Up@@ -138,8 +136,9 @@ function Playground(): JSX.Element {
{isLoading && <Loader />}
<EditorTabs
tabs={['code', 'tsconfig', 'eslintrc']}
activeTab={activeTab}
active={activeTab}
change={setTab}
showVisualEditor={activeTab !== 'code'}
showModal={(): void => setShowModal(activeTab)}
/>
<div className={styles.tabCode}>
Expand All@@ -165,12 +164,20 @@ function Playground(): JSX.Element {
/>
</div>
<div className={styles.astViewer}>
{state.showAST === 'es' && (
<ESQueryFilter
onChange={setEsQueryFilter}
onError={setEsQueryError}
<div className={styles.playgroundInfoHeader}>
<EditorTabs
tabs={detailTabs}
active={state.showAST ?? false}
change={(v): void => setState({ showAST: v })}
/>
)}
{state.showAST === 'es' && (
<ESQueryFilter
onChange={setEsQueryFilter}
onError={setEsQueryError}
/>
)}
</div>

{(state.showAST === 'ts' && tsAst && (
<ASTViewerTS
value={tsAst}
Expand Down
6 changes: 6 additions & 0 deletionspackages/website/src/components/config.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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' },
];
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import Dropdown from '@site/src/components/inputs/Dropdown';
import Modal from '@site/src/components/modals/Modal';
import Modal from '@site/src/components/layout/Modal';
import clsx from 'clsx';
import React, { useCallback, useEffect, useReducer, useState } from 'react';

Expand Down
30 changes: 30 additions & 0 deletionspackages/website/src/components/layout/EditorTabs.module.css
View file
Open in desktop
Original file line numberDiff line numberDiff 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;
}
55 changes: 55 additions & 0 deletionspackages/website/src/components/layout/EditorTabs.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
.modal {
display: none;
position: fixed;
z-index:1;
z-index:2;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color:rgba(0, 0, 0, 0.4);
background-color:rgb(0 0 0 / 40%);
}

.modal.open {
Expand All@@ -32,6 +32,7 @@
top: -30rem;
opacity: 0;
}

to {
top: 0;
opacity: 1;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp