Skip to content

Commit a3d1ceb

Browse files
authored
feat: compact auth banner alongside post signup widget (#5886)
1 parent 29f47e7 commit a3d1ceb

File tree

6 files changed

+86
-32
lines changed

6 files changed

+86
-32
lines changed

packages/shared/src/components/auth/AuthenticationBanner.tsx

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,58 @@ import { AuthDisplay } from './common';
1818

1919
const Section = classed('div', 'flex flex-col');
2020

21+
interface AuthenticationBannerProps extends PropsWithChildren {
22+
compact?: boolean;
23+
}
24+
2125
export function AuthenticationBanner({
2226
children,
23-
}: PropsWithChildren): ReactElement {
27+
compact,
28+
}: AuthenticationBannerProps): ReactElement {
2429
const { showLogin } = useAuthContext();
2530

2631
return (
2732
<BottomBannerContainer
2833
className={classNames(
29-
'border-t border-accent-cabbage-default py-10 shadow-3',
34+
'border-t border-accent-cabbage-default shadow-3',
35+
compact ? 'py-4' : 'py-10',
3036
authGradientBg,
3137
)}
3238
>
33-
<div className="flex max-w-[63.75rem] flex-row justify-center gap-10">
39+
<div
40+
className={classNames(
41+
'flex max-w-[63.75rem] flex-row justify-center gap-10',
42+
compact && 'items-center',
43+
)}
44+
>
3445
<Image
3546
className="absolute left-0 top-0 -z-1 h-full w-full"
3647
src={bg}
3748
srcSet={`${laptopBg} 1440w, ${desktopBg} 1920w, ${bg} 2880w`}
3849
sizes="(max-width: 1440px) 100vw, (max-width: 1920px) 1920px, 100vw"
3950
/>
40-
<Section className="max-w-full flex-grow basis-0 gap-4">
41-
{children || (
42-
<OnboardingHeadline
43-
className={{
44-
title: 'typo-mega3',
45-
description: 'mb-8 typo-title3',
46-
}}
47-
/>
51+
<Section
52+
className={classNames(
53+
'max-w-full flex-grow basis-0',
54+
compact ? 'justify-center gap-2' : 'gap-4',
4855
)}
56+
>
57+
{children ||
58+
(compact ? (
59+
<OnboardingHeadline
60+
className={{
61+
title: 'typo-large-title',
62+
description: 'typo-body',
63+
}}
64+
/>
65+
) : (
66+
<OnboardingHeadline
67+
className={{
68+
title: 'typo-mega3',
69+
description: 'mb-8 typo-title3',
70+
}}
71+
/>
72+
))}
4973
</Section>
5074
<Section className="w-[23.25rem]">
5175
<AuthOptions
@@ -56,7 +80,7 @@ export function AuthenticationBanner({
5680
defaultDisplay={AuthDisplay.OnboardingSignup}
5781
forceDefaultDisplay
5882
className={{
59-
onboardingSignup: '!gap-4',
83+
onboardingSignup: compact ? '!gap-3' : '!gap-4',
6084
}}
6185
onAuthStateUpdate={(props) => {
6286
showLogin({
@@ -67,6 +91,8 @@ export function AuthenticationBanner({
6791
onboardingSignupButton={{
6892
variant: ButtonVariant.Primary,
6993
}}
94+
hideLoginLink={compact}
95+
compact={compact}
7096
/>
7197
</Section>
7298
</div>

packages/shared/src/components/auth/PostAuthBanner.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,30 @@ const GeoPersonalizedBanner = dynamic(
2323
() => import('../banners/personalized/GeoPersonalizedBanner'),
2424
);
2525

26-
export const PostAuthBanner = (): ReactElement => {
26+
interface PostAuthBannerProps {
27+
compact?: boolean;
28+
}
29+
30+
export const PostAuthBanner = ({
31+
compact,
32+
}: PostAuthBannerProps = {}): ReactElement => {
2733
const searchParams = useSearchParams();
2834
const { geo } = useAuthContext();
2935

3036
const userId = searchParams?.get('userid');
3137

3238
if (userId) {
33-
return <UserPersonalizedBanner userId={userId} />;
39+
return <UserPersonalizedBanner userId={userId} compact={compact} />;
3440
}
3541

3642
const social = getSocialReferrer();
3743
if (social) {
38-
return <SocialPersonalizedBanner site={social} />;
44+
return <SocialPersonalizedBanner site={social} compact={compact} />;
3945
}
4046

4147
if (geo?.region) {
42-
return <GeoPersonalizedBanner geo={geo.region} />;
48+
return <GeoPersonalizedBanner geo={geo.region} compact={compact} />;
4349
}
4450

45-
return <AuthenticationBanner />;
51+
return <AuthenticationBanner compact={compact} />;
4652
};

packages/shared/src/components/banners/personalized/GeoPersonalizedBanner.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@ import React from 'react';
33
import { geoToCountry, geoToEmoji } from '../../../lib/geo';
44
import { AuthenticationBanner, OnboardingHeadline } from '../../auth';
55

6-
const GeoPersonalizedBanner = ({ geo }: { geo: string }): ReactElement => {
6+
const GeoPersonalizedBanner = ({
7+
geo,
8+
compact,
9+
}: {
10+
geo: string;
11+
compact?: boolean;
12+
}): ReactElement => {
713
const emoji = geoToEmoji(geo);
814
const country = geoToCountry(geo);
915

1016
return (
11-
<AuthenticationBanner>
12-
<span className="text-[3.5rem] leading-none">{emoji}</span>
17+
<AuthenticationBanner compact={compact}>
18+
<span
19+
className={
20+
compact ? 'text-[2.5rem] leading-none' : 'text-[3.5rem] leading-none'
21+
}
22+
>
23+
{emoji}
24+
</span>
1325
<OnboardingHeadline
1426
className={{
15-
title: `typo-mega3`,
16-
description: 'mb-8 typo-title3',
27+
title: compact ? 'typo-large-title' : 'typo-mega3',
28+
description: compact ? 'typo-body' : 'mb-8 typo-title3',
1729
}}
1830
title={`daily.dev is the fastest growing developer platform in ${country}!`}
1931
description="We know how hard it is to be a developer. It doesn't have to be. Personalized news feed, dev community and search, much better than what's out there. Maybe ;)"

packages/shared/src/components/banners/personalized/SocialPersonalizedBanner.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,27 @@ import { IconSize } from '../../Icon';
1414

1515
const SocialPersonalizedBanner = ({
1616
site,
17+
compact,
1718
}: {
1819
site: SupportedSocialReferrer;
20+
compact?: boolean;
1921
}): ReactElement => {
2022
const Icon = socialIcon[site];
2123
const gradient = socialGradient[site];
2224

2325
return (
24-
<AuthenticationBanner>
25-
<Icon size={IconSize.Size48} secondary={site === SocialIconType.Reddit} />
26+
<AuthenticationBanner compact={compact}>
27+
<Icon
28+
size={compact ? IconSize.Large : IconSize.Size48}
29+
secondary={site === SocialIconType.Reddit}
30+
/>
2631
<OnboardingHeadline
2732
className={{
28-
title: classNames('typo-mega3', gradient),
29-
description: classNames('mb-8 typo-title3'),
33+
title: classNames(
34+
compact ? 'typo-large-title' : 'typo-mega3',
35+
gradient,
36+
),
37+
description: compact ? 'typo-body' : 'mb-8 typo-title3',
3038
}}
3139
pretitle={`Coming from ${capitalize(site)}?`}
3240
{...socialCTA[site]}

packages/shared/src/components/banners/personalized/UserPersonalizedBanner.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { generateQueryKey, RequestKey } from '../../../lib/query';
88

99
const UserPersonalizedBanner = ({
1010
userId,
11+
compact,
1112
}: {
1213
userId: string;
14+
compact?: boolean;
1315
}): ReactElement => {
1416
const key = generateQueryKey(RequestKey.ReferringUser);
1517
const { data: user, isError } = useQuery({
@@ -18,18 +20,18 @@ const UserPersonalizedBanner = ({
1820
});
1921

2022
if (isError) {
21-
return <AuthenticationBanner />;
23+
return <AuthenticationBanner compact={compact} />;
2224
}
2325

2426
const name = user?.name ? user?.name.split(' ')[0] : user?.username;
2527

2628
return (
27-
<AuthenticationBanner>
29+
<AuthenticationBanner compact={compact}>
2830
{user?.image && <ProfilePicture user={user} />}
2931
<OnboardingHeadline
3032
className={{
31-
title: 'typo-mega3',
32-
description: 'mb-8 typo-title3',
33+
title: compact ? 'typo-large-title' : 'typo-mega3',
34+
description: compact ? 'typo-body' : 'mb-8 typo-title3',
3335
}}
3436
pretitle={user?.username}
3537
title="shared it, so it's probably a good one."

packages/webapp/pages/posts/[id]/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ export const PostPage = ({
288288
},
289289
}}
290290
/>
291-
{shouldShowAuthBanner && isLaptop && !isPostSignupWidget && (
292-
<PostAuthBanner />
291+
{shouldShowAuthBanner && isLaptop && (
292+
<PostAuthBanner compact={isPostSignupWidget} />
293293
)}
294294
</FooterNavBarLayout>
295295
</LogExtraContextProvider>

0 commit comments

Comments
 (0)