feat: added button styling and updated login layout

This commit is contained in:
Dominik 2025-04-19 01:24:28 +02:00 committed by SomeCodecat
parent d86c86e137
commit 77ef7038d2
9 changed files with 196 additions and 29 deletions

View file

@ -1,12 +1,32 @@
:root {
--background: #ffffff;
--foreground: #171717;
--foreground: #3a3a3a;
--neutral: #808080;
--primary-50: rgba(59, 130, 246, 0.5);
--primary-75: rgba(59, 130, 246, 0.75);
--primary-100: rgba(59, 130, 246, 1);
--warning-50: rgba(245, 158, 11, 0.5);
--warning-75: rgba(245, 158, 11, 0.75);
--warning-100: rgba(245, 158, 11, 1);
--success-50: rgba(22, 163, 74, 0.5);
--success-75: rgba(22, 163, 74, 0.75);
--success-100: rgba(22, 163, 74, 1);
--danger-50: rgba(220, 38, 38, 0.5);
--danger-75: rgba(220, 38, 38, 0.75);
--danger-100: rgba(220, 38, 38, 1);
--button-text-size: 18px;
}
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
--foreground: #e5e7eb;
}
}

View file

@ -1,20 +1,18 @@
import { auth } from '@/auth';
import SignIn from '@/components/user/signin-button';
import { SignOut } from '@/components/user/signout-button';
import Login from '@/components/user/login-button';
import { redirect } from 'next/navigation';
export default async function Login() {
export default async function LoginPage() {
const session = await auth();
if (session?.user) {
redirect('/');
}
return (
<div>
<h1>Login</h1>
{!session?.user ? (
<SignIn></SignIn>
) : (
<>
<h2>Hallo {session.user.name}</h2>
<SignOut></SignOut>
</>
)}
<Login provider='authentik' providerDisplayName='SSO' />
</div>
);
}

View file

@ -0,0 +1,54 @@
.button {
background-color: var(--color-50);
border-radius: 9999px;
padding: 10px 20px;
outline: none;
border: 2px solid var(--color-100);
transition: background-color 0.3s ease;
height: 50px;
}
.button:hover {
background-color: var(--color-75);
}
.button:active {
background-color: var(--color-100);
}
.button span {
color: var(--foreground);
font-size: var(--button-text-size);
font-weight: 600;
}
.icon {
display: grid;
grid-template-columns: 25px 1fr;
gap: 10px;
align-items: center;
}
.style_primary {
--color-50: var(--primary-50);
--color-75: var(--primary-75);
--color-100: var(--primary-100);
}
.style_warning {
--color-50: var(--warning-50);
--color-75: var(--warning-75);
--color-100: var(--warning-100);
}
.style_success {
--color-50: var(--success-50);
--color-75: var(--success-75);
--color-100: var(--success-100);
}
.style_danger {
--color-50: var(--danger-50);
--color-75: var(--danger-75);
--color-100: var(--danger-100);
}

39
src/components/Button.tsx Normal file
View file

@ -0,0 +1,39 @@
import style from './Button.module.css';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
export default function Button({
type,
children,
mode = 'primary',
icon,
}: {
type?: 'button' | 'submit' | 'reset';
children?: React.ReactNode;
mode?: 'primary' | 'warning' | 'success' | 'danger';
icon?: IconProp;
}) {
if (!icon) {
return (
<button
className={style.button + ' ' + style['style_' + mode]}
type={type}
>
<span>{children}</span>
</button>
);
} else {
return (
<button
className={
style.button + ' ' + style['style_' + mode] + ' ' + style['icon']
}
type={type}
>
<FontAwesomeIcon icon={icon} height={25} />
<span>{children}</span>
</button>
);
}
}

View file

@ -0,0 +1,24 @@
import { signIn } from '@/auth';
import Button from '../Button';
import { faOpenid } from '@fortawesome/free-brands-svg-icons';
export default function Login({
provider,
providerDisplayName,
}: {
provider: string;
providerDisplayName: string;
}) {
return (
<form
action={async () => {
'use server';
await signIn(provider);
}}
>
<Button type='submit' mode='warning' icon={faOpenid}>
Login with {providerDisplayName}
</Button>
</form>
);
}

View file

@ -1,6 +1,7 @@
import { signOut } from '@/auth';
import Button from '../Button';
export function SignOut() {
export function Logout() {
return (
<form
action={async () => {
@ -8,7 +9,7 @@ export function SignOut() {
await signOut();
}}
>
<button type='submit'>Sign Out</button>
<Button type='submit'>Sign Out</Button>
</form>
);
}

View file

@ -1,14 +0,0 @@
import { signIn } from '@/auth';
export default function SignIn() {
return (
<form
action={async () => {
'use server';
await signIn('authentik');
}}
>
<button type='submit'>Signin with Authentik</button>
</form>
);
}