Skip to content

chore(website): [playground] move config panel to secondary menu #5131

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 4 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 19 additions & 1 deletion packages/website/src/components/OptionsSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import React, { useCallback } from 'react';

import {
NavbarSecondaryMenuFiller,
useWindowSize,
} from '@docusaurus/theme-common';

import Expander from './layout/Expander';
import Dropdown from './inputs/Dropdown';
import Checkbox from './inputs/Checkbox';
Expand Down Expand Up @@ -29,7 +34,7 @@ const ASTOptions = [
{ value: 'scope', label: 'Scope' },
] as const;

function OptionsSelector({
function OptionsSelectorContent({
state,
setState,
tsVersions,
Expand Down Expand Up @@ -154,4 +159,17 @@ function OptionsSelector({
);
}

function OptionsSelector(props: OptionsSelectorParams): JSX.Element {
const windowSize = useWindowSize();
if (windowSize === 'mobile') {
return (
<NavbarSecondaryMenuFiller
component={OptionsSelectorContent}
props={props}
/>
);
}
return <OptionsSelectorContent {...props} />;
}

export default OptionsSelector;
2 changes: 1 addition & 1 deletion packages/website/src/components/Playground.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}

.options {
width: 100%;
display: none;
}

.tabCode {
Expand Down
6 changes: 3 additions & 3 deletions packages/website/src/components/layout/Expander.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@

.arrow {
margin: 0 0.5rem 0 0;
transform: rotateZ(-90deg);
transform: rotateZ(0deg);
transition: transform 250ms ease-in-out;
width: 1rem;
height: 1rem;
}

.expandedArrow {
transform: rotateZ(0deg);
.arrow.expandedArrow {
transform: rotateZ(90deg);
}

.children {
Expand Down
24 changes: 12 additions & 12 deletions packages/website/src/components/layout/Expander.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { useState } from 'react';
import React from 'react';
import clsx from 'clsx';
import { useCollapsible, Collapsible } from '@docusaurus/theme-common';
import styles from './Expander.module.css';

import ArrowIcon from '@site/src/icons/arrow.svg';
Expand All @@ -10,23 +12,21 @@ export interface ExpanderProps {
}

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

const handleToggle = (): void => {
setIsExpanded(!isExpanded);
};
const { collapsed, toggleCollapsed } = useCollapsible({
initialState: false,
});

return (
<div className={`${styles.expander} ${props.className ?? ''}`}>
<button className={styles.heading} onClick={handleToggle}>
<div className={clsx(styles.expander, props.className)}>
<button className={styles.heading} onClick={toggleCollapsed}>
<ArrowIcon
className={`${styles.arrow} ${
isExpanded ? styles.expandedArrow : ''
}`}
className={clsx(styles.arrow, !collapsed && styles.expandedArrow)}
/>
<span className={styles.headerLabel}>{props.label}</span>
</button>
{isExpanded && <div className={styles.children}>{props.children}</div>}
<Collapsible lazy={false} as="div" collapsed={collapsed}>
<div className={styles.children}>{props.children}</div>
</Collapsible>
</div>
);
}
Expand Down