-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from wp-graphql/issue-3-auth-switch
feat: public user query
- Loading branch information
Showing
14 changed files
with
6,149 additions
and
3,501 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import { ToolbarButton } from '@graphiql/react'; | ||
|
||
import styles from '../../../styles/ToggleAuthButton.module.css'; | ||
|
||
/** | ||
* Component to toggle the authentication state within the GraphiQL IDE. | ||
* | ||
* @param {Object} props Component props. | ||
* @param {boolean} props.isAuthenticated Indicates if the current state is authenticated. | ||
* @param {Function} props.toggleAuthentication Function to toggle the authentication state. | ||
*/ | ||
export const ToggleAuthButton = ( { | ||
isAuthenticated, | ||
toggleAuthentication, | ||
} ) => { | ||
const avatarUrl = window.WPGRAPHQL_IDE_DATA?.context?.avatarUrl; | ||
const title = isAuthenticated | ||
? 'Switch to execute as a public user' | ||
: 'Switch to execute as the logged-in user'; | ||
|
||
return ( | ||
<ToolbarButton | ||
className={ clsx( 'graphiql-un-styled', 'graphiql-toolbar-button graphiql-auth-button', { | ||
[ styles.authAvatarPublic ]: ! isAuthenticated, | ||
'is-authenticated': isAuthenticated, | ||
'is-public': ! isAuthenticated, | ||
} ) } | ||
onClick={ toggleAuthentication } | ||
label={ title } | ||
> | ||
<span | ||
className={ styles.authAvatar } | ||
style={ { backgroundImage: `url(${ avatarUrl ?? '' })` } } | ||
> | ||
<span className={ styles.authBadge }></span> | ||
</span> | ||
</ToolbarButton> | ||
); | ||
}; |
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,58 @@ | ||
.authAvatar { | ||
display: inline-block; | ||
width: 32px; | ||
height: 32px; | ||
border-radius: 50%; | ||
background-size: cover; | ||
position: relative; | ||
} | ||
|
||
.authAvatarPublic { | ||
filter: grayscale(100%) !important; | ||
|
||
.authBadge { | ||
animation: bounceOut 0.5s forwards; | ||
} | ||
} | ||
|
||
.authBadge { | ||
width: 10px; | ||
height: 10px; | ||
background-color: #52c41a; /* Success color */ | ||
border-radius: 50%; | ||
display: block; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
border: 2px solid white; | ||
transition: background-color 1.5s, transform 1.5s; | ||
animation: bounceIn 0.5s forwards; | ||
} | ||
|
||
@keyframes bounceIn { | ||
0% { | ||
transform: scale(0.2); | ||
opacity: 0; | ||
} | ||
60% { | ||
transform: scale(1.2); | ||
opacity: 1; | ||
} | ||
100% { | ||
transform: scale(1); | ||
} | ||
} | ||
|
||
@keyframes bounceOut { | ||
0% { | ||
transform: scale(1); | ||
} | ||
50% { | ||
transform: scale(1.2); | ||
opacity: 1; | ||
} | ||
100% { | ||
transform: scale(0.2); | ||
opacity: 0; | ||
} | ||
} |
Empty file.
Oops, something went wrong.