Skip to content

Commit c11b9ff

Browse files
committed
feat: change the magic link layout
1 parent 584519a commit c11b9ff

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

packages/auth/Auth.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:appearance="appearance"
88
>
99
<SocialAuth
10-
v-if="isSignView"
10+
v-if="authView === VIEWS.SIGN_IN || authView === VIEWS.SIGN_UP"
1111
:supabaseClient="supabaseClient"
1212
:appearance="appearance"
1313
:providers="providers"
@@ -20,7 +20,7 @@
2020
/>
2121
<template v-if="!onlyThirdPartyProviders">
2222
<EmailAuth
23-
v-if="authView === 'sign_in' || authView === 'sign_up'"
23+
v-if="authView === VIEWS.SIGN_IN || authView === VIEWS.SIGN_UP"
2424
:supabaseClient="supabaseClient"
2525
:appearance="appearance"
2626
:redirectTo="redirectTo"
@@ -30,7 +30,7 @@
3030
:additionalData="additionalData"
3131
/>
3232
<MagicLink
33-
v-if="authView === 'magic_link'"
33+
v-if="authView === VIEWS.MAGIC_LINK"
3434
:supabaseClient="supabaseClient"
3535
:appearance="appearance"
3636
:redirectTo="redirectTo"
@@ -41,28 +41,28 @@
4141
</SocialAuthContainer>
4242
<template v-else>
4343
<ForgottenPassword
44-
v-if="authView === 'forgotten_password'"
44+
v-if="authView === VIEWS.FORGOTTEN_PASSWORD"
4545
:supabaseClient="supabaseClient"
4646
:appearance="appearance"
4747
:redirectTo="redirectTo"
4848
:showLinks="showLinks"
4949
:i18n="i18n"
5050
/>
5151
<UpdatePassword
52-
v-if="authView === 'update_password'"
52+
v-if="authView === VIEWS.UPDATE_PASSWORD"
5353
:supabaseClient="supabaseClient"
5454
:appearance="appearance"
5555
:i18n="i18n"
5656
/>
5757
<VerifyOtp
58-
v-if="authView === 'verify_otp'"
58+
v-if="authView === VIEWS.VERIFY_OTP"
5959
:supabaseClient="supabaseClient"
6060
:appearance="appearance"
6161
:otpType="otpType"
6262
:i18n="i18n"
6363
/>
6464
<AnonymousAuth
65-
v-if="authView === 'anonymous_sign_in'"
65+
v-if="authView === VIEWS.ANONYMOUS_SIGN_IN"
6666
:supabaseClient="supabaseClient"
6767
:appearance="appearance"
6868
:i18n="i18n"
@@ -73,7 +73,7 @@
7373

7474
<script lang="ts" setup>
7575
import { provide, ref, watch, computed } from 'vue'
76-
import { I18nVariables, en, merge } from '@supabase/auth-ui-shared'
76+
import { I18nVariables, en, merge, VIEWS } from '@supabase/auth-ui-shared'
7777
import { createStitches } from '@stitches/core'
7878
import cloneDeep from 'lodash.clonedeep'
7979
import { colord } from 'colord'
@@ -92,7 +92,7 @@ import VerifyOtp from './VerifyOtp.vue'
9292
import AnonymousAuth from './AnonymousAuth.vue'
9393
9494
const props = withDefaults(defineProps<AuthProps>(), {
95-
view: 'sign_in',
95+
view: VIEWS.SIGN_IN,
9696
socialLayout: 'vertical',
9797
onlyThirdPartyProviders: false,
9898
magicLink: false,
@@ -131,9 +131,9 @@ const i18n = computed<I18nVariables>(() => {
131131
*/
132132
const isSignView = computed(() => {
133133
return (
134-
authView.value === 'sign_in' ||
135-
authView.value === 'sign_up' ||
136-
authView.value === 'magic_link'
134+
authView.value === VIEWS.SIGN_IN ||
135+
authView.value === VIEWS.SIGN_UP ||
136+
authView.value === VIEWS.MAGIC_LINK
137137
)
138138
})
139139
@@ -177,9 +177,9 @@ watch(
177177
const { data: authListener } = props.supabaseClient.auth.onAuthStateChange(
178178
(event) => {
179179
if (event === 'PASSWORD_RECOVERY') {
180-
setAuthView('update_password')
180+
setAuthView(VIEWS.UPDATE_PASSWORD)
181181
} else if (event === 'USER_UPDATED') {
182-
setAuthView('sign_in')
182+
setAuthView(VIEWS.SIGN_IN)
183183
}
184184
}
185185
)

packages/auth/MagicLink.vue

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@
88
}"
99
>
1010
<Container direction="vertical" gap="large" :appearance="appearance">
11-
<Container direction="vertical" gap="large" :appearance="appearance">
12-
<div>
13-
<Label htmlFor="email" :appearance="appearance">
14-
{{ labels?.email_input_label }}
15-
</Label>
16-
<Input
17-
id="email"
18-
type="email"
19-
name="email"
20-
autoComplete="email"
21-
autofocus
22-
:shape="appearance?.shape"
23-
:placeholder="labels?.email_input_placeholder"
24-
:appearance="appearance"
25-
v-model="email"
26-
/>
27-
</div>
28-
</Container>
11+
<div>
12+
<Label htmlFor="email" :appearance="appearance">
13+
{{ labels?.email_input_label }}
14+
</Label>
15+
<Input
16+
id="email"
17+
type="email"
18+
name="email"
19+
autoComplete="email"
20+
autofocus
21+
:shape="appearance?.shape"
22+
:placeholder="labels?.email_input_placeholder"
23+
:appearance="appearance"
24+
v-model="email"
25+
/>
26+
</div>
2927

3028
<Button
3129
type="submit"

src/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,15 @@
110110
:class="
111111
cn(
112112
`rounded-full border-${color}-500 text-brand-foreground bg-${color}-500/20 hover:bg-${color}-500/50`,
113-
authBrandColor === color &&
114-
`bg-${color}-500 border-${color}-800 dark:border-${color}-200 border-2`
113+
authBrandColor === color && `border-2`
115114
)
116115
"
116+
:style="{
117+
background: colord(colors[color]['500']).toRgbString(),
118+
borderColor: isDark
119+
? colord(colors[color]['200']).toRgbString()
120+
: colord(colors[color]['800']).toRgbString()
121+
}"
117122
@click="authBrandColor = color"
118123
/>
119124
</div>
@@ -280,6 +285,7 @@ const backgroundColor = computed(() => {
280285
const color = colors[authBrandColor.value]['500']
281286
return colord(color).alpha(opacity).toRgbString()
282287
})
288+
283289
const theme = computed(() => (isDark.value ? 'dark' : 'default'))
284290
const I18nVariables = computed(() => (locale.value === 'en-US' ? en : zh))
285291
const redirectTo = computed(() => {

0 commit comments

Comments
 (0)