Skip to content

Commit 8088f5e

Browse files
committed
feat: add shape variant
1 parent 317221c commit 8088f5e

File tree

15 files changed

+74
-41
lines changed

15 files changed

+74
-41
lines changed

packages/auth/AnonymousAuth.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
variant="brand"
1414
:loading="isLoading"
1515
:appearance="appearance"
16+
:shape="appearance?.shape"
1617
>
1718
{{ isLoading ? labels?.loading_button_label : labels?.button_label }}
1819
</Button>

packages/auth/Auth.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,12 @@ const theme = computed(() => {
147147
appearanceVariables?.[props?.theme] ?? {}
148148
)
149149
})
150-
createStitches({ theme: theme.value })
151150
watch(
152151
() => [props.appearance, props.theme],
153152
() => {
154153
createStitches({ theme: theme.value })
155154
},
156-
{ deep: true }
155+
{ deep: true, immediate: true }
157156
)
158157
159158
watch(
@@ -162,11 +161,11 @@ watch(
162161
const currentColor = colors[props.appearance?.brand ?? 'emerald']['500']
163162
const hlsColor = colord(currentColor).toHsl()
164163
document.documentElement.style.setProperty(
165-
'--brand',
164+
'--auth-ui-brand',
166165
`${hlsColor.h} ${hlsColor.s}% ${hlsColor.l}%`
167166
)
168167
},
169-
{ deep: true }
168+
{ deep: true, immediate: true }
170169
)
171170
172171
watch(

packages/auth/EmailAuth.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
type="email"
1919
name="email"
2020
v-model="email"
21+
:shape="appearance?.shape"
2122
:placeholder="labels?.email_input_placeholder"
2223
autoComplete="email"
2324
:appearance="appearance"
@@ -32,6 +33,7 @@
3233
type="password"
3334
name="password"
3435
v-model="password"
36+
:shape="appearance?.shape"
3537
:placeholder="labels?.password_input_placeholder"
3638
:autoComplete="
3739
authView === 'sign_in' ? 'current-password' : 'new-password'
@@ -44,6 +46,7 @@
4446
<Button
4547
type="submit"
4648
variant="brand"
49+
:shape="appearance?.shape"
4750
:loading="isLoading"
4851
:appearance="appearance"
4952
>

packages/auth/ForgottenPassword.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
name="email"
1919
autoComplete="email"
2020
autofocus
21+
:shape="appearance?.shape"
2122
:placeholder="labels?.email_input_placeholder"
2223
:appearance="appearance"
2324
v-model="email"
@@ -28,6 +29,7 @@
2829
type="submit"
2930
variant="brand"
3031
:loading="isLoading"
32+
:shape="appearance?.shape"
3133
:appearance="appearance"
3234
>
3335
{{ isLoading ? labels?.loading_button_label : labels?.button_label }}

packages/auth/MagicLink.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
name="email"
2020
autoComplete="email"
2121
autofocus
22+
:shape="appearance?.shape"
2223
:placeholder="labels?.email_input_placeholder"
2324
:appearance="appearance"
2425
v-model="email"
@@ -30,6 +31,7 @@
3031
type="submit"
3132
variant="brand"
3233
:loading="isLoading"
34+
:shape="appearance?.shape"
3335
:appearance="appearance"
3436
>
3537
{{ isLoading ? labels?.loading_button_label : labels?.button_label }}

packages/auth/SocialAuth.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<template v-for="provider in providers" :key="provider">
1010
<Button
1111
variant="outline"
12+
:shape="appearance?.shape"
1213
:loading="isLoading"
1314
:appearance="appearance"
1415
@click.prevent="() => handleProviderSignIn(provider)"

packages/auth/UpdatePassword.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
type="password"
1818
name="password"
1919
autofocus
20+
:shape="appearance?.shape"
2021
:placeholder="labels?.password_input_placeholder"
2122
:appearance="appearance"
2223
v-model="password"
@@ -28,6 +29,7 @@
2829
variant="brand"
2930
:loading="isLoading"
3031
:appearance="appearance"
32+
:shape="appearance?.shape"
3133
>
3234
{{ isLoading ? labels?.loading_button_label : labels?.button_label }}
3335
</Button>

packages/auth/VerifyOtp.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
name="phone"
1818
type="text"
1919
autofocus
20+
:shape="appearance?.shape"
2021
:placeholder="labels?.phone_input_placeholder"
2122
:appearance="appearance"
2223
v-model="phone"
@@ -32,6 +33,7 @@
3233
type="email"
3334
autoComplete="email"
3435
autofocus
36+
:shape="appearance?.shape"
3537
:placeholder="labels?.email_input_placeholder"
3638
:appearance="appearance"
3739
v-model="email"
@@ -46,6 +48,7 @@
4648
name="token"
4749
type="text"
4850
autofocus
51+
:shape="appearance?.shape"
4952
:placeholder="labels?.token_input_placeholder"
5053
:appearance="appearance"
5154
v-model="token"
@@ -57,6 +60,7 @@
5760
variant="brand"
5861
:loading="isLoading"
5962
:appearance="appearance"
63+
:shape="appearance?.shape"
6064
>
6165
{{ isLoading ? labels?.loading_button_label : labels?.button_label }}
6266
</Button>

packages/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import type {
1919

2020
export interface Appearance extends BaseAppearance {
2121
brand: keyof typeof colors
22+
size?: 'default' | 'sm' | 'md' | 'lg'
23+
shape: 'square' | 'rounded' | 'pill'
2224
style?: {
2325
anchor?: CSSProperties
2426
button?: CSSProperties

src/App.vue

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
</div>
3333
<h1 class="text-foreground text-2xl">Acme Industries</h1>
3434
</div>
35-
<p class="text-neutral-400 text-auth-widget-test">
35+
<p class="text-muted-foreground">
3636
Sign in today for Supa stuff
3737
</p>
3838
</div>
3939
<Auth
4040
:appearance="{
4141
theme: ThemeSupa,
42-
brand: brandColor
42+
brand: brandColor,
43+
shape: shape
4344
}"
4445
:supabaseClient="supabaseClient"
4546
v-model:view="view"
@@ -171,18 +172,18 @@
171172
</div>
172173
<div class="flex items-center gap-3">
173174
<ToggleButton
174-
v-model:selected="borderRadius"
175-
:defaultValue="radii[0]"
176-
class="rounded-xl border-b-0 border-l-0 bg-neutral-100 dark:bg-neutral-800"
175+
v-model:selected="shape"
176+
:defaultValue="shapeList[0]"
177+
class="rounded-none border-b-0 border-l-0 bg-neutral-100 dark:bg-neutral-800"
177178
/>
178179
<ToggleButton
179-
v-model:selected="borderRadius"
180-
:defaultValue="radii[1]"
180+
v-model:selected="shape"
181+
:defaultValue="shapeList[1]"
181182
class="rounded-xl border-b-0 border-l-0 bg-neutral-100 dark:bg-neutral-800"
182183
/>
183184
<ToggleButton
184-
v-model:selected="borderRadius"
185-
:defaultValue="radii[2]"
185+
v-model:selected="shape"
186+
:defaultValue="shapeList[2]"
186187
class="rounded-2xl border-b-0 border-l-0 bg-neutral-100 dark:bg-neutral-800"
187188
/>
188189
</div>
@@ -284,13 +285,12 @@ const { locale } = useI18n()
284285
const { en, zh } = useLanguage()
285286
286287
const classes: { [key: string]: string } = {
287-
emerald: 'container-greenshadow',
288-
violet: 'container-purpleshadow',
289-
fuchsia: 'container-pinkshadow',
290-
sky: 'container-blueshadow',
291-
amber: 'container-orangeshadow'
288+
emerald: 'container-emeraldshadow',
289+
violet: 'container-violetshadow',
290+
fuchsia: 'container-fuchsiashadow',
291+
sky: 'container-skyshadow',
292+
amber: 'container-ambershadow'
292293
}
293-
const radii = ['5px', '10px', '20px'] as const
294294
295295
const brandList: (keyof typeof colors)[] = [
296296
'emerald',
@@ -299,6 +299,7 @@ const brandList: (keyof typeof colors)[] = [
299299
'sky',
300300
'amber'
301301
]
302+
const shapeList = ['square', 'rounded', 'pill'] as const
302303
303304
const socialAlignments = ['horizontal', 'vertical'] as const
304305
@@ -313,7 +314,7 @@ const views: { id: AuthViewType; title: string }[] = [
313314
]
314315
315316
const brandColor = ref(brandList[0])
316-
const borderRadius = ref(radii[0])
317+
const shape = ref(shapeList[1])
317318
const socialLayout = ref(socialAlignments[0])
318319
const view = ref(views[0].id)
319320
@@ -351,43 +352,43 @@ watch(
351352
</script>
352353

353354
<style scoped>
354-
.container-purpleshadow {
355+
.container-violetshadow {
355356
box-shadow: 0px 0px 256px rgb(139, 92, 246, 0.3);
356357
}
357358
358-
.container-pinkshadow {
359+
.container-fuchsiashadow {
359360
box-shadow: 0px 0px 256px rgb(217, 70, 239, 0.3);
360361
}
361362
362-
.container-greenshadow {
363+
.container-emeraldshadow {
363364
box-shadow: 0px 0px 256px rgb(16, 185, 129, 0.3);
364365
}
365366
366-
.container-blueshadow {
367+
.container-skyshadow {
367368
box-shadow: 0px 0px 256px rgb(14, 165, 233, 0.3);
368369
}
369370
370-
.container-orangeshadow {
371+
.container-ambershadow {
371372
box-shadow: 0px 0px 256px rgb(245, 158, 11, 0.3);
372373
}
373374
374-
.dark .container-purpleshadow {
375+
.dark .container-violetshadow {
375376
box-shadow: 0px 0px 256px rgb(139, 92, 246, 0.6);
376377
}
377378
378-
.dark .container-pinkshadow {
379+
.dark .container-fuchsiashadow {
379380
box-shadow: 0px 0px 256px rgb(217, 70, 239, 0.6);
380381
}
381382
382-
.dark .container-greenshadow {
383+
.dark .container-emeraldshadow {
383384
box-shadow: 0px 0px 256px rgb(16, 185, 129, 0.6);
384385
}
385386
386-
.dark .container-blueshadow {
387+
.dark .container-skyshadow {
387388
box-shadow: 0px 0px 256px rgb(14, 165, 233, 0.6);
388389
}
389390
390-
.dark .container-orangeshadow {
391+
.dark .container-ambershadow {
391392
box-shadow: 0px 0px 256px rgb(245, 158, 11, 0.6);
392393
}
393394
</style>

0 commit comments

Comments
 (0)