style: apply prettier formatting to all files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,163 +1,163 @@
|
||||
<script lang="ts">
|
||||
import { _ } from "svelte-i18n";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "$lib/components/ui/card";
|
||||
import { Input } from "$lib/components/ui/input";
|
||||
import { Label } from "$lib/components/ui/label";
|
||||
import * as Alert from "$lib/components/ui/alert";
|
||||
import { goto } from "$app/navigation";
|
||||
import { login } from "$lib/services";
|
||||
import { onMount } from "svelte";
|
||||
import PeonyBackground from "$lib/components/background/peony-background.svelte";
|
||||
import Meta from "$lib/components/meta/meta.svelte";
|
||||
import Logo from "$lib/components/logo/logo.svelte";
|
||||
import { _ } from "svelte-i18n";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "$lib/components/ui/card";
|
||||
import { Input } from "$lib/components/ui/input";
|
||||
import { Label } from "$lib/components/ui/label";
|
||||
import * as Alert from "$lib/components/ui/alert";
|
||||
import { goto } from "$app/navigation";
|
||||
import { login } from "$lib/services";
|
||||
import { onMount } from "svelte";
|
||||
import PeonyBackground from "$lib/components/background/peony-background.svelte";
|
||||
import Meta from "$lib/components/meta/meta.svelte";
|
||||
import Logo from "$lib/components/logo/logo.svelte";
|
||||
|
||||
let email = $state("");
|
||||
let password = $state("");
|
||||
let error = $state("");
|
||||
let showPassword = $state(false);
|
||||
let _rememberMe = $state(false);
|
||||
let isLoading = $state(false);
|
||||
let isError = $state(false);
|
||||
let email = $state("");
|
||||
let password = $state("");
|
||||
let error = $state("");
|
||||
let showPassword = $state(false);
|
||||
let _rememberMe = $state(false);
|
||||
let isLoading = $state(false);
|
||||
let isError = $state(false);
|
||||
|
||||
async function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
await login(email, password);
|
||||
goto("/videos", { invalidateAll: true });
|
||||
} catch (err: any) {
|
||||
error = err.message;
|
||||
isError = true;
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
async function handleSubmit(e: Event) {
|
||||
e.preventDefault();
|
||||
try {
|
||||
await login(email, password);
|
||||
goto("/videos", { invalidateAll: true });
|
||||
} catch (err: any) {
|
||||
error = err.message;
|
||||
isError = true;
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
const { data } = $props();
|
||||
const { data } = $props();
|
||||
|
||||
onMount(() => {
|
||||
if (!data.authStatus.authenticated) {
|
||||
return;
|
||||
}
|
||||
goto("/me");
|
||||
});
|
||||
onMount(() => {
|
||||
if (!data.authStatus.authenticated) {
|
||||
return;
|
||||
}
|
||||
goto("/me");
|
||||
});
|
||||
</script>
|
||||
|
||||
<Meta title={$_("auth.login.title")} description={$_("auth.login.description")} />
|
||||
|
||||
<div
|
||||
class="relative min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 via-accent/5 to-background p-4 overflow-hidden"
|
||||
class="relative min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 via-accent/5 to-background p-4 overflow-hidden"
|
||||
>
|
||||
<PeonyBackground />
|
||||
<PeonyBackground />
|
||||
|
||||
<div class="w-full max-w-md">
|
||||
<!-- Logo -->
|
||||
<div class="text-center mb-8">
|
||||
<div class="flex items-center justify-center gap-3 text-2xl font-bold mb-2">
|
||||
|
||||
<Logo />
|
||||
<div class="w-full max-w-md">
|
||||
<!-- Logo -->
|
||||
<div class="text-center mb-8">
|
||||
<div class="flex items-center justify-center gap-3 text-2xl font-bold mb-2">
|
||||
<Logo />
|
||||
</div>
|
||||
<p class="text-muted-foreground">{$_("auth.login.welcome")}</p>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
class="bg-gradient-to-br from-card/85 via-card/90 to-card/80 backdrop-blur-xl shadow-2xl shadow-primary/20"
|
||||
>
|
||||
<CardHeader class="text-center">
|
||||
<CardTitle class="text-2xl">{$_("auth.login.title")}</CardTitle>
|
||||
<CardDescription>{$_("auth.login.description")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="space-y-6">
|
||||
<form onsubmit={handleSubmit} class="space-y-4">
|
||||
<!-- Email -->
|
||||
<div class="space-y-2">
|
||||
<Label for="email">{$_("auth.login.email")}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder={$_("auth.login.email_placeholder")}
|
||||
bind:value={email}
|
||||
required
|
||||
class="bg-background/50 border-primary/20 focus:border-primary"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="space-y-2">
|
||||
<Label for="password">{$_("auth.login.password")}</Label>
|
||||
<div class="relative">
|
||||
<Input
|
||||
id="password"
|
||||
type={showPassword ? "text" : "password"}
|
||||
placeholder={$_("auth.login.password_placeholder")}
|
||||
bind:value={password}
|
||||
required
|
||||
class="bg-background/50 border-primary/20 focus:border-primary pr-10"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (showPassword = !showPassword)}
|
||||
class="cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{#if showPassword}
|
||||
<span class="icon-[ri--eye-off-line] w-4 h-4"></span>
|
||||
{:else}
|
||||
<span class="icon-[ri--eye-line] w-4 h-4"></span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-muted-foreground">{$_("auth.login.welcome")}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
class="bg-gradient-to-br from-card/85 via-card/90 to-card/80 backdrop-blur-xl shadow-2xl shadow-primary/20"
|
||||
>
|
||||
<CardHeader class="text-center">
|
||||
<CardTitle class="text-2xl">{$_("auth.login.title")}</CardTitle>
|
||||
<CardDescription>{$_("auth.login.description")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="space-y-6">
|
||||
<form onsubmit={handleSubmit} class="space-y-4">
|
||||
<!-- Email -->
|
||||
<div class="space-y-2">
|
||||
<Label for="email">{$_("auth.login.email")}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder={$_("auth.login.email_placeholder")}
|
||||
bind:value={email}
|
||||
required
|
||||
class="bg-background/50 border-primary/20 focus:border-primary"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="space-y-2">
|
||||
<Label for="password">{$_("auth.login.password")}</Label>
|
||||
<div class="relative">
|
||||
<Input
|
||||
id="password"
|
||||
type={showPassword ? "text" : "password"}
|
||||
placeholder={$_("auth.login.password_placeholder")}
|
||||
bind:value={password}
|
||||
required
|
||||
class="bg-background/50 border-primary/20 focus:border-primary pr-10"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (showPassword = !showPassword)}
|
||||
class="cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{#if showPassword}
|
||||
<span class="icon-[ri--eye-off-line] w-4 h-4"></span>
|
||||
{:else}
|
||||
<span class="icon-[ri--eye-line] w-4 h-4"></span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Remember Me & Forgot Password -->
|
||||
<div class="flex items-center justify-between">
|
||||
<!-- <div class="flex items-center space-x-2">
|
||||
<!-- Remember Me & Forgot Password -->
|
||||
<div class="flex items-center justify-between">
|
||||
<!-- <div class="flex items-center space-x-2">
|
||||
<Checkbox id="remember" bind:checked={rememberMe} />
|
||||
<Label for="remember" class="text-sm"
|
||||
>{$_("auth.login.remember_me")}</Label
|
||||
>
|
||||
</div> -->
|
||||
<a href="/password" class="text-sm text-primary hover:underline"
|
||||
>{$_("auth.login.forgot_password")}</a
|
||||
>
|
||||
</div>
|
||||
<a href="/password" class="text-sm text-primary hover:underline"
|
||||
>{$_("auth.login.forgot_password")}</a
|
||||
>
|
||||
</div>
|
||||
|
||||
{#if isError}
|
||||
<div class="grid w-full max-w-xl items-start gap-4">
|
||||
<Alert.Root variant="destructive">
|
||||
<Alert.Title class="items-center flex"
|
||||
><span class="icon-[ri--alert-line] inline-block w-4 h-4 mr-1"
|
||||
></span>{$_("auth.login.error")}</Alert.Title
|
||||
>
|
||||
<Alert.Description>{error}</Alert.Description>
|
||||
</Alert.Root>
|
||||
</div>
|
||||
{/if}
|
||||
{#if isError}
|
||||
<div class="grid w-full max-w-xl items-start gap-4">
|
||||
<Alert.Root variant="destructive">
|
||||
<Alert.Title class="items-center flex"
|
||||
><span class="icon-[ri--alert-line] inline-block w-4 h-4 mr-1"></span>{$_(
|
||||
"auth.login.error",
|
||||
)}</Alert.Title
|
||||
>
|
||||
<Alert.Description>{error}</Alert.Description>
|
||||
</Alert.Root>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Submit Button -->
|
||||
<Button
|
||||
type="submit"
|
||||
class="cursor-pointer w-full bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{#if isLoading}
|
||||
<div
|
||||
class="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin mr-2"
|
||||
></div>
|
||||
{$_("auth.login.signing_in")}
|
||||
{:else}
|
||||
{$_("auth.login.sign_in")}
|
||||
{/if}
|
||||
</Button>
|
||||
</form>
|
||||
<!-- Submit Button -->
|
||||
<Button
|
||||
type="submit"
|
||||
class="cursor-pointer w-full bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{#if isLoading}
|
||||
<div
|
||||
class="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin mr-2"
|
||||
></div>
|
||||
{$_("auth.login.signing_in")}
|
||||
{:else}
|
||||
{$_("auth.login.sign_in")}
|
||||
{/if}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<!-- Divider -->
|
||||
<!-- <div class="relative">
|
||||
<!-- Divider -->
|
||||
<!-- <div class="relative">
|
||||
<div class="absolute inset-0 flex items-center">
|
||||
<div class="w-full border-t border-border/50"></div>
|
||||
</div>
|
||||
@@ -168,8 +168,8 @@ onMount(() => {
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- Social Login -->
|
||||
<!-- <div class="grid grid-cols-2 gap-4">
|
||||
<!-- Social Login -->
|
||||
<!-- <div class="grid grid-cols-2 gap-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
class="border-primary/20 hover:bg-primary/10"
|
||||
@@ -207,16 +207,16 @@ onMount(() => {
|
||||
</Button>
|
||||
</div> -->
|
||||
|
||||
<!-- Sign Up Link -->
|
||||
<div class="text-center">
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{$_("auth.login.no_account")}
|
||||
<a href="/signup" class="text-primary hover:underline font-medium"
|
||||
>{$_("auth.login.sign_up_link")}</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<!-- Sign Up Link -->
|
||||
<div class="text-center">
|
||||
<p class="text-sm text-muted-foreground">
|
||||
{$_("auth.login.no_account")}
|
||||
<a href="/signup" class="text-primary hover:underline font-medium"
|
||||
>{$_("auth.login.sign_up_link")}</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user