Skip to content

Commit

Permalink
Make playground responsive layout
Browse files Browse the repository at this point in the history
  • Loading branch information
acomagu committed Apr 13, 2024
1 parent 730587b commit b0b114a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
15 changes: 8 additions & 7 deletions playground/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
AppShell,
Code,
Divider,
Flex,
Group,
Input,
ScrollArea,
Expand All @@ -21,6 +20,7 @@ import '@mantine/core/styles.css';
import { IconBrandGithub, IconMoon, IconSun } from '@tabler/icons-react';
import * as graphql from 'graphql';
import { useState } from "react";
import classes from './Playground.module.css';

const sampleGqlSchema = `
type Query {
Expand Down Expand Up @@ -69,7 +69,7 @@ function Playground() {
const [gqlSchemaStr, setGqlSchemaStr] = useState<string>(sampleGqlSchema);
const [typeName, setTypeName] = useState<string | undefined>('Query');

return <Flex h="100%">
return <div className={classes.playground}>
<Stack h="100%" flex={1}>
<Textarea
flex={1}
Expand All @@ -93,11 +93,12 @@ function Playground() {
></Textarea>
<TypeNameSelect gqlSchemaInput={gqlSchemaStr} value={typeName} onChange={setTypeName} />
</Stack>
<Divider orientation="vertical" ml="lg" mr="lg" />
<Divider orientation="vertical" ml="lg" mr="lg" className={classes['playground-divider-vertical']} />
<Divider orientation="horizontal" mt="lg" mb="lg" className={classes['playground-divider-horizontal']} />
<ScrollArea flex={1}>
<Result gqlSchemaInput={gqlSchemaStr} convertedTypeName={typeName} />
</ScrollArea>
</Flex>;
</div>;
}

function Result(props: { gqlSchemaInput: string, convertedTypeName: string | undefined }) {
Expand Down Expand Up @@ -145,9 +146,9 @@ export function App() {
padding="lg"
>
<AppShell.Header ps="lg" pe="lg">
<Group justify="space-between">
<Title order={1} lh="60px" fw="normal">GraphQL to JSON Schema Playground</Title>
<Group>
<Group justify="space-between" wrap="nowrap">
<Title order={1} lh="60px" fw="normal" style={{ fontSize: 'min(calc(6vw - 10px), var(--mantine-h1-font-size))' }}>GraphQL to JSON Schema Playground</Title>
<Group wrap="nowrap">
<ActionIcon
component="a"
href="https://github.com/acomagu/graphql-to-json-schema"
Expand Down
22 changes: 22 additions & 0 deletions playground/Playground.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.playground {
display: flex;
height: 100%;
}

.playground-divider-horizontal {
display: none;
}

@media (max-width: 30em) {
.playground {
flex-direction: column;
}

.playground-divider-horizontal {
display: block;
}

.playground-divider-vertical {
display: none;
}
}
2 changes: 1 addition & 1 deletion playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@acomagu/graphql-to-json-schema": "^0.0.2",
"@mantine/code-highlight": "^7.7.2",
"@mantine/core": "^7.7.2",
"@mantine/hooks": "^7.8.0",
"@tabler/icons-react": "^3.2.0",
"graphql": "^16.8.1",
"react-dom": "^18.2.0"
Expand Down
1 change: 1 addition & 0 deletions playground/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />

0 comments on commit b0b114a

Please sign in to comment.