Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[redesign] implement sidebar #2543

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/graphiql-react/src/icons/docs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/graphiql-react/src/icons/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions packages/graphiql-react/src/icons/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import _ChevronDownIcon from './chevron-down.svg';
import _ChevronUpIcon from './chevron-up.svg';
import _CopyIcon from './copy.svg';
import _DocsIcon from './docs.svg';
import _HistoryIcon from './history.svg';
import _KeyboardShortcutIcon from './keyboard-shortcut.svg';
import _MergeIcon from './merge.svg';
import _PlayIcon from './play.svg';
import _PrettifyIcon from './prettify.svg';
import _SettingsIcon from './settings.svg';
import _StopIcon from './stop.svg';

export const ChevronDownIcon = generateIcon(
Expand All @@ -12,9 +16,16 @@ export const ChevronDownIcon = generateIcon(
);
export const ChevronUpIcon = generateIcon(_ChevronUpIcon, 'chevron up icon');
export const CopyIcon = generateIcon(_CopyIcon, 'copy icon');
export const DocsIcon = generateIcon(_DocsIcon, 'docs icon');
export const HistoryIcon = generateIcon(_HistoryIcon, 'history icon');
export const KeyboardShortcutIcon = generateIcon(
_KeyboardShortcutIcon,
'keyboard shortcut icon',
);
export const MergeIcon = generateIcon(_MergeIcon, 'merge icon');
export const PlayIcon = generateIcon(_PlayIcon, 'play icon');
export const PrettifyIcon = generateIcon(_PrettifyIcon, 'prettify icon');
export const SettingsIcon = generateIcon(_SettingsIcon, 'settings icon');
export const StopIcon = generateIcon(_StopIcon, 'stop icon');

function generateIcon(RawComponent: any, title: string) {
Expand Down
7 changes: 7 additions & 0 deletions packages/graphiql-react/src/icons/keyboard-shortcut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/graphiql-react/src/icons/settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/graphiql-react/src/style/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@
0px 0.399006px 1.33002px rgba(59, 76, 106, 0.0525061);

/* Layout */
--sidebar-width: 44px;
--toolbar-width: 40px;
}

.graphiql-container,
.CodeMirror-info,
.CodeMirror-lint-tooltip,
.graphiql-container button {
color: var(--color-neutral-100);
font-family: var(--font-family);
font-size: var(--font-size-body);
font-weight: var(----font-weight-regular);
Expand Down
8 changes: 2 additions & 6 deletions packages/graphiql-react/src/utility/resize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,8 @@ export function useDragResize({

if (firstRef.current && storage && storageKey) {
const storedValue = storage?.get(storageKey);
if (
storedValue &&
storedValue !== HIDE_FIRST &&
storedValue !== HIDE_SECOND
) {
firstRef.current.style.flex = storedValue;
if (storedValue !== HIDE_FIRST && storedValue !== HIDE_SECOND) {
firstRef.current.style.flex = storedValue || defaultFlexRef.current;
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions packages/graphiql/__mocks__/@graphiql/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export {
ChevronDownIcon,
ChevronUpIcon,
CopyIcon,
DocsIcon,
Dropdown,
EditorContext,
EditorContextProvider,
Expand All @@ -25,13 +26,16 @@ export {
ExplorerContextProvider,
HistoryContext,
HistoryContextProvider,
HistoryIcon,
ImagePreview,
KeyboardShortcutIcon,
onHasCompletion,
MergeIcon,
PlayIcon,
PrettifyIcon,
SchemaContext,
SchemaContextProvider,
SettingsIcon,
StopIcon,
StorageContext,
StorageContextProvider,
Expand Down
8 changes: 4 additions & 4 deletions packages/graphiql/cypress/integration/docs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('GraphiQL DocExplorer - button', () => {
cy.visit(`/`);
});
it('Toggles doc pane on', () => {
cy.get('.docExplorerShow').click();
cy.get('.graphiql-sidebar button').eq(0).click();
cy.get('.doc-explorer').should('be.visible');
});

Expand All @@ -19,7 +19,7 @@ describe('GraphiQL DocExplorer - button', () => {
describe('GraphiQL DocExplorer - search', () => {
before(() => {
cy.visit(`/`);
cy.get('.docExplorerShow').click();
cy.get('.graphiql-sidebar button').eq(0).click();
});

it('Searches docs for values', () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('GraphiQL DocExplorer - search', () => {

it('Allows clearing the search', () => {
cy.visit(`/`);
cy.get('.docExplorerShow').click();
cy.get('.graphiql-sidebar button').eq(0).click();
cy.get('label.search-box input').type('test');
cy.get('.search-box-clear').click();
cy.get('.doc-category-title').should('have.text', 'root types');
Expand All @@ -77,7 +77,7 @@ describe('GraphiQL DocExplorer - search', () => {
describe('GraphQL DocExplorer - deprecated fields', () => {
before(() => {
cy.visit(`/`);
cy.get('.docExplorerShow').click();
cy.get('.graphiql-sidebar button').eq(0).click();
});
it('should show deprecated fields category title', () => {
cy.get('.doc-category>.doc-category-item').first().find('a').click();
Expand Down
Loading