Add docs close button

This commit is contained in:
Gregory Schier
2025-07-07 13:59:06 -07:00
parent 7a11da42af
commit f5dbff4682

View File

@@ -15,8 +15,10 @@ import {
} from 'graphql'; } from 'graphql';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { ReactNode, useState } from 'react'; import { ReactNode, useState } from 'react';
import { graphqlSchemaAtom } from '../atoms/graphqlSchemaAtom'; import { graphqlDocStateAtom, graphqlSchemaAtom } from '../atoms/graphqlSchemaAtom';
import { jotaiStore } from '../lib/jotai';
import { Icon } from './core/Icon'; import { Icon } from './core/Icon';
import { IconButton } from './core/IconButton';
import { Markdown } from './Markdown'; import { Markdown } from './Markdown';
type ExplorerItem = type ExplorerItem =
@@ -43,7 +45,16 @@ export function GraphQLDocsExplorer() {
const allTypes = graphqlSchema.getTypeMap(); const allTypes = graphqlSchema.getTypeMap();
return ( return (
<div> <div className="relative w-full">
<IconButton
icon="x"
size="sm"
className="!absolute right-2 top-0"
title="Close documenation explorer"
onClick={() => {
jotaiStore.set(graphqlDocStateAtom, false);
}}
/>
{activeItem == null ? ( {activeItem == null ? (
<div className="flex flex-col gap-3 overflow-auto h-full"> <div className="flex flex-col gap-3 overflow-auto h-full">
<Heading>Root Types</Heading> <Heading>Root Types</Heading>
@@ -72,6 +83,7 @@ export function GraphQLDocsExplorer() {
const t = allTypes[typeName]!; const t = allTypes[typeName]!;
return ( return (
<GqlTypeLink <GqlTypeLink
key={t.name}
color="notice" color="notice"
item={{ kind: 'type', type: t, from: null }} item={{ kind: 'type', type: t, from: null }}
setItem={setActiveItem} setItem={setActiveItem}