Skip to content

Commit 98e1415

Browse files
show filled docs icon when docs are visible (#2739)
1 parent 33bef17 commit 98e1415

5 files changed

Lines changed: 22 additions & 2 deletions

File tree

.changeset/grumpy-dogs-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphiql/react': minor
3+
---
4+
5+
Add `DocsFilledIcon` component and use show that icon in the sidebar when the docs plugin is visible
Lines changed: 5 additions & 0 deletions
Loading

packages/graphiql-react/src/icons/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import _DeprecatedArgumentIcon from './deprecated-argument.svg';
88
import _DeprecatedEnumValueIcon from './deprecated-enum-value.svg';
99
import _DeprecatedFieldIcon from './deprecated-field.svg';
1010
import _DirectiveIcon from './directive.svg';
11+
import _DocsFilledIcon from './docs-filled.svg';
1112
import _DocsIcon from './docs.svg';
1213
import _EnumValueIcon from './enum-value.svg';
1314
import _FieldIcon from './field.svg';
@@ -53,6 +54,7 @@ export const DeprecatedFieldIcon = generateIcon(
5354
'deprecated field icon',
5455
);
5556
export const DirectiveIcon = generateIcon(_DirectiveIcon, 'directive icon');
57+
export const DocsFilledIcon = generateIcon(_DocsFilledIcon, 'filled docs icon');
5658
export const DocsIcon = generateIcon(_DocsIcon, 'docs icon');
5759
export const EnumValueIcon = generateIcon(_EnumValueIcon, 'enum value icon');
5860
export const FieldIcon = generateIcon(_FieldIcon, 'field icon');

packages/graphiql-react/src/plugin.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from 'react';
99
import { DocExplorer, useExplorerContext } from './explorer';
1010
import { History, useHistoryContext } from './history';
11-
import { DocsIcon, HistoryIcon } from './icons';
11+
import { DocsFilledIcon, DocsIcon, HistoryIcon } from './icons';
1212
import { useStorageContext } from './storage';
1313
import { createContextHook, createNullableContext } from './utility/context';
1414

@@ -31,7 +31,14 @@ export type GraphiQLPlugin = {
3131

3232
export const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {
3333
title: 'Documentation Explorer',
34-
icon: DocsIcon,
34+
icon: function Icon() {
35+
const pluginContext = usePluginContext();
36+
return pluginContext?.visiblePlugin === DOC_EXPLORER_PLUGIN ? (
37+
<DocsFilledIcon />
38+
) : (
39+
<DocsIcon />
40+
);
41+
},
3542
content: DocExplorer,
3643
};
3744
export const HISTORY_PLUGIN: GraphiQLPlugin = {

packages/graphiql/__mocks__/@graphiql/react.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export {
3131
DirectiveIcon,
3232
DOC_EXPLORER_PLUGIN,
3333
DocExplorer,
34+
DocsFilledIcon,
3435
DocsIcon,
3536
EditorContext,
3637
EditorContextProvider,

0 commit comments

Comments
 (0)