-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[redesign] implement new toolbar design (#2524)
* implement new toolbar design * add `caller` argument for better errors
- Loading branch information
1 parent
443ed67
commit 32e3858
Showing
27 changed files
with
324 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
'graphiql': major | ||
--- | ||
|
||
BREAKING: The following static properties of the `GraphiQL` component have been removed: | ||
- `GraphiQL.Button`: You can use the `ToolbarButton` component from `@graphiql/react` instead. | ||
- `GraphiQL.ToolbarButton`: This exposed the same component as `GraphiQL.Button`. | ||
- `GraphiQL.Group`: Grouping multiple buttons side-by-side is not provided out-of-the box anymore in the new GraphiQL UI. If you want to implement a similar feature in the new vertical toolbar you can do so by adding your own styles for your custom toolbar elements. Example: | ||
```jsx | ||
import { GraphiQL } from "graphiql"; | ||
function CustomGraphiQL() { | ||
return ( | ||
<GraphiQL> | ||
<GraphiQL.Toolbar> | ||
{/* Add custom styles for your buttons using the given class */} | ||
<div className="button-group"> | ||
<button>1</button> | ||
<button>2</button> | ||
<button>3</button> | ||
</div> | ||
</GraphiQL.Toolbar> | ||
</GraphiQL> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
button.graphiql-toolbar-button { | ||
display: block; | ||
height: var(--toolbar-width); | ||
width: var(--toolbar-width); | ||
|
||
&.error { | ||
background: var(--color-red-background); | ||
} | ||
|
||
& > svg { | ||
pointer-events: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState } from 'react'; | ||
|
||
import { UnStyledButton } from '../ui'; | ||
|
||
import './button.css'; | ||
|
||
export function ToolbarButton(props: JSX.IntrinsicElements['button']) { | ||
const [error, setError] = useState<Error | null>(null); | ||
return ( | ||
<UnStyledButton | ||
{...props} | ||
className={ | ||
'graphiql-toolbar-button' + | ||
(error ? ' error' : '') + | ||
(props.className ? ' ' + props.className : '') | ||
} | ||
onClick={event => { | ||
try { | ||
props.onClick?.(event); | ||
setError(null); | ||
} catch (err) { | ||
setError( | ||
err instanceof Error | ||
? err | ||
: new Error(`Toolbar button click failed: ${err}`), | ||
); | ||
} | ||
}} | ||
title={error ? error.message : props.title} | ||
aria-invalid={error ? 'true' : props['aria-invalid']} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.graphiql-execute-button-wrapper { | ||
position: relative; | ||
} | ||
|
||
.graphiql-execute-button { | ||
background-color: var(--color-pink); | ||
border: none; | ||
border-radius: var(--border-radius-8); | ||
cursor: pointer; | ||
height: var(--toolbar-width); | ||
padding: 0; | ||
width: var(--toolbar-width); | ||
|
||
&:active { | ||
background-color: var(--color-pink-dark); | ||
} | ||
|
||
&:focus { | ||
outline: var(--color-pink-dark) auto 1px; | ||
} | ||
|
||
& > svg { | ||
color: var(--color-neutral-0); | ||
display: block; | ||
height: var(--px-16); | ||
margin: auto; | ||
pointer-events: none; | ||
width: var(--px-16); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './button'; | ||
export * from './execute'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.graphiql-dropdown { | ||
background-color: var(--color-neutral-0); | ||
box-shadow: var(--box-shadow); | ||
border-radius: var(--border-radius-8); | ||
margin: 0; | ||
max-width: 250px; | ||
min-width: 100px; | ||
padding: 0; | ||
position: absolute; | ||
z-index: 1; | ||
} | ||
|
||
.graphiql-dropdown-item { | ||
border-radius: var(--border-radius-4); | ||
cursor: pointer; | ||
margin: var(--px-4); | ||
overflow: hidden; | ||
padding: var(--px-6) var(--px-8); | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.graphiql-dropdown-item:active, | ||
.graphiql-dropdown-item:hover { | ||
background-color: var(--color-neutral-7); | ||
} | ||
|
||
.graphiql-dropdown-item:not(:first-child) { | ||
margin-top: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import './dropdown.css'; | ||
|
||
export function Dropdown(props: JSX.IntrinsicElements['ul']) { | ||
return ( | ||
<ul | ||
{...props} | ||
className={`graphiql-dropdown ${props.className || ''}`.trim()} | ||
/> | ||
); | ||
} | ||
|
||
Dropdown.Item = DropdownItem; | ||
|
||
function DropdownItem(props: JSX.IntrinsicElements['li']) { | ||
return ( | ||
<li | ||
{...props} | ||
className={`graphiql-dropdown-item ${props.className || ''}`.trim()} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './button'; | ||
export * from './dropdown'; |
Oops, something went wrong.