Skip to content

Commit

Permalink
Merge pull request #7 from wp-graphql/misc
Browse files Browse the repository at this point in the history
Miscellaneous Changes
  • Loading branch information
josephfusco committed Jan 22, 2024
2 parents 8f188b4 + 6e0f2a1 commit 1b9de29
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useState } from '@wordpress/element';
import { EditorDrawer } from './components/EditorDrawer';
import { Editor } from './components/Editor';

export function App() {
const [ drawerOpen, setDrawerOpen ] = useState( false );

return (
<div className="AppRoot">
<EditorDrawer>
<Editor />
<EditorDrawer open={ drawerOpen } setDrawerOpen={ setDrawerOpen }>
<Editor setDrawerOpen={ setDrawerOpen } />
</EditorDrawer>
</div>
);
Expand Down
16 changes: 12 additions & 4 deletions src/components/Editor.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global WPGRAPHQL_IDE_DATA */
import { GraphiQL } from 'graphiql';

import 'graphiql/graphiql.min.css';

const fetcher = async ( graphQLParams ) => {
Expand All @@ -17,10 +18,17 @@ const fetcher = async ( graphQLParams ) => {
return response.json();
};

export function Editor() {
export function Editor( { setDrawerOpen } ) {
return (
<>
<GraphiQL fetcher={ fetcher } />
</>
<GraphiQL fetcher={ fetcher }>
<GraphiQL.Logo>
<button
className="button EditorDrawerCloseButton"
onClick={ () => setDrawerOpen( false ) }
>
X<span className="screen-reader-text">close drawer</span>
</button>
</GraphiQL.Logo>
</GraphiQL>
);
}
15 changes: 13 additions & 2 deletions src/components/EditorDrawer.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { Drawer as VaulDrawer } from 'vaul';

export function EditorDrawer( { shouldScaleBackground = false, children } ) {
export function EditorDrawer( {
setDrawerOpen,
open = false,
shouldScaleBackground = false,
children,
} ) {
const buttonLabel = 'GraphQL IDE';

return (
<div className="EditorDrawerRoot">
<VaulDrawer.Root shouldScaleBackground={ shouldScaleBackground }>
<VaulDrawer.Root
dismissible={ false }
closeThreshold={ 1 }
shouldScaleBackground={ shouldScaleBackground }
open={ open }
onOpenChange={ setDrawerOpen }
>
<VaulDrawer.Trigger className="EditorDrawerButton">
<span className="ab-icon" aria-hidden="true"></span>
{ buttonLabel }
Expand Down

0 comments on commit 1b9de29

Please sign in to comment.