Skip to content
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

chore(website): add playground to website #4108

Merged
merged 50 commits into from Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8d960ad
chore(website): migrate playground from #3147
armano2 Nov 8, 2021
c09021e
Merge branch 'master' into website-playground
armano2 Nov 8, 2021
09613a1
chore(website): playground compilation fix, not fully working
armano2 Nov 9, 2021
a121f03
docs: allow playground to be executed
armano2 Nov 11, 2021
5961541
docs: fix circular modules
armano2 Nov 11, 2021
bc4f486
Merge branch 'master' into website-playground
armano2 Nov 11, 2021
40c5e38
docs(website): regenerate vendors
armano2 Nov 11, 2021
6b70c80
Merge branch 'master' into website-playground
armano2 Nov 11, 2021
bf5870d
Merge remote-tracking branch 'origin/master' into website-playground
armano2 Nov 15, 2021
92a235a
Merge remote-tracking branch 'armano2/master' into website-playground
armano2 Nov 15, 2021
4339a46
fix: update playground
armano2 Nov 15, 2021
fc36401
fix: expose linter types from website-eslint
armano2 Nov 16, 2021
0f7439f
fix(website): add extended eslint config editor
armano2 Nov 18, 2021
fef660f
Merge remote-tracking branch 'origin/master' into website-playground
armano2 Nov 18, 2021
d5dc0c6
fix(website): enable default focus on search input
armano2 Nov 18, 2021
e58eefc
refactor(website): refactor codebase
armano2 Nov 18, 2021
d9c277e
refactor(website): mark all props as readonly
armano2 Nov 18, 2021
368b0bf
refactor(website): migrate config code to use reducers
armano2 Nov 18, 2021
9e5f387
refactor(website): ensure correct focus for textarea
armano2 Nov 18, 2021
80a5a3f
refactor(website): update useHashState
armano2 Nov 18, 2021
60d617c
refactor(website): add missing error handling
armano2 Nov 18, 2021
193dec5
refactor(website): add basic tsconfig edit
armano2 Nov 18, 2021
697d811
refactor(website): simplify components
armano2 Nov 18, 2021
0e1f198
refactor(website): add basic config validation
armano2 Nov 19, 2021
86af1b9
refactor(website): refactor config editors
armano2 Nov 19, 2021
d8bc68c
refactor(website): get all registered rules instead of only from esli…
armano2 Nov 19, 2021
b9c0fd2
fix: correct invalid header in modals
armano2 Nov 19, 2021
023400e
Merge remote-tracking branch 'origin/main' into website-playground
armano2 Nov 20, 2021
0af7777
chore(website): add actions to playground
armano2 Nov 20, 2021
a1a1114
chore(website): fix issue with isLoading
armano2 Nov 20, 2021
171087b
chore(website): final code cleanup
armano2 Nov 20, 2021
c549ca8
Merge remote-tracking branch 'origin/main' into website-playground
armano2 Nov 20, 2021
a3b4f40
chore(website): simplify code of editor
armano2 Nov 21, 2021
d636bb0
chore(website): use BrowserOnly component to load playground
armano2 Nov 21, 2021
c466baf
chore(website): apply first part of changes requested in code review
armano2 Nov 21, 2021
62d12c1
chore(website): refactor editor to use composite api
armano2 Nov 21, 2021
4aeee36
chore(website): improve playground position, and scrolling of options
armano2 Nov 21, 2021
5b13139
chore(website): correct issue with changing typescript version
armano2 Nov 22, 2021
30ff108
Merge branch 'main' into pr/armano2/4108
bradzacher Nov 24, 2021
ef239bf
docs(website): refactor ast viewer
armano2 Nov 26, 2021
0d5ca6c
Merge remote-tracking branch 'origin/main' into website-playground
armano2 Nov 26, 2021
dd3385d
chore(website): fix reverse hovering error
armano2 Nov 26, 2021
37414ab
chore(website): correct z-index of playground and allow hints to be seen
armano2 Nov 27, 2021
4f8702b
Merge remote-tracking branch 'origin/main' into website-playground
armano2 Nov 29, 2021
d0c2fb6
chore(website-eslint): add missing comments
armano2 Nov 29, 2021
3472b61
chore(website-eslint): correct some of linting errors
armano2 Nov 29, 2021
1996667
chore: disable spelling check for vendor
armano2 Nov 29, 2021
f9baefe
chore: xposed -> exposed
armano2 Nov 29, 2021
403fceb
fix: add missing dev deps for website-eslint
armano2 Nov 29, 2021
e66e0a0
fix: revert unnecessary changes and add missing command
armano2 Nov 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/website/.eslintrc.js
Expand Up @@ -8,7 +8,11 @@ module.exports = {
plugins: ['jsx-a11y', 'react', 'react-hooks'],
overrides: [
{
files: ['./src/pages/*.tsx'],
files: [
'./src/pages/*.tsx',
'./src/components/**/*.tsx',
'./src/components/hooks/*.ts',
],
rules: {
'import/no-default-export': 'off',
},
Expand All @@ -17,7 +21,8 @@ module.exports = {
rules: {
'react/jsx-no-target-blank': 'off',
'react/no-unescaped-entities': 'off',
'react-hooks/exhaustive-deps': 'error',
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
armano2 marked this conversation as resolved.
Show resolved Hide resolved
'react-hooks/exhaustive-deps': 'off', // TODO: enable it later
armano2 marked this conversation as resolved.
Show resolved Hide resolved
},
settings: {
react: {
Expand Down
5 changes: 5 additions & 0 deletions packages/website/src/components/OptionsSelector.module.css
Expand Up @@ -16,6 +16,11 @@
color var(--ifm-transition-fast) var(--ifm-transition-timing-default);
color: var(--ifm-font-color-secondary);
justify-content: space-between;
border: none;
background: transparent;
font-family: var(--ifm-font-family-base);
box-sizing: border-box;
line-height: var(--ifm-line-height-base);
}

.optionLabel:hover {
Expand Down
26 changes: 15 additions & 11 deletions packages/website/src/components/OptionsSelector.tsx
@@ -1,3 +1,4 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React, { useCallback, useState } from 'react';

import ConfigEslint from './config/ConfigEslint';
Expand All @@ -22,7 +23,7 @@ import type {
RulesRecord,
} from './types';

interface OptionsSelectorParams {
export interface OptionsSelectorParams {
readonly ruleOptions: RuleDetails[];
readonly state: ConfigModel;
readonly setState: (cfg: Partial<ConfigModel>) => void;
Expand Down Expand Up @@ -148,38 +149,41 @@ function OptionsSelector({
options={['script', 'module']}
/>
</label>
<label
<button
className={styles.optionLabel}
onClick={(): void => setEslintModal(true)}
>
Eslint Config
<EditIcon className={styles.clickableIcon} />
</label>
<label
</button>
<button
className={styles.optionLabel}
onClick={(): void => setTypeScriptModal(true)}
>
TypeScript Config
<EditIcon className={styles.clickableIcon} />
</label>
</button>
</Expander>
<Expander label="Actions">
<label className={styles.optionLabel} onClick={copyLinkToClipboard}>
<button className={styles.optionLabel} onClick={copyLinkToClipboard}>
Copy Link
<Tooltip open={copyLink} text="Copied" close={setCopyLink}>
<CopyIcon className={styles.clickableIcon} />
</Tooltip>
</label>
<label className={styles.optionLabel} onClick={copyMarkdownToClipboard}>
</button>
<button
className={styles.optionLabel}
onClick={copyMarkdownToClipboard}
>
Copy Markdown
<Tooltip open={copyMarkdown} text="Copied" close={setCopyMarkdown}>
<CopyIcon className={styles.clickableIcon} />
</Tooltip>
</label>
<label className={styles.optionLabel} onClick={openIssue}>
</button>
<button className={styles.optionLabel} onClick={openIssue}>
Report Issue
<CopyIcon className={styles.clickableIcon} />
</label>
</button>
</Expander>
</>
);
Expand Down
1 change: 1 addition & 0 deletions packages/website/src/components/ast/PropertyName.tsx
Expand Up @@ -9,6 +9,7 @@ export default function PropertyName(props: {
onMouseEnter?: (e: SyntheticEvent) => void;
}): JSX.Element {
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
<span onClick={props.onClick} onMouseEnter={props.onMouseEnter}>
{props.propName && (
<span className={clsx(styles.propName, styles.clickable)}>
Expand Down
1 change: 1 addition & 0 deletions packages/website/src/components/config/ConfigEditor.tsx
Expand Up @@ -87,6 +87,7 @@ function reducerObject(
}
}
} catch {
// eslint-disable-next-line no-console
console.error('ERROR parsing json');
}
return state;
Expand Down
3 changes: 3 additions & 0 deletions packages/website/src/components/editor/LoadedEditor.tsx
Expand Up @@ -37,6 +37,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({

useEffect(
debounce(() => {
// eslint-disable-next-line no-console
console.info('[Editor] linting triggered');
const [markers, fatalMessage, codeActions] = lintCode(
webLinter,
Expand Down Expand Up @@ -78,6 +79,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
debounce(() => {
const position = sandboxInstance.editor.getPosition();
if (position) {
// eslint-disable-next-line no-console
console.info('[Editor] updating cursor', position);
onSelect(position);
}
Expand Down Expand Up @@ -118,6 +120,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
if (modelValue === code) {
return;
}
// eslint-disable-next-line no-console
console.info('[Editor] updating editor model');
sandboxInstance.editor.executeEdits(modelValue, [
{
Expand Down
4 changes: 4 additions & 0 deletions packages/website/src/components/hooks/useHashState.ts
Expand Up @@ -45,6 +45,7 @@ const parseStateFromUrl = (hash: string): ConfigModel | undefined => {
: undefined,
};
} catch (e) {
// eslint-disable-next-line no-console
console.warn(e);
}
return undefined;
Expand All @@ -69,6 +70,7 @@ const writeStateToUrl = (newState: ConfigModel): string => {
.map(item => `${encodeURIComponent(item[0])}=${item[1]}`)
.join('&');
} catch (e) {
// eslint-disable-next-line no-console
console.warn(e);
}
return '';
Expand Down Expand Up @@ -141,6 +143,7 @@ function useHashState(

const onHashChange = (): void => {
const newHash = window.location.hash;
// eslint-disable-next-line no-console
console.info('[State] hash change detected', newHash);
setHash(newHash);
};
Expand All @@ -153,6 +156,7 @@ function useHashState(
}, []);
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved

const _setState = useCallback((cfg: Partial<ConfigModel>) => {
// eslint-disable-next-line no-console
console.info('[State] updating config diff', cfg);
setTmpState(cfg);
}, []);
Expand Down
1 change: 1 addition & 0 deletions packages/website/src/components/inputs/Text.tsx
Expand Up @@ -8,6 +8,7 @@ export interface DropdownProps {
readonly type?: 'text' | 'search';
}

// eslint-disable-next-line react/display-name
const Text = React.forwardRef((props: DropdownProps, ref): JSX.Element => {
return (
<input
Expand Down
4 changes: 2 additions & 2 deletions packages/website/src/components/inputs/Tooltip.tsx
Expand Up @@ -2,14 +2,14 @@ import React, { useEffect } from 'react';
import styles from './Tooltip.module.css';
import clsx from 'clsx';

export interface CopyProps {
export interface TooltipProps {
readonly children: JSX.Element | (JSX.Element | false)[];
readonly text: string;
readonly open?: boolean;
readonly close: (status: boolean) => void;
}

function Tooltip(props: CopyProps): JSX.Element {
function Tooltip(props: TooltipProps): JSX.Element {
useEffect(() => {
if (props.open) {
setTimeout(() => {
Expand Down
8 changes: 5 additions & 3 deletions packages/website/src/components/layout/Expander.tsx
Expand Up @@ -3,16 +3,16 @@ import styles from './Expander.module.css';

import ArrowIcon from '../icons/ArrowIcon';

interface MyProps {
export interface ExpanderProps {
readonly children?: React.ReactNode;
readonly className?: string;
readonly label: string;
}

export default function Expander(props: MyProps): JSX.Element {
function Expander(props: ExpanderProps): JSX.Element {
const [isExpanded, setIsExpanded] = useState<boolean>(true);

const handleToggle = () => {
const handleToggle = (): void => {
setIsExpanded(!isExpanded);
};

Expand All @@ -31,3 +31,5 @@ export default function Expander(props: MyProps): JSX.Element {
</div>
);
}

export default Expander;
1 change: 1 addition & 0 deletions packages/website/src/components/modals/Modal.tsx
@@ -1,3 +1,4 @@
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */
import React from 'react';
import clsx from 'clsx';
import styles from './Modal.module.css';
Expand Down