-
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.
File structure and components refactoring and test update (#215)
* Rename the original utilities.js to common.js to indicate its generic use * Move the customized hook "useUser" to hooks/ * Move tests/ directory outside of components/ * Separate useUser from common.test * Add renderHook for useUser test. The hook should be called by a component. In a test, renderHook would do that for us. * Extract ScreenNavigation * Add navigateToScreen as dependency navigateToScreen should be added as the hook dependency, or hasEdits might not be the latest value when calling the function. In fact, due to the property of how hasEdits is updated, the navigateToScreen would always get the latest value of hasEdits, but it's best practice to add state and props that are used in the hook as its dependency, or it might get harder to develop a new feature or maintain the code someday in the future. * Bump @wordpress/scripts version to ^25.0.0 See details at #215 (comment)
- Loading branch information
Showing
19 changed files
with
450 additions
and
202 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
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,42 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Icon, chevronLeft } from '@wordpress/icons'; | ||
import { Card, CardHeader, CardBody } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import ScreenLink from './screen-link'; | ||
|
||
/** | ||
* @param props | ||
* @param props.children | ||
* @param props.screen | ||
*/ | ||
const ScreenNavigation = ( { screen, children } ) => ( | ||
<Card> | ||
<CardHeader className="wporg-2fa__navigation" size="xSmall"> | ||
<ScreenLink | ||
screen="account-status" | ||
ariaLabel="Back to the account status page" | ||
anchorText={ | ||
<> | ||
<Icon icon={ chevronLeft } /> | ||
Back | ||
</> | ||
} | ||
/> | ||
|
||
<h3> | ||
{ screen | ||
.replace( '-', ' ' ) | ||
.replace( 'totp', 'Two-Factor Authentication' ) | ||
.replace( 'webauthn', 'Two-Factor Security Key' ) } | ||
</h3> | ||
</CardHeader> | ||
<CardBody className={ 'wporg-2fa__' + screen }>{ children }</CardBody> | ||
</Card> | ||
); | ||
|
||
export default ScreenNavigation; |
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,22 @@ | ||
.wporg-2fa__navigation { | ||
padding: 24px 0 !important; /* Override Gutenberg auto-generated. */ | ||
justify-content: center !important; | ||
position: relative; | ||
|
||
a { | ||
display: flex; | ||
align-items: center; | ||
position: absolute; | ||
left: 24px; | ||
} | ||
|
||
svg { | ||
fill: #4ca6cf; | ||
} | ||
|
||
h3 { | ||
margin: unset; | ||
text-transform: capitalize; | ||
} | ||
|
||
} |
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
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.