-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ScreenLink: Introduce component to simplify linking between screens.
The caller no longer needs to deal with the importing `clickScreenLink` and setting it as the `onClick` handler.
- Loading branch information
Showing
7 changed files
with
73 additions
and
40 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,35 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useContext } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { GlobalContext } from '../script'; | ||
|
||
export default function ScreenLink( { screen, anchorText, buttonStyle = false } ) { | ||
const { clickScreenLink } = useContext( GlobalContext ); | ||
const classes = []; | ||
let screenUrl = new URL( document.location.href ); | ||
|
||
screenUrl.searchParams.set( 'screen', screen ); | ||
|
||
if ( 'primary' === buttonStyle ) { | ||
classes.push( 'components-button' ); | ||
classes.push( 'is-primary' ); | ||
} else if ( 'secondary' === buttonStyle ) { | ||
classes.push( 'components-button' ); | ||
classes.push( 'is-secondary' ); | ||
} | ||
|
||
return ( | ||
<a | ||
href={ screenUrl.href } | ||
onClick={ ( event ) => clickScreenLink( event, screen ) } | ||
className={ classes.join( ' ' ) } | ||
> | ||
{ anchorText } | ||
</a> | ||
) | ||
} |
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,6 @@ | ||
/* Overwrite bbPress styles with Gutenberg styles */ | ||
#bbpress-forums .wp-block-wporg-two-factor-settings a.components-button, | ||
#bbpress-forums .wp-block-wporg-two-factor-settings a.components-button:hover { | ||
box-shadow: inset 0 0 0 1px var(--wp-components-color-accent,var(--wp-admin-theme-color,#007cba)); | ||
text-decoration: 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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
.wporg-2fa__verify-code { | ||
width: 10ch; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.wporg-2fa__enabled-status { | ||
|
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