Created some base components
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { apiPost } from '../../api/api';
|
||||
import '../../components/auth-card';
|
||||
import '../../components/form-input';
|
||||
import '../../components/ui-button';
|
||||
import '../../components/notify-bar';
|
||||
import '../../components/horizontal-divider';
|
||||
import '../../components/ui-link';
|
||||
|
||||
@customElement('login-page')
|
||||
@@ -9,139 +14,6 @@ export class LoginPage extends LitElement {
|
||||
:host {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background:
|
||||
radial-gradient(
|
||||
ellipse at 30% 20%,
|
||||
color-mix(in srgb, var(--color-accent) 15%, transparent) 0%,
|
||||
transparent 50%
|
||||
),
|
||||
radial-gradient(
|
||||
ellipse at 70% 80%,
|
||||
color-mix(in srgb, var(--color-accent) 10%, transparent) 0%,
|
||||
transparent 50%
|
||||
),
|
||||
var(--color-bg);
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
background: var(--color-bg-nav);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 1rem;
|
||||
padding: 2.5rem 2rem 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
box-shadow:
|
||||
0 1px 3px rgba(0, 0, 0, 0.08),
|
||||
0 12px 40px rgba(0, 0, 0, 0.12);
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.header p {
|
||||
margin: 0;
|
||||
font-size: 0.875rem;
|
||||
color: color-mix(in srgb, var(--color-text) 60%, transparent);
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
color: color-mix(in srgb, var(--color-text) 70%, transparent);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.65rem 0.75rem;
|
||||
font-size: 0.95rem;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
outline: none;
|
||||
transition:
|
||||
border-color 0.25s ease,
|
||||
box-shadow 0.25s ease;
|
||||
}
|
||||
|
||||
input::placeholder {
|
||||
color: color-mix(in srgb, var(--color-text) 35%, transparent);
|
||||
}
|
||||
|
||||
input:focus {
|
||||
border-color: var(--color-accent);
|
||||
box-shadow: 0 0 0 3px
|
||||
color-mix(in srgb, var(--color-accent) 15%, transparent);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #e5484d;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
padding: 0.5rem 0.75rem;
|
||||
background: color-mix(in srgb, #e5484d 8%, transparent);
|
||||
border: 1px solid color-mix(in srgb, #e5484d 25%, transparent);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 0.25rem;
|
||||
width: 100%;
|
||||
padding: 0.7rem 1rem;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
color: #fff;
|
||||
background: var(--color-accent);
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.25s ease,
|
||||
box-shadow 0.25s ease,
|
||||
transform 0.15s ease,
|
||||
opacity 0.25s ease;
|
||||
}
|
||||
|
||||
button:hover:not(:disabled) {
|
||||
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
||||
box-shadow: 0 4px 14px
|
||||
color-mix(in srgb, var(--color-accent) 35%, transparent);
|
||||
}
|
||||
|
||||
button:active:not(:disabled) {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.footer {
|
||||
@@ -150,13 +22,6 @@ export class LoginPage extends LitElement {
|
||||
color: color-mix(in srgb, var(--color-text) 60%, transparent);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.divider {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: var(--color-border);
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
`;
|
||||
|
||||
@state() email = '';
|
||||
@@ -188,52 +53,48 @@ export class LoginPage extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private handleKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Enter') this.handleLogin();
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<div class="card">
|
||||
<div class="header">
|
||||
<h2>Welcome back</h2>
|
||||
<p>Sign in to your FlightScore account</p>
|
||||
</div>
|
||||
<auth-card
|
||||
heading="Welcome back"
|
||||
subheading="Sign in to your FlightScore account"
|
||||
>
|
||||
<form-input
|
||||
label="Email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
.value=${this.email}
|
||||
@value-changed=${(e: CustomEvent) =>
|
||||
(this.email = e.detail.value)}
|
||||
></form-input>
|
||||
|
||||
<div class="field">
|
||||
<label>Email</label>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
.value=${this.email}
|
||||
@input=${(e: any) => (this.email = e.target.value)}
|
||||
@keydown=${this.handleKeydown}
|
||||
/>
|
||||
</div>
|
||||
<form-input
|
||||
label="Password"
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
.value=${this.password}
|
||||
@value-changed=${(e: CustomEvent) =>
|
||||
(this.password = e.detail.value)}
|
||||
></form-input>
|
||||
|
||||
<div class="field">
|
||||
<label>Password</label>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
.value=${this.password}
|
||||
@input=${(e: any) => (this.password = e.target.value)}
|
||||
@keydown=${this.handleKeydown}
|
||||
/>
|
||||
</div>
|
||||
<notify-bar type="error" .message=${this.error}></notify-bar>
|
||||
|
||||
${this.error ? html`<div class="error">${this.error}</div>` : null}
|
||||
|
||||
<button ?disabled=${this.loading} @click=${this.handleLogin}>
|
||||
<ui-button
|
||||
full
|
||||
?disabled=${this.loading}
|
||||
@click=${this.handleLogin}
|
||||
>
|
||||
${this.loading ? 'Signing in...' : 'Sign in'}
|
||||
</button>
|
||||
</ui-button>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<horizontal-divider></horizontal-divider>
|
||||
|
||||
<p class="footer">
|
||||
No account? <ui-link href="/register">Create one</ui-link>
|
||||
No account?
|
||||
<ui-link href="/register">Create one</ui-link>
|
||||
</p>
|
||||
</div>
|
||||
</auth-card>
|
||||
`;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,26 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { apiPost } from '../../api/api';
|
||||
import '../../components/auth-card.ts';
|
||||
import '../../components/form-input.ts';
|
||||
import '../../components/ui-button';
|
||||
import '../../components/notify-bar.ts';
|
||||
import '../../components/horizontal-divider';
|
||||
import '../../components/ui-link';
|
||||
|
||||
@customElement('register-page')
|
||||
export class RegisterPage extends LitElement {
|
||||
static styles = css`
|
||||
:host {
|
||||
flex: 1;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--color-accent),
|
||||
color-mix(in srgb, var(--color-accent) 30%, black)
|
||||
);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form {
|
||||
width: 100%;
|
||||
max-width: 380px;
|
||||
background: var(--color-bg-nav);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
input {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
padding: 0.6rem;
|
||||
font-size: 1rem;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
:host {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: crimson;
|
||||
font-size: 0.9rem;
|
||||
.footer {
|
||||
text-align: center;
|
||||
font-size: 0.875rem;
|
||||
color: color-mix(in srgb, var(--color-text) 60%, transparent);
|
||||
margin: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -57,7 +34,7 @@ export class RegisterPage extends LitElement {
|
||||
this.error = null;
|
||||
this.loading = true;
|
||||
try {
|
||||
const res = await apiPost<{ id: number; name: string; email: string }>(
|
||||
await apiPost<{ id: number; name: string; email: string }>(
|
||||
'/api/auth/register',
|
||||
{
|
||||
name: this.name,
|
||||
@@ -65,7 +42,6 @@ export class RegisterPage extends LitElement {
|
||||
password: this.password,
|
||||
}
|
||||
);
|
||||
console.log('Registered user:', res);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('nav', {
|
||||
detail: { path: '/login' },
|
||||
@@ -82,34 +58,53 @@ export class RegisterPage extends LitElement {
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<div class="form">
|
||||
<h2>Register</h2>
|
||||
<input
|
||||
placeholder="Full name"
|
||||
<auth-card
|
||||
heading="Create account"
|
||||
subheading="Get started with FlightScore"
|
||||
>
|
||||
<form-input
|
||||
label="Name"
|
||||
placeholder="Your full name"
|
||||
.value=${this.name}
|
||||
@input=${(e: any) => (this.name = e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="Email"
|
||||
.value=${this.email}
|
||||
@input=${(e: any) => (this.email = e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
.value=${this.password}
|
||||
@input=${(e: any) => (this.password = e.target.value)}
|
||||
/>
|
||||
@value-changed=${(e: CustomEvent) =>
|
||||
(this.name = e.detail.value)}
|
||||
></form-input>
|
||||
|
||||
${this.error ? html`<div class="error">${this.error}</div>` : null}
|
||||
<form-input
|
||||
label="Email"
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
.value=${this.email}
|
||||
@value-changed=${(e: CustomEvent) =>
|
||||
(this.email = e.detail.value)}
|
||||
></form-input>
|
||||
|
||||
<form-input
|
||||
label="Password"
|
||||
type="password"
|
||||
placeholder="Choose a password"
|
||||
.value=${this.password}
|
||||
@value-changed=${(e: CustomEvent) =>
|
||||
(this.password = e.detail.value)}
|
||||
></form-input>
|
||||
|
||||
<notify-bar type="error" .message=${this.error}></notify-bar>
|
||||
|
||||
<ui-button
|
||||
full
|
||||
?disabled=${this.loading}
|
||||
@click=${this.handleRegister}
|
||||
>${this.loading ? 'Loading...' : 'Register'}</ui-button
|
||||
>
|
||||
</div>
|
||||
${this.loading ? 'Creating account...' : 'Create account'}
|
||||
</ui-button>
|
||||
|
||||
<horizontal-divider></horizontal-divider>
|
||||
|
||||
<p class="footer">
|
||||
Already have an account?
|
||||
<ui-link href="/login">Sign in</ui-link>
|
||||
</p>
|
||||
</auth-card>
|
||||
`;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,123 @@
|
||||
import { LitElement, html, css } from 'lit';
|
||||
import { customElement } from 'lit/decorators.js';
|
||||
import '../components/card-backdrop';
|
||||
import '../components/ui-card';
|
||||
import '../components/horizontal-divider';
|
||||
import '../components/ui-button';
|
||||
|
||||
@customElement('not-found-page')
|
||||
export class NotFoundPage extends LitElement {
|
||||
static styles = css`
|
||||
div {
|
||||
padding-top: 4rem;
|
||||
* {
|
||||
width: fit-content;
|
||||
margin: auto auto;
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
:host {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
color: color-mix(in srgb, var(--color-text) 30%, transparent);
|
||||
}
|
||||
|
||||
.code {
|
||||
font-size: 5rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
line-height: 1;
|
||||
margin: 0;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--color-accent),
|
||||
color-mix(in srgb, var(--color-accent) 50%, transparent)
|
||||
);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1.35rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.6;
|
||||
color: color-mix(in srgb, var(--color-text) 55%, transparent);
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
padding: 0.6rem 1.25rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
background: var(--color-accent);
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.25s ease,
|
||||
box-shadow 0.25s ease,
|
||||
transform 0.15s ease;
|
||||
}
|
||||
|
||||
.back-btn:hover {
|
||||
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
||||
box-shadow: 0 4px 14px
|
||||
color-mix(in srgb, var(--color-accent) 35%, transparent);
|
||||
}
|
||||
|
||||
.back-btn:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.back-btn svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
}
|
||||
`;
|
||||
|
||||
navigate(path: string) {
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('nav', { detail: { path }, bubbles: true, composed: true })
|
||||
);
|
||||
}
|
||||
private navigate(path: string) {
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('nav', {
|
||||
detail: { path },
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<div>
|
||||
<h1>404 Not Found</h1>
|
||||
<p><ui-link href="/">Here</ui-link>you can get back.</p>
|
||||
</div>
|
||||
<card-backdrop>
|
||||
<ui-card centered>
|
||||
<p class="code">404</p>
|
||||
<h2>Page not found</h2>
|
||||
<p>
|
||||
The page you are looking for does not exist or has been
|
||||
moved.
|
||||
</p>
|
||||
|
||||
<horizontal-divider></horizontal-divider>
|
||||
|
||||
|
||||
<ui-button @click=${()=> this.navigate('/')}>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<line x1="19" y1="12" x2="5" y2="12"></line>
|
||||
<polyline points="12 19 5 12 12 5"></polyline>
|
||||
</svg>
|
||||
Back to home
|
||||
</ui-button>
|
||||
</ui-card>
|
||||
</card-backdrop>
|
||||
`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user