Skip to content

Commit 01e0a5d

Browse files
authored
Merge pull request #19392 from mozilla/FXA-12326
chore(settings): Add border to Google thirdparty auth button
2 parents c4980ae + 7501aa8 commit 01e0a5d

3 files changed

Lines changed: 80 additions & 16 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ThirdPartyAuthComponent buttons match snapshot: apple 1`] = `
4+
<button
5+
aria-label="Continue with Apple"
6+
class="w-[60px] h-[60px] p-4 flex items-center justify-center rounded-full border focus-visible-default outline-offset-2
7+
bg-black border-transparent
8+
"
9+
type="submit"
10+
>
11+
<svg>
12+
apple-logo-viewbox-white.svg
13+
</svg>
14+
</button>
15+
`;
16+
17+
exports[`ThirdPartyAuthComponent buttons match snapshot: google 1`] = `
18+
<button
19+
aria-label="Continue with Google"
20+
class="w-[60px] h-[60px] p-4 flex items-center justify-center rounded-full border focus-visible-default outline-offset-2
21+
bg-[#F9F4F4] border-[#747775] border-[1px]
22+
"
23+
type="submit"
24+
>
25+
<svg>
26+
google-logo-viewbox.svg
27+
</svg>
28+
</button>
29+
`;

packages/fxa-settings/src/components/ThirdPartyAuth/index.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ describe('ThirdPartyAuthComponent', () => {
197197
expect(mockViewWithNoPasswordSet).not.toHaveBeenCalled();
198198
});
199199

200+
it('buttons match snapshot', async () => {
201+
renderWith({
202+
enabled: true,
203+
onContinueWithApple,
204+
onContinueWithGoogle,
205+
});
206+
207+
const googleButton = await screen.findByLabelText('Continue with Google');
208+
const appleButton = await screen.findByLabelText('Continue with Apple');
209+
expect(googleButton).toMatchSnapshot('google');
210+
expect(appleButton).toMatchSnapshot('apple');
211+
});
212+
200213
describe('emits metrics', () => {
201214
it('emits glean metrics loginNoPwView', () => {
202215
renderWith({

packages/fxa-settings/src/components/ThirdPartyAuth/index.tsx

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const ThirdPartyAuth = ({
3535
showSeparator = true,
3636
viewName = 'unknown',
3737
deeplink,
38-
flowQueryParams
38+
flowQueryParams,
3939
}: ThirdPartyAuthProps) => {
4040
const config = useConfig();
4141

@@ -79,7 +79,7 @@ const ThirdPartyAuth = ({
7979
<GoogleLogo />
8080
</>
8181
),
82-
deeplink
82+
deeplink,
8383
}}
8484
/>
8585
<ThirdPartySignInForm
@@ -99,7 +99,7 @@ const ThirdPartyAuth = ({
9999
<AppleLogo />
100100
</>
101101
),
102-
deeplink
102+
deeplink,
103103
}}
104104
/>
105105
</div>
@@ -128,7 +128,7 @@ const ThirdPartySignInForm = ({
128128
onSubmit,
129129
viewName,
130130
deeplink,
131-
flowQueryParams
131+
flowQueryParams,
132132
}: {
133133
party: 'google' | 'apple';
134134
authorizationEndpoint: string;
@@ -154,8 +154,16 @@ const ThirdPartySignInForm = ({
154154

155155
const getLoginAriaLabel = () => {
156156
const labels = {
157-
google: l10n.getString('continue-with-google-button', null, 'Continue with Google'),
158-
apple: l10n.getString('continue-with-apple-button', null, 'Continue with Apple')
157+
google: l10n.getString(
158+
'continue-with-google-button',
159+
null,
160+
'Continue with Google'
161+
),
162+
apple: l10n.getString(
163+
'continue-with-apple-button',
164+
null,
165+
'Continue with Apple'
166+
),
159167
};
160168
return labels[party];
161169
};
@@ -197,24 +205,30 @@ const ThirdPartySignInForm = ({
197205
}
198206
}, [party, stateRef, viewName, logViewEventOnce, flowQueryParams]);
199207

200-
201208
if (onSubmit === undefined) {
202209
onSubmit = () => true;
203210
}
204211

205212
useEffect(() => {
206213
if (deeplink && formRef.current) {
207214
// Only deeplink if this is the correct button
208-
if ((deeplink === "googleLogin" && party === "google") || (deeplink === "appleLogin" && party === "apple")) {
215+
if (
216+
(deeplink === 'googleLogin' && party === 'google') ||
217+
(deeplink === 'appleLogin' && party === 'apple')
218+
) {
209219
onClick();
210220
formRef.current.submit();
211221
}
212222
}
213-
214223
}, [deeplink, onClick, party]);
215224

216225
return (
217-
<form action={authorizationEndpoint} method="GET" onSubmit={onSubmit} ref={formRef}>
226+
<form
227+
action={authorizationEndpoint}
228+
method="GET"
229+
onSubmit={onSubmit}
230+
ref={formRef}
231+
>
218232
<input
219233
data-testid={`${party}-signin-form-state`}
220234
ref={stateRef}
@@ -235,15 +249,19 @@ const ThirdPartySignInForm = ({
235249
{!isDeeplinking ? (
236250
<button
237251
type="submit"
238-
className={`w-[60px] h-[60px] p-4 flex items-center justify-center rounded-full border border-transparent focus-visible-default outline-offset-2 ${
239-
party === 'google' ? 'bg-[#F9F4F4]' : 'bg-black'
240-
}`}
252+
className={`w-[60px] h-[60px] p-4 flex items-center justify-center rounded-full border focus-visible-default outline-offset-2
253+
${
254+
party === 'google'
255+
? 'bg-[#F9F4F4] border-[#747775] border-[1px]'
256+
: 'bg-black border-transparent'
257+
}
258+
`}
241259
onClick={onClick}
242260
aria-label={getLoginAriaLabel()}
243261
>
244262
{buttonText}
245263
</button>
246-
) : null }
264+
) : null}
247265
</form>
248266
);
249267
};
@@ -263,7 +281,10 @@ function getState(flowQueryParams: QueryParams | undefined) {
263281
const combinedParams = {
264282
...paramsObject,
265283
...Object.fromEntries(
266-
Object.entries(flowQueryParams || {}).map(([key, value]) => [key, String(value)])
284+
Object.entries(flowQueryParams || {}).map(([key, value]) => [
285+
key,
286+
String(value),
287+
])
267288
),
268289
};
269290

@@ -278,7 +299,8 @@ function getState(flowQueryParams: QueryParams | undefined) {
278299
]);
279300
// we won't need these params that are used for internal backbone/react navigation
280301
return encodeURIComponent(
281-
`${window.location.origin}${window.location.pathname
302+
`${window.location.origin}${
303+
window.location.pathname
282304
}?${filteredParams.toString()}`
283305
);
284306
}

0 commit comments

Comments
 (0)