From d631d8e0f1ba033db756a5117baf49f6663f63ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 12 Jul 2026 02:16:42 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=92=84=20add=20design=20system=20?= =?UTF-8?q?and=20shared=20UI=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - styles.css: design tokens and primitives, dark by default with a prefers-color-scheme light theme, no CSS framework - Layout: sidebar shell with navigation, user chip, and logout; collapses into a top bar on narrow screens in pure CSS - Feedback: shared error line, loading pulse, and empty state - Icons: inline aria-hidden stroke icons - ProfileFields: the personal-info inputs and FormData reader shared by the profile page and the admin per-user editor --- src/components/Feedback.tsx | 25 ++ src/components/Icons.tsx | 116 +++++ src/components/Layout.tsx | 84 ++++ src/components/ProfileFields.tsx | 71 +++ src/styles.css | 748 +++++++++++++++++++++++++++++++ 5 files changed, 1044 insertions(+) create mode 100644 src/components/Feedback.tsx create mode 100644 src/components/Icons.tsx create mode 100644 src/components/Layout.tsx create mode 100644 src/components/ProfileFields.tsx create mode 100644 src/styles.css diff --git a/src/components/Feedback.tsx b/src/components/Feedback.tsx new file mode 100644 index 0000000..b92268b --- /dev/null +++ b/src/components/Feedback.tsx @@ -0,0 +1,25 @@ +// Small shared feedback pieces: inline error line, loading pulse, empty state. + +import { Show, type JSX } from "solid-js"; + +export function ErrorLine(props: { error: string | null }) { + return ( + + + + ); +} + +export function Loading() { + return ( +
+ +
+ ); +} + +export function Empty(props: { children: JSX.Element }) { + return

{props.children}

; +} diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx new file mode 100644 index 0000000..e80b807 --- /dev/null +++ b/src/components/Icons.tsx @@ -0,0 +1,116 @@ +// Inline stroke icons (lucide-style paths), sized by the `.icon` class. +// Decorative only — every icon is aria-hidden; pair with text or a title. + +import type { JSX } from "solid-js"; + +function Svg(props: { children: JSX.Element }) { + return ( + + ); +} + +export const IconPlane = () => ( + + + + +); + +export const IconHome = () => ( + + + + +); + +export const IconNote = () => ( + + + + + +); + +export const IconCalendar = () => ( + + + + +); + +export const IconBook = () => ( + + + + +); + +export const IconClipboard = () => ( + + + + + +); + +export const IconChart = () => ( + + + + +); + +export const IconUsers = () => ( + + + + + + +); + +export const IconLogout = () => ( + + + + + +); + +export const IconPlus = () => ( + + + +); + +export const IconEdit = () => ( + + + +); + +export const IconTrash = () => ( + + + + + +); + +export const IconArrow = () => ( + + + + +); diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx new file mode 100644 index 0000000..fa323a4 --- /dev/null +++ b/src/components/Layout.tsx @@ -0,0 +1,84 @@ +// App shell: sidebar with navigation, user chip, and logout. Collapses into a +// top bar on narrow screens (pure CSS). Rendered only for authenticated routes. + +import { A, useNavigate } from "@solidjs/router"; +import { Show, type ParentProps } from "solid-js"; +import { useAuth } from "../lib/auth"; +import { + IconBook, + IconCalendar, + IconChart, + IconClipboard, + IconHome, + IconLogout, + IconNote, + IconPlane, + IconUsers, +} from "./Icons"; + +export function Layout(props: ParentProps) { + const { user, logout, can } = useAuth(); + const navigate = useNavigate(); + + const onLogout = async () => { + await logout(); + navigate("/login", { replace: true }); + }; + + return ( +
+ +
{props.children}
+
+ ); +} diff --git a/src/components/ProfileFields.tsx b/src/components/ProfileFields.tsx new file mode 100644 index 0000000..a81681f --- /dev/null +++ b/src/components/ProfileFields.tsx @@ -0,0 +1,71 @@ +// The five personal-info inputs plus the FormData → ProfilePatch reader, +// shared by the self-service profile page and the admin per-user editor. +// Submitting sends every field: what an input holds is what the server keeps, +// and an emptied input clears the field (the backend's "" semantics). + +import type { ProfilePatch } from "../lib/api"; +import { today } from "../lib/format"; +import { LIMITS, type User } from "../lib/types"; + +/** Matches the backend rule: optional leading +, separators, 7–15 digits. */ +const PHONE_PATTERN = "\\+?(?:[\\s()-]*\\d){7,15}[\\s()-]*"; + +export function profilePatch(form: HTMLFormElement): ProfilePatch { + const data = new FormData(form); + return { + name: String(data.get("name")), + surname: String(data.get("surname")), + email: String(data.get("email")), + phone: String(data.get("phone")), + birth_date: String(data.get("birth_date")), + }; +} + +export function ProfileFields(props: { user: User }) { + return ( + <> +
+ + +
+ +
+ + +
+ + ); +} diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..f1ca463 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,748 @@ +/* Design tokens + the primitives the app uses. Dark by default, light via + prefers-color-scheme. No framework — zero runtime style cost. */ + +:root { + --bg: #0a0d14; + --surface: #111622; + --surface-2: #19202e; + --surface-3: #202a3c; + --border: #232c3d; + --text: #e8ebf2; + --muted: #8b95a8; + --accent: #7c9aff; + --accent-2: #a78bfa; + --accent-strong: #5468f0; + --accent-2-strong: #7c5cf0; + --danger: #f27d7d; + --ok: #4ecf8a; + --warn: #e8b44f; + --radius: 14px; + --radius-sm: 9px; + --shadow: 0 1px 2px rgb(0 0 0 / 0.35); + --shadow-lg: 0 8px 24px -8px rgb(0 0 0 / 0.5); + --ring: color-mix(in srgb, var(--accent) 30%, transparent); +} + +@media (prefers-color-scheme: light) { + :root { + --bg: #f4f6fa; + --surface: #ffffff; + --surface-2: #eef1f7; + --surface-3: #e4e8f2; + --border: #dde2ec; + --text: #171c28; + --muted: #5f6879; + --accent: #4a5fd8; + --accent-2: #7c5cd8; + --accent-strong: #4a5fe0; + --accent-2-strong: #7250e0; + --danger: #d64545; + --ok: #1f9d5f; + --warn: #a87716; + --shadow: 0 1px 2px rgb(20 25 40 / 0.06); + --shadow-lg: 0 8px 24px -12px rgb(20 25 40 / 0.18); + } +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; + background: var(--bg); + color: var(--text); + font: + 15px/1.55 ui-sans-serif, + system-ui, + -apple-system, + "Segoe UI", + Roboto, + "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; +} + +/* Soft accent glow in the corners; sits behind everything. */ +body::before { + content: ""; + position: fixed; + inset: 0; + z-index: -1; + background: + radial-gradient( + 55rem 38rem at 88% -12%, + color-mix(in srgb, var(--accent) 8%, transparent), + transparent 65% + ), + radial-gradient( + 45rem 32rem at -8% 108%, + color-mix(in srgb, var(--accent-2) 6%, transparent), + transparent 65% + ); +} + +h1 { + font-size: 1.55rem; + letter-spacing: -0.02em; + margin: 0; +} +h2 { + font-size: 1.1rem; + letter-spacing: -0.01em; + margin: 0; +} +h3 { + font-size: 1rem; + margin: 0; +} +p { + margin: 0; +} +a { + color: var(--accent); + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +a:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; + border-radius: 4px; +} + +.icon { + width: 1.15em; + height: 1.15em; + flex-shrink: 0; +} + +/* --- app shell ----------------------------------------------------------- */ + +.shell { + display: flex; + min-height: 100dvh; +} + +.sidebar { + position: sticky; + top: 0; + align-self: flex-start; + display: flex; + flex-direction: column; + gap: 1.25rem; + width: 15rem; + height: 100dvh; + padding: 1.1rem 0.8rem; + background: color-mix(in srgb, var(--surface) 72%, transparent); + backdrop-filter: blur(14px); + border-right: 1px solid var(--border); +} + +.brand { + display: flex; + align-items: center; + gap: 0.6rem; + padding: 0.25rem 0.55rem; + font-size: 1.05rem; + font-weight: 700; + letter-spacing: -0.01em; + color: var(--text); +} +.brand:hover { + text-decoration: none; +} +.brand-mark { + display: grid; + place-items: center; + width: 2rem; + height: 2rem; + border-radius: 10px; + color: #fff; + background: linear-gradient(135deg, var(--accent-strong), var(--accent-2-strong)); + box-shadow: var(--shadow); +} +.brand-mark .icon { + width: 1.05rem; + height: 1.05rem; +} + +.sidebar nav { + display: flex; + flex-direction: column; + gap: 0.15rem; + flex: 1; +} + +.sidebar nav a, +.user-chip { + display: flex; + align-items: center; + gap: 0.65rem; + padding: 0.5rem 0.65rem; + border-radius: var(--radius-sm); + color: var(--muted); + font-weight: 500; + white-space: nowrap; + transition: + background 120ms, + color 120ms; +} +.sidebar nav a:hover { + color: var(--text); + background: var(--surface-2); + text-decoration: none; +} +.sidebar nav a.active { + color: var(--accent); + background: color-mix(in srgb, var(--accent) 11%, transparent); +} + +.sidebar-end { + display: flex; + align-items: center; + gap: 0.25rem; +} + +.user-chip { + flex: 1; + min-width: 0; + color: var(--text); +} +.user-chip:hover { + background: var(--surface-2); + text-decoration: none; +} +.user-meta { + display: flex; + flex-direction: column; + min-width: 0; + line-height: 1.25; +} +.user-meta strong { + font-size: 0.88rem; + font-weight: 600; + overflow: hidden; + text-overflow: ellipsis; +} +.user-meta span { + font-size: 0.72rem; + color: var(--muted); + text-transform: capitalize; +} + +.avatar { + display: grid; + place-items: center; + width: 2.1rem; + height: 2.1rem; + border-radius: 50%; + flex-shrink: 0; + color: #fff; + font-size: 0.9rem; + font-weight: 700; + text-transform: uppercase; + background: linear-gradient(135deg, var(--accent-strong), var(--accent-2-strong)); +} +.avatar-lg { + width: 3.25rem; + height: 3.25rem; + font-size: 1.35rem; +} + +main { + flex: 1; + width: 100%; + max-width: 66rem; + margin: 0 auto; + padding: 2.2rem 2.2rem 5rem; + min-width: 0; +} + +@media (max-width: 860px) { + .shell { + flex-direction: column; + } + .sidebar { + flex-direction: row; + align-items: center; + gap: 0.6rem; + width: 100%; + height: auto; + padding: 0.5rem 0.75rem; + border-right: none; + border-bottom: 1px solid var(--border); + z-index: 10; + } + .brand span { + display: none; + } + .sidebar nav { + flex-direction: row; + overflow-x: auto; + scrollbar-width: none; + padding: 0.25rem 0; + } + .sidebar nav::-webkit-scrollbar { + display: none; + } + .sidebar nav a { + padding: 0.4rem 0.6rem; + } + .user-meta { + display: none; + } + .user-chip { + flex: none; + padding: 0.25rem; + border-radius: 50%; + } + main { + padding: 1.4rem 1rem 4rem; + } +} + +/* --- page scaffolding ------------------------------------------------------ */ + +.page { + display: flex; + flex-direction: column; + gap: 1.15rem; +} + +.page-head { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 1rem; + flex-wrap: wrap; + margin-bottom: 0.35rem; +} +.page-head .sub { + margin-top: 0.3rem; + color: var(--muted); + font-size: 0.92rem; +} + +.stack { + display: flex; + flex-direction: column; + gap: 0.75rem; +} +.stack-lg { + display: flex; + flex-direction: column; + gap: 2.25rem; +} + +.row { + display: flex; + gap: 0.75rem; + align-items: center; + flex-wrap: wrap; +} +.row > h1, +.row > h3 { + flex: 1; +} + +.row-actions { + display: flex; + gap: 0.5rem; + align-items: center; + flex-wrap: wrap; +} + +.grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); + gap: 0.9rem; +} + +.cols { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 2rem; + align-items: start; +} +@media (max-width: 720px) { + .cols { + grid-template-columns: 1fr; + } +} + +.section-head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 1rem; +} +.section-head a { + font-size: 0.85rem; + font-weight: 500; +} + +/* --- cards ------------------------------------------------------------------ */ + +.card { + background: var(--surface); + border: 1px solid var(--border); + border-radius: var(--radius); + padding: 1.1rem 1.2rem; + box-shadow: var(--shadow); +} + +.link-card { + display: block; + color: inherit; + transition: + border-color 140ms, + translate 140ms, + box-shadow 140ms; +} +.link-card:hover { + text-decoration: none; + border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); + translate: 0 -2px; + box-shadow: var(--shadow-lg); +} + +/* --- stat tiles --------------------------------------------------------------- */ + +.stats { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 0.9rem; +} +.stat { + display: flex; + flex-direction: column; + gap: 0.15rem; +} +.stat-label { + display: flex; + align-items: center; + gap: 0.45rem; + font-size: 0.82rem; + color: var(--muted); +} +.stat-label .icon { + color: var(--accent); +} +.stat-value { + font-size: 1.75rem; + font-weight: 600; + letter-spacing: -0.02em; + line-height: 1.2; +} +.stat-value small { + font-size: 0.95rem; + font-weight: 500; + color: var(--muted); +} + +/* --- forms ---------------------------------------------------------------- */ + +label { + display: flex; + flex-direction: column; + gap: 0.3rem; + font-size: 0.85rem; + font-weight: 500; + color: var(--muted); +} + +input, +textarea, +select { + font: inherit; + color: var(--text); + background: var(--surface-2); + border: 1px solid var(--border); + border-radius: var(--radius-sm); + padding: 0.5rem 0.75rem; + transition: + border-color 120ms, + box-shadow 120ms; +} +input:focus-visible, +textarea:focus-visible, +select:focus-visible { + outline: none; + border-color: var(--accent); + box-shadow: 0 0 0 3px var(--ring); +} +textarea { + resize: vertical; +} +::placeholder { + color: color-mix(in srgb, var(--muted) 75%, transparent); +} + +button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.45rem; + font: inherit; + font-weight: 600; + color: #fff; + background: linear-gradient(135deg, var(--accent-strong), var(--accent-2-strong)); + border: 1px solid transparent; + border-radius: var(--radius-sm); + padding: 0.5rem 0.95rem; + cursor: pointer; + transition: + filter 100ms, + scale 100ms; +} +button:hover:not(:disabled) { + filter: brightness(1.08); +} +button:active:not(:disabled) { + scale: 0.98; +} +button:disabled { + opacity: 0.55; + cursor: default; +} +button:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +button.ghost { + color: var(--text); + background: transparent; + border-color: var(--border); + font-weight: 500; +} +button.ghost:hover:not(:disabled) { + background: var(--surface-2); + filter: none; +} +button.danger { + color: var(--danger); +} +button.danger:hover:not(:disabled) { + border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); + background: color-mix(in srgb, var(--danger) 9%, transparent); +} + +button.icon-btn { + padding: 0.45rem; + border-radius: var(--radius-sm); +} + +/* --- tables ---------------------------------------------------------------- */ + +.table-wrap { + overflow-x: auto; + background: var(--surface); + border: 1px solid var(--border); + border-radius: var(--radius); + box-shadow: var(--shadow); +} + +table { + width: 100%; + border-collapse: collapse; +} +th, +td { + text-align: left; + padding: 0.6rem 0.9rem; + border-bottom: 1px solid var(--border); +} +th { + font-size: 0.75rem; + text-transform: uppercase; + letter-spacing: 0.07em; + color: var(--muted); + background: color-mix(in srgb, var(--surface-2) 55%, transparent); +} +tbody tr { + transition: background 100ms; +} +tbody tr:hover { + background: color-mix(in srgb, var(--surface-2) 45%, transparent); +} +tr:last-child td { + border-bottom: none; +} +td .mono { + font-size: 0.78rem; +} + +/* --- bits ------------------------------------------------------------------ */ + +.badge { + display: inline-flex; + align-items: center; + padding: 0.12rem 0.6rem; + border-radius: 999px; + font-size: 0.73rem; + font-weight: 600; + color: var(--accent); + background: color-mix(in srgb, var(--accent) 12%, transparent); + border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); + text-transform: uppercase; + letter-spacing: 0.04em; + white-space: nowrap; +} +.badge-present { + color: var(--ok); + background: color-mix(in srgb, var(--ok) 12%, transparent); + border-color: color-mix(in srgb, var(--ok) 25%, transparent); +} +.badge-absent { + color: var(--danger); + background: color-mix(in srgb, var(--danger) 12%, transparent); + border-color: color-mix(in srgb, var(--danger) 25%, transparent); +} +.badge-late { + color: var(--warn); + background: color-mix(in srgb, var(--warn) 12%, transparent); + border-color: color-mix(in srgb, var(--warn) 25%, transparent); +} +.badge-excused { + color: var(--muted); + background: color-mix(in srgb, var(--muted) 12%, transparent); + border-color: color-mix(in srgb, var(--muted) 25%, transparent); +} + +.gap-top { + margin-top: 1.5rem; +} +.push { + margin-left: auto; +} + +.muted { + color: var(--muted); +} +.meta { + color: var(--muted); + font-size: 0.85rem; +} +.mono { + font-family: ui-monospace, "JetBrains Mono", monospace; + font-size: 0.82rem; +} +.prewrap { + white-space: pre-wrap; + overflow-wrap: anywhere; +} +.clamp { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; +} + +.mark { + font-size: 2.1rem; + font-weight: 650; + letter-spacing: -0.02em; +} +.mark small { + font-size: 1rem; + font-weight: 500; + color: var(--muted); +} + +.error { + color: var(--danger); + font-size: 0.9rem; +} + +.empty { + color: var(--muted); + padding: 2rem 1rem; + text-align: center; + border: 1px dashed var(--border); + border-radius: var(--radius); +} + +/* --- loading pulse ----------------------------------------------------------- */ + +.loading { + display: flex; + gap: 0.4rem; + justify-content: center; + padding: 2.5rem 0; +} +.loading span { + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--accent); + animation: pulse 900ms ease-in-out infinite; +} +.loading span:nth-child(2) { + animation-delay: 150ms; +} +.loading span:nth-child(3) { + animation-delay: 300ms; +} + +@keyframes pulse { + 0%, + 100% { + opacity: 0.25; + scale: 0.8; + } + 50% { + opacity: 1; + scale: 1; + } +} + +@media (prefers-reduced-motion: reduce) { + .loading span { + animation: none; + } + .link-card, + button { + transition: none; + } +} + +/* --- auth page ----------------------------------------------------------------- */ + +.auth-page { + min-height: 100dvh; + display: grid; + place-items: center; + padding: 1rem; +} + +.auth-card { + width: min(370px, 100%); + display: flex; + flex-direction: column; + gap: 0.9rem; + padding: 2rem 1.75rem; +} +.auth-head { + display: flex; + flex-direction: column; + align-items: center; + gap: 0.65rem; + margin-bottom: 0.5rem; + text-align: center; +} +.auth-head .brand-mark { + width: 2.75rem; + height: 2.75rem; + border-radius: 13px; +} +.auth-head .brand-mark .icon { + width: 1.4rem; + height: 1.4rem; +} +.auth-head p { + color: var(--muted); + font-size: 0.88rem; +}