Skip to content

Commit

Permalink
[feat] disable strict mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
LeahHirst committed Nov 17, 2024
1 parent 14236e0 commit 511bf2b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
19 changes: 17 additions & 2 deletions apps/site/src/components/playground/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,29 @@ export const DropdownAction = styled.button`
export type DropdownProps = {
label: string;
children: React.ReactNode;
open?: boolean;
onTriggerClick?: () => void;
};

export default function Dropdown({ label, children }: DropdownProps) {
export default function Dropdown({
label,
children,
open,
onTriggerClick,
}: DropdownProps) {
const [show, setShow] = useState(false);

return (
<div>
<Button onClick={() => setShow(!show)}>
<Button
onClick={() => {
if (open !== undefined) {
setShow(!show);
} else {
onTriggerClick?.();
}
}}
>
{label}
<Chevron direction={show ? 'up' : 'down'} />
</Button>
Expand Down
8 changes: 7 additions & 1 deletion apps/site/src/components/playground/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ export default function Header() {
};
}, [share]);

const [examplesOpen, setExamplesOpen] = useState(false);

return (
<Base>
<Flex>
<H1>Playground</H1>
<Dropdown label="Examples">
<Dropdown
open={examplesOpen}
onTriggerClick={() => setExamplesOpen((v) => !v)}
label="Examples"
>
<DropdownAction>Hello world</DropdownAction>
<DropdownAction>Hello types</DropdownAction>
</Dropdown>
Expand Down
4 changes: 2 additions & 2 deletions apps/site/src/components/playground/PlaygroundContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PlaygroundContext = createContext<PlaygroundContextType>({
run: () => {},
share: () => {},
getTypegraphUrl: () => undefined,
strict: true,
strict: false,
setStrict: () => {},
});

Expand All @@ -55,7 +55,7 @@ export const PlaygroundContextProvider = ({
const [programInput, setProgramInput] = useState(input);
const [programOutput, setProgramOutput] = useState('');
const [compilerOutput, setCompilerOutput] = useState<CompilerMessage[]>([]);
const [strict, setStrict] = useState(true);
const [strict, setStrict] = useState(false);

const monaco = useMonaco();

Expand Down

0 comments on commit 511bf2b

Please sign in to comment.