Skip to content

Commit 8d71696

Browse files
PavelLaptevestib-vega
authored andcommitted
Add OAuth mode prop to auth components
Introduces an 'oauthMode' prop to AuthPageLayout and OAuthButtons to distinguish between 'signin' and 'signup' flows, updating button text accordingly. Updates login and signup pages to use the correct mode, and refines layout logic for finalized pages and navigation visibility. Also adds an optional 'showBackLink' prop to AuthUtilityLayout.
1 parent b7a9da2 commit 8d71696

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

apps/web/src/lib/components/auth/AuthPageLayout.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
title: string;
88
subtitle?: string;
99
oauthText?: string;
10+
oauthMode?: 'signin' | 'signup';
1011
bottomLinkText?: string;
1112
bottomLinkHref?: string;
1213
bottomLinkLabel?: string;
@@ -17,6 +18,7 @@
1718
title,
1819
subtitle,
1920
oauthText = 'Or continue with',
21+
oauthMode = 'signin',
2022
bottomLinkText,
2123
bottomLinkHref,
2224
bottomLinkLabel,
@@ -41,7 +43,7 @@
4143
<span class="text-12">{oauthText}</span>
4244
</div>
4345

44-
<OAuthButtons />
46+
<OAuthButtons mode={oauthMode} />
4547
</div>
4648

4749
{#if bottomLinkText && bottomLinkHref && bottomLinkLabel}

apps/web/src/lib/components/auth/AuthUtilityLayout.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
interface Props {
77
title: string;
88
children: Snippet;
9+
showBackLink?: boolean;
910
}
1011
11-
let { title, children }: Props = $props();
12+
let { title, children, showBackLink = true }: Props = $props();
1213
1314
const routesService = inject(WEB_ROUTES_SERVICE);
1415
</script>
@@ -21,9 +22,12 @@
2122

2223
<div class="text-12 service-form__footer">
2324
<p>
24-
← Back to
25-
<a href={routesService.loginPath()}>Login</a>
25+
{#if showBackLink}
26+
← Back to
27+
<a href={routesService.loginPath()}>Login</a>
28+
{/if}
2629
</p>
30+
2731
<p>
2832
Need help?
2933
<a

apps/web/src/lib/components/login/OAuthButtons.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<script lang="ts">
22
import { env } from '$env/dynamic/public';
3+
4+
interface Props {
5+
mode?: 'signin' | 'signup';
6+
}
7+
8+
let { mode = 'signin' }: Props = $props();
9+
10+
const actionText = mode === 'signup' ? 'Sign up' : 'Sign in';
311
</script>
412

513
<div class="oauth-buttons">
614
{#snippet oauthButton(provider: 'github' | 'google')}
715
{@const config = {
816
github: {
917
endpoint: 'auth/github',
10-
title: 'Sign in with GitHub',
18+
title: `${actionText} with GitHub`,
1119
label: 'GitHub',
1220
svg: `<svg class="oauth-logo" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
1321
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#000"/>
1422
</svg>`
1523
},
1624
google: {
1725
endpoint: 'auth/google_oauth2',
18-
title: 'Sign in with Google',
26+
title: `${actionText} with Google`,
1927
label: 'Google',
2028
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="oauth-logo">
2129
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285f4"></path>
@@ -55,6 +63,7 @@
5563
align-items: center;
5664
justify-content: center;
5765
padding: 8px;
66+
padding-right: 14px;
5867
gap: 8px;
5968
border: 1px solid var(--clr-border-2);
6069
border-radius: var(--radius-m);

apps/web/src/routes/(app)/+layout.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@
152152
const isCommitPage = $derived(page.url.pathname.includes('/commit/'));
153153
const isLoginPage = $derived(page.url.pathname.includes('/login'));
154154
const isSignupPage = $derived(page.url.pathname.includes('/signup'));
155-
const hasNavigation = $derived(!isCommitPage && !isLoginPage && !isSignupPage);
156-
const isFullScreen = $derived(isLoginPage || isSignupPage);
155+
const isFinalized = $derived(page.url.pathname.includes('/finalize'));
156+
const hasNavigation = $derived(!isCommitPage && !isLoginPage && !isSignupPage && !isFinalized);
157+
const isFullScreen = $derived(isLoginPage || isSignupPage || isFinalized);
157158
</script>
158159

159160
<RedirectIfNotFinalized />
@@ -179,6 +180,7 @@
179180
flex-direction: column;
180181
width: 100%;
181182
min-height: 100vh;
183+
margin: 0 auto;
182184
padding: 24px var(--layout-side-paddings);
183185
&:not(.full-screen) {
184186
max-width: calc(1440px + var(--layout-side-paddings) * 2);

apps/web/src/routes/(app)/login/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
title="Login"
7575
subtitle="to GitButler"
7676
oauthText="Or log in with"
77+
oauthMode="signin"
7778
bottomLinkText="Don't have an account?"
7879
bottomLinkHref={routesService.signupPath()}
7980
bottomLinkLabel="Sign Up now"

apps/web/src/routes/(app)/signup/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
title="Sign Up"
6464
subtitle="for GitButler"
6565
oauthText="Or sign up with"
66+
oauthMode="signup"
6667
bottomLinkText="Already have an account?"
6768
bottomLinkHref={routesService.loginPath()}
6869
bottomLinkLabel="Log in"

0 commit comments

Comments
 (0)