-
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] add settings dialog (#2595)
* add `Dialog` component to `@graphiql/react` * add a `clear` method to the `Storage` type * add success and failure states to `Button` component * add settings dialog * make sure to show dialog above editor scrollbars
- Loading branch information
1 parent
8737f99
commit 9db62f8
Showing
14 changed files
with
339 additions
and
18 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
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,5 @@ | ||
--- | ||
'@graphiql/toolkit': minor | ||
--- | ||
|
||
Add a `clear` method to `Storage` classes |
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
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,19 +1,31 @@ | ||
import { compose } from '../utility/compose'; | ||
|
||
import './button.css'; | ||
|
||
export function UnStyledButton(props: JSX.IntrinsicElements['button']) { | ||
return ( | ||
<button | ||
{...props} | ||
className={`graphiql-un-styled ${props.className || ''}`.trim()} | ||
className={compose('graphiql-un-styled', props.className)} | ||
/> | ||
); | ||
} | ||
|
||
export function Button(props: JSX.IntrinsicElements['button']) { | ||
type ButtonProps = { state?: 'success' | 'error' }; | ||
|
||
export function Button(props: ButtonProps & JSX.IntrinsicElements['button']) { | ||
return ( | ||
<button | ||
{...props} | ||
className={`graphiql-button ${props.className || ''}`.trim()} | ||
className={compose( | ||
'graphiql-button', | ||
props.state === 'success' | ||
? 'graphiql-button-success' | ||
: props.state === 'error' | ||
? 'graphiql-button-error' | ||
: '', | ||
props.className, | ||
)} | ||
/> | ||
); | ||
} |
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,34 @@ | ||
@import url('@reach/dialog/styles.css'); | ||
|
||
[data-reach-dialog-overlay] { | ||
align-items: center; | ||
background-color: var(--color-neutral-background); | ||
display: flex; | ||
justify-content: center; | ||
/** | ||
* CodeMirror has a `z-index` set for the container of the scrollbar of the | ||
* editor, so we have to add one here to make sure that the dialog is shown | ||
* above the editor scrollbar (if they are visible). | ||
*/ | ||
z-index: 10; | ||
} | ||
|
||
[data-reach-dialog-content] { | ||
background-color: var(--color-neutral-0); | ||
border-radius: var(--border-radius-12); | ||
box-shadow: var(--box-shadow); | ||
margin: 0; | ||
max-height: 80vh; | ||
max-width: 80vw; | ||
overflow: auto; | ||
padding: 0; | ||
width: unset; | ||
} | ||
|
||
.graphiql-dialog-close > svg { | ||
color: var(--color-neutral-60); | ||
display: block; | ||
height: var(--px-12); | ||
padding: var(--px-12); | ||
width: var(--px-12); | ||
} |
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,27 @@ | ||
import { Dialog as ReachDialog } from '@reach/dialog'; | ||
import { VisuallyHidden } from '@reach/visually-hidden'; | ||
import { ComponentProps } from 'react'; | ||
import { CloseIcon } from '../icons'; | ||
import { compose } from '../utility/compose'; | ||
import { UnStyledButton } from './button'; | ||
|
||
import './dialog.css'; | ||
|
||
export function Dialog(props: ComponentProps<typeof ReachDialog>) { | ||
return <ReachDialog {...props} />; | ||
} | ||
|
||
function DialogClose(props: JSX.IntrinsicElements['button']) { | ||
return ( | ||
<UnStyledButton | ||
{...props} | ||
type="button" | ||
className={compose('graphiql-dialog-close', props.className)} | ||
> | ||
<VisuallyHidden>Close dialog</VisuallyHidden> | ||
<CloseIcon /> | ||
</UnStyledButton> | ||
); | ||
} | ||
|
||
Dialog.Close = DialogClose; |
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
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
Oops, something went wrong.