Skip to content

Login: Update styles and layout of QR code screen #102010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions client/blocks/qr-code-login/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getTracksAnonymousUserId } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { Card, Gridicon, ExternalLink } from '@automattic/components';
import { ExternalLink } from '@automattic/components';
import { localizeUrl } from '@automattic/i18n-utils';
import { Notice } from '@wordpress/components';
import { addQueryArgs } from '@wordpress/url';
import { useTranslate } from 'i18n-calypso';
import { QRCodeSVG } from 'qrcode.react';
import { useEffect, useState } from 'react';
import qrCenter from 'calypso/assets/images/qr-login/app.png';
import { setStoredItem, getStoredItem } from 'calypso/lib/browser-storage';
import { useInterval } from 'calypso/lib/interval';
import { login } from 'calypso/lib/paths';
import { postLoginRequest, getErrorFromHTTPError } from 'calypso/state/login/utils';

import './style.scss';
Expand Down Expand Up @@ -73,26 +73,20 @@ function QRCodePlaceholder() {
);
}

function QRCodeErrorCard( { redirectToAfterLoginUrl, locale } ) {
function QRCodeErrorCard() {
const translate = useTranslate();

const loginUrl = login( {
redirectTo: redirectToAfterLoginUrl,
locale,
} );
return (
<Card className="qr-code-login">
<div className="qr-code-login is-error">
<div className="qr-code-login__token-error">
<h1 className="qr-code-login-page__heading">{ translate( 'Log in via Jetpack app' ) }</h1>
<p>{ translate( 'Mobile App QR Code login is currently unavailable.' ) }</p>
<p>
<a href={ loginUrl }>{ translate( 'Back to login' ) }</a>
</p>
</div>
</Card>
</div>
);
}

function QRCodeLogin( { locale, redirectToAfterLoginUrl } ) {
function QRCodeLogin( { redirectToAfterLoginUrl } ) {
const translate = useTranslate();
const [ tokenState, setTokenState ] = useState( null );
const [ authState, setAuthState ] = useState( false );
Expand Down Expand Up @@ -217,7 +211,11 @@ function QRCodeLogin( { locale, redirectToAfterLoginUrl } ) {
),
},
} ),
translate( 'Tap the Me Tab.' ),
translate( 'Tap the {{strong}}Me{{/strong}} tab.', {
components: {
strong: <strong />,
},
} ),
translate( 'Tap the {{strong}}Scan Login Code{{/strong}} option.', {
components: {
strong: <strong />,
Expand All @@ -227,7 +225,7 @@ function QRCodeLogin( { locale, redirectToAfterLoginUrl } ) {
];

const notice = translate(
"Logging in via the Jetpack app is {{strong}}not available{{/strong}} if you've enabled two-step authentication on your account.",
'Logging in via the Jetpack app is {{strong}}not available{{/strong}} to accounts with two-factor authentication enabled.',
{
components: {
strong: <strong />,
Expand All @@ -236,32 +234,29 @@ function QRCodeLogin( { locale, redirectToAfterLoginUrl } ) {
);

if ( isErrorState ) {
return (
<QRCodeErrorCard locale={ locale } redirectToAfterLoginUrl={ redirectToAfterLoginUrl } />
);
return <QRCodeErrorCard />;
}

return (
<Card className="qr-code-login">
<div className="qr-code-login">
<div className="qr-code-login__token">
<TokenQRCode tokenData={ tokenState } />
</div>

<div className="qr-code-login__instructions">
<h2 className="qr-code-login__heading">{ translate( 'Use QR Code to login' ) }</h2>
<h1 className="qr-code-login-page__heading">{ translate( 'Log in via Jetpack app' ) }</h1>
<Notice isDismissible={ false } status="warning">
<p>{ notice }</p>
</Notice>
<ol className="qr-code-login__steps">
{ steps.map( ( step, index ) => (
<li key={ 'step-' + index } className="qr-code-login__step">
{ step }
</li>
) ) }
</ol>
<div className="qr-code-login__info">
<Gridicon icon="info-outline" size={ 18 } />
<p>{ notice }</p>
</div>
</div>
</Card>
</div>
);
}

Expand Down
46 changes: 7 additions & 39 deletions client/blocks/qr-code-login/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,22 @@
display: flex;
flex-direction: column;
clear: left;
gap: 16px 48px;

&:not(.is-error) {
margin-bottom: 48px;
}

@include break-small {
flex-direction: row-reverse;
}

.qr-code-login__instructions {
text-align: left;
padding-right: 20px;
font-size: $font-body-small;

.qr-code-login__heading {
font-size: $font-title-small;
text-align: center;
margin-bottom: 12px;
font-weight: 500;

@include break-small {
text-align: left;
}
}
line-height: 1.6;

.qr-code-login__steps {
margin-left: 16px;
}

.qr-code-login__step {
margin-bottom: 0.75em;
}

.qr-code-login__info {
border-radius: 2px;
font-size: $font-body-small;
padding: 8px;
align-items: center;
background-color: var(--color-neutral-0);
display: flex;
color: var(--color-neutral-50);

.gridicon {
padding-right: 4px;
width: 60px;
text-align: left;
fill: var(--color-warning);
}

strong {
color: var(--color-neutral-70);
}
margin: 16px 0 0 16px;
}

a {
Expand Down
12 changes: 6 additions & 6 deletions client/layout/masterbar/woo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ $breakpoint-mobile: 660px;
.wp-login__links button,
.button:not(.social-buttons__button),
.magic-login__footer a {
font-size: $woo-font-size-base;
line-height: 28px;
text-align: center;
color: $gray-50;
text-decoration: underline;
letter-spacing: 0;

&:hover,
&:visited {
color: $gray-50;
}

&:hover,
&:focus {
color: $woo-gray-100;
}
}

.button:not(.social-buttons__button) {
Expand Down Expand Up @@ -722,7 +722,6 @@ $breakpoint-mobile: 660px;

a {
color: var(--woo-purple-70);
font-size: $font-body;
text-decoration: none;
}

Expand Down Expand Up @@ -1525,6 +1524,7 @@ $breakpoint-mobile: 660px;
color: var(--woo-purple-40);
text-align: center;
font-weight: 400;
font-size: $woo-font-size-base;
line-height: 20px;
margin-block-start: 24px;
text-decoration: underline;
Expand Down
17 changes: 14 additions & 3 deletions client/login/qr-code-login-page/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Gridicon } from '@automattic/components';
import { Card } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import AsyncLoad from 'calypso/components/async-load';
import Main from 'calypso/components/main';
Expand All @@ -17,7 +17,19 @@ function QrCodeLoginPage( { locale, redirectTo } ) {
return (
<Main className="qr-code-login-page">
<div className="qr-code-login-page__form">
<h1 className="qr-code-login-page__heading">{ translate( 'Log in via Jetpack app' ) }</h1>
<div className="magic-login__gutenboarding-wordpress-logo">
<svg
aria-hidden="true"
role="img"
focusable="false"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 20 20"
>
<path d="M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"></path>
</svg>
</div>
<AsyncLoad
require="calypso/blocks/qr-code-login"
placeholder={ <QrCodeLoginPlaceholder /> }
Expand All @@ -27,7 +39,6 @@ function QrCodeLoginPage( { locale, redirectTo } ) {
/>
<div className="qr-code-login-page__footer">
<a href={ login( { locale, redirectTo, isWhiteLogin } ) }>
<Gridicon icon="arrow-left" size={ 18 } />
{ translate( 'Enter a password instead' ) }
</a>
</div>
Expand Down
24 changes: 12 additions & 12 deletions client/login/qr-code-login-page/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@

.qr-code-login-page {
margin: 0 auto;
max-width: 780px;
max-width: 700px;
text-align: center;
}

.layout:has(.qr-code-login-page) {
display: flex;
align-items: center;
justify-content: center;
}

.qr-code-login-page__heading {
font-size: $font-title-small;
margin-bottom: 32px;
margin-top: 16px;
text-align: center;
@include onboarding-heading-text-mobile;
margin-bottom: 16px;
text-align: left !important;
}

.qr-code-login-page__footer {
a {
color: var(--color-neutral-50);
display: block;
/* stylelint-disable-next-line declaration-property-unit-allowed-list */
line-height: 4em;
font-size: $font-body-small;
color: var(--color-text);
font-weight: 600;
padding: 0 24px;
text-align: center;
text-decoration: none;
text-decoration: underline;

&:hover {
color: var(--color-primary);
}
}
.gridicon {
vertical-align: text-bottom;
}
}

.qr-code-login-page__placeholder {
Expand Down