diff --git a/settings/src/components/screen-navigation.js b/settings/src/components/screen-navigation.js new file mode 100644 index 00000000..1951226d --- /dev/null +++ b/settings/src/components/screen-navigation.js @@ -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 } ) => ( + + + + + Back + + } + /> + +

+ { screen + .replace( '-', ' ' ) + .replace( 'totp', 'Two-Factor Authentication' ) + .replace( 'webauthn', 'Two-Factor Security Key' ) } +

+
+ { children } +
+); + +export default ScreenNavigation; diff --git a/settings/src/components/screen-navigation.scss b/settings/src/components/screen-navigation.scss new file mode 100644 index 00000000..fdfd62c8 --- /dev/null +++ b/settings/src/components/screen-navigation.scss @@ -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; + } + +} \ No newline at end of file diff --git a/settings/src/script.js b/settings/src/script.js index a71a4f1b..ef411b26 100644 --- a/settings/src/script.js +++ b/settings/src/script.js @@ -9,14 +9,13 @@ import { useState, createRoot, } from '@wordpress/element'; -import { Icon, chevronLeft } from '@wordpress/icons'; -import { Card, CardHeader, CardBody, Spinner } from '@wordpress/components'; +import { Spinner } from '@wordpress/components'; /** * Internal dependencies */ import { useUser } from './hooks/useUser'; -import ScreenLink from './components/screen-link'; +import ScreenNavigation from './components/screen-navigation'; import AccountStatus from './components/account-status'; import Password from './components/password'; import EmailAddress from './components/email-address'; @@ -143,35 +142,12 @@ function Main( { userId } ) { return ; } - const currentScreen = components[ screen ]; - let screenContent = currentScreen; - - if ( 'account-status' !== screen ) { - screenContent = ( - - - - - Back - - } - /> - -

- { screen - .replace( '-', ' ' ) - .replace( 'totp', 'Two-Factor Authentication' ) - .replace( 'webauthn', 'Two-Factor Security Key' ) } -

-
- { currentScreen } -
+ const currentScreenComponent = + 'account-status' === screen ? ( + components[ screen ] + ) : ( + { components[ screen ] } ); - } const isRevalidationExpired = twoFactorRequiredScreens.includes( screen ) && @@ -185,7 +161,7 @@ function Main( { userId } ) { value={ { navigateToScreen, user, setGlobalNotice, setError, error } } > - { screenContent } + { currentScreenComponent } { shouldRevalidate && } ); diff --git a/settings/src/style.scss b/settings/src/style.scss index 5ddc1549..e3ed7684 100644 --- a/settings/src/style.scss +++ b/settings/src/style.scss @@ -50,29 +50,6 @@ $alert-blue: #72aee6; flex-wrap: wrap; } -.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; - } - -} - .wporg-2fa__token { letter-spacing: .3em; } @@ -105,5 +82,6 @@ $alert-blue: #72aee6; @import "components/setup-progress-bar"; @import "components/global-notice"; @import "components/screen-link"; +@import "components/screen-navigation"; @import "components/auto-tabbing-input"; @import "components/revalidate-modal";