forge
Explore
Log in

Don't you dare go Hollow

♻️ side panel redesign, smart date picker positioning, form polish

Browse files at this commit

eafd591de4006332b3e1eb1fbe1ac915dea5887fBurak BoduroğluParent: 212dcef
  • refactor
    • ♻️ side panel redesign, smart date picker positioning, form polish
Show full message
refactor: ♻️ side panel redesign, smart date picker positioning, form polish
- redesign side panel as floating card (inset sm:right-3 sm:rounded-2xl, backdrop)
- add IconX close button with border/shadow, card-based header
- style side-panel-body form sections with card borders and sticky footer
- add smart fixed positioning to date picker (resize/scroll listeners)
- switch accent from blue (217) to teal-blue (204), bump radius to 0.75rem
- remove IconSave icon from event/exam submit buttons
- make exam form datetime grid single-column
src/components/events/event-form.tsxmodified+0 -2
@@ -4,7 +4,6 @@ import type { Event } from "@/api/types";
44 import { Button } from "@/components/ui/button";
55 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
66 import { DatePicker } from "@/components/ui/date-picker";
7-import { IconSave } from "@/components/ui/icons";
87 import { Input } from "@/components/ui/input";
98 import { Label } from "@/components/ui/label";
109 import { Textarea } from "@/components/ui/textarea";
@@ -217,7 +216,6 @@ export function EventForm(props: {
217216 {error() && <p class="text-sm text-destructive">{error()}</p>}
218217 <div class="flex flex-wrap items-center gap-2">
219218 <Button type="submit" class="h-10" disabled={pending()}>
220- <IconSave />
221219 {props.submitLabel ?? t("common.save")}
222220 </Button>
223221 {props.onCancel && (
src/components/exams/exam-form.tsxmodified+1 -3
@@ -7,7 +7,6 @@ import { EXAM_KINDS, EXAM_MODES } from "@/api/types";
77 import { Button } from "@/components/ui/button";
88 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
99 import { DatePicker } from "@/components/ui/date-picker";
10-import { IconSave } from "@/components/ui/icons";
1110 import { Input } from "@/components/ui/input";
1211 import { Label } from "@/components/ui/label";
1312 import { Select } from "@/components/ui/select";
@@ -264,7 +263,7 @@ export function ExamForm(props: {
264263 </Show>
265264 </div>
266265 <Show when={mode() === "sync" || mode() === "async"}>
267- <div class="grid gap-3 sm:grid-cols-2">
266+ <div class="grid gap-3">
268267 <div class="space-y-1.5">
269268 <Label for="exam-starts">{t("events.starts")}</Label>
270269 <div class="grid grid-cols-[minmax(0,1fr)_7rem] gap-2">
@@ -332,7 +331,6 @@ export function ExamForm(props: {
332331 {error() && <p class="text-sm text-destructive">{error()}</p>}
333332 <div class="flex flex-wrap items-center gap-2">
334333 <Button type="submit" disabled={pending()}>
335- <IconSave />
336334 {props.submitLabel ?? t("common.save")}
337335 </Button>
338336 {props.onCancel && (
src/components/ui/date-picker.tsxmodified+33 -7
@@ -49,6 +49,7 @@ export function DatePicker(props: {
4949 }) {
5050 let root: HTMLDivElement | undefined;
5151 const [open, setOpen] = createSignal(false);
52+ const [position, setPosition] = createSignal({ left: 0, top: 0, width: 288 });
5253 const selected = createMemo(() => parseDate(props.value));
5354 const [month, setMonth] = createSignal(selected() ?? new Date());
5455 const days = createMemo(() => monthDays(month()));
@@ -63,11 +64,33 @@ export function DatePicker(props: {
6364
6465 createEffect(() => {
6566 if (!open()) return;
67+ const updatePosition = () => {
68+ if (!root) return;
69+ const rect = root.getBoundingClientRect();
70+ const panelWidth = Math.min(288, Math.max(240, window.innerWidth - 24));
71+ const left = Math.min(Math.max(12, rect.left), window.innerWidth - panelWidth - 12);
72+ const estimatedHeight = 300;
73+ const viewportPadding = 12;
74+ const availableBelow = window.innerHeight - rect.bottom - viewportPadding;
75+ const availableAbove = rect.top - viewportPadding;
76+ const opensAbove = availableBelow < estimatedHeight && availableAbove > availableBelow;
77+ const rawTop = opensAbove ? rect.top - estimatedHeight - 8 : rect.bottom + 8;
78+ const maxTop = Math.max(viewportPadding, window.innerHeight - estimatedHeight - viewportPadding);
79+ const top = Math.min(Math.max(viewportPadding, rawTop), maxTop);
80+ setPosition({ left, top, width: panelWidth });
81+ };
82+ updatePosition();
6683 const closeOnOutside = (event: MouseEvent) => {
6784 if (root && !root.contains(event.target as Node)) setOpen(false);
6885 };
86+ window.addEventListener("resize", updatePosition);
87+ window.addEventListener("scroll", updatePosition, true);
6988 document.addEventListener("mousedown", closeOnOutside);
70- onCleanup(() => document.removeEventListener("mousedown", closeOnOutside));
89+ onCleanup(() => {
90+ window.removeEventListener("resize", updatePosition);
91+ window.removeEventListener("scroll", updatePosition, true);
92+ document.removeEventListener("mousedown", closeOnOutside);
93+ });
7194 });
7295
7396 const moveMonth = (delta: number) => {
@@ -97,13 +120,16 @@ export function DatePicker(props: {
97120 <IconCalendar class="pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
98121 </div>
99122 <Show when={open()}>
100- <div class="absolute z-50 mt-2 w-72 rounded-md border bg-popover p-3 text-popover-foreground shadow-lg">
123+ <div
124+ class="fixed z-[80] rounded-xl border border-border/80 bg-popover p-2.5 text-popover-foreground shadow-xl"
125+ style={{ left: `${position().left}px`, top: `${position().top}px`, width: `${position().width}px` }}
126+ >
101127 <div class="mb-3 flex items-center justify-between gap-2">
102- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 p-0" onClick={() => moveMonth(-1)}>
128+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={() => moveMonth(-1)}>
103129 <IconChevronLeft class="h-4 w-4" />
104130 </Button>
105- <p class="text-sm font-medium capitalize">{monthLabel()}</p>
106- <Button type="button" variant="ghost" size="sm" class="h-8 w-8 p-0" onClick={() => moveMonth(1)}>
131+ <p class="min-w-0 truncate px-2 text-sm font-semibold capitalize">{monthLabel()}</p>
132+ <Button type="button" variant="ghost" size="sm" class="h-8 w-8 rounded-lg p-0" onClick={() => moveMonth(1)}>
107133 <IconChevronRight class="h-4 w-4" />
108134 </Button>
109135 </div>
@@ -116,7 +142,7 @@ export function DatePicker(props: {
116142 <span>Cmt</span>
117143 <span>Paz</span>
118144 </div>
119- <div class="mt-1 grid grid-cols-7 gap-1">
145+ <div class="mt-1 grid grid-cols-7 gap-0.5">
120146 <For each={days()}>
121147 {(date) => (
122148 <Show when={date} fallback={<span class="h-8" />}>
@@ -125,7 +151,7 @@ export function DatePicker(props: {
125151 type="button"
126152 variant={sameDay(selected(), day()) ? "default" : "ghost"}
127153 size="sm"
128- class="h-8 rounded-sm p-0 text-xs"
154+ class="h-8 rounded-lg p-0 text-xs"
129155 onClick={() => pick(day())}
130156 >
131157 {day().getDate()}
src/components/ui/icons.tsxmodified+9 -0
@@ -52,6 +52,15 @@ export function IconCheck(props: IconProps) {
5252 );
5353 }
5454
55+export function IconX(props: IconProps) {
56+ return (
57+ <Svg {...props}>
58+ <path d="M18 6 6 18" />
59+ <path d="m6 6 12 12" />
60+ </Svg>
61+ );
62+}
63+
5564 export function IconAlert(props: IconProps) {
5665 return (
5766 <Svg {...props}>
src/components/ui/side-panel.tsxmodified+10 -9
@@ -1,5 +1,6 @@
11 import { Dialog as DialogPrimitive } from "@kobalte/core/dialog";
22 import type { ParentProps } from "solid-js";
3+import { IconX } from "@/components/ui/icons";
34 import { cn } from "@/lib/cn";
45
56 export function SidePanel(props: ParentProps<{
@@ -12,29 +13,29 @@ export function SidePanel(props: ParentProps<{
1213 return (
1314 <DialogPrimitive open={props.open} onOpenChange={props.onOpenChange}>
1415 <DialogPrimitive.Portal>
15- <DialogPrimitive.Overlay class="fixed inset-0 z-50 bg-black/35 backdrop-blur-[1px] dark:bg-black/60" />
16+ <DialogPrimitive.Overlay class="fixed inset-0 z-50 bg-black/25 backdrop-blur-[1px] dark:bg-black/55" />
1617 <DialogPrimitive.Content
1718 class={cn(
18- "fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-border bg-popover text-popover-foreground shadow-xl outline-none transition-transform duration-200",
19+ "fixed inset-y-0 right-0 z-50 flex w-full max-w-[34rem] flex-col border-l border-border/80 bg-background text-foreground shadow-[0_20px_70px_hsl(var(--foreground)/0.18)] outline-none transition-transform duration-200 sm:inset-y-3 sm:right-3 sm:rounded-2xl sm:border sm:border-border/80",
1920 props.class,
2021 )}
2122 >
22- <div class="flex items-start justify-between gap-4 border-b border-border px-5 py-4">
23- <div>
24- <DialogPrimitive.Title class="font-display text-lg font-semibold leading-none">
23+ <div class="flex items-start justify-between gap-4 border-b border-border/80 bg-card px-6 py-5 sm:rounded-t-2xl">
24+ <div class="min-w-0 space-y-1">
25+ <DialogPrimitive.Title class="truncate font-display text-base font-semibold leading-6 tracking-tight">
2526 {props.title}
2627 </DialogPrimitive.Title>
2728 {props.description && (
28- <DialogPrimitive.Description class="mt-1.5 text-sm text-muted-foreground">
29+ <DialogPrimitive.Description class="text-sm leading-5 text-muted-foreground">
2930 {props.description}
3031 </DialogPrimitive.Description>
3132 )}
3233 </div>
33- <DialogPrimitive.CloseButton class="rounded-sm px-2 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground">
34- ×
34+ <DialogPrimitive.CloseButton class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/80 bg-background text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
35+ <IconX class="h-4 w-4" />
3536 </DialogPrimitive.CloseButton>
3637 </div>
37- <div class="min-h-0 flex-1 overflow-y-auto px-5 py-4">{props.children}</div>
38+ <div class="side-panel-body min-h-0 flex-1 overflow-y-auto bg-muted/20 px-6 pt-5">{props.children}</div>
3839 </DialogPrimitive.Content>
3940 </DialogPrimitive.Portal>
4041 </DialogPrimitive>
src/index.cssmodified+40 -9
@@ -15,8 +15,8 @@
1515 --ui-text-1: 180 11% 7%;
1616 --ui-text-2: 180 6% 31%;
1717 --ui-text-3: 180 4% 49%;
18- --ui-accent: 217 91% 60%;
19- --ui-accent-muted: 214 95% 93%;
18+ --ui-accent: 204 86% 48%;
19+ --ui-accent-muted: 204 88% 91%;
2020 --ui-success: 142 72% 29%;
2121 --ui-success-muted: 138 76% 97%;
2222 --ui-warning: 32 95% 44%;
@@ -45,13 +45,13 @@
4545 --muted: var(--ui-surface-2);
4646 --muted-foreground: var(--ui-text-2);
4747 --accent: var(--ui-accent-muted);
48- --accent-foreground: 217 91% 28%;
48+ --accent-foreground: 204 86% 25%;
4949 --destructive: var(--ui-danger);
5050 --destructive-foreground: 0 0% 100%;
5151 --border: var(--ui-border-1);
5252 --input: var(--ui-border-1);
5353 --ring: var(--ui-accent);
54- --radius: 0.625rem;
54+ --radius: 0.75rem;
5555 --success: var(--ui-success);
5656 --warning: var(--ui-warning);
5757 --info: var(--ui-info);
@@ -70,8 +70,8 @@
7070 --ui-text-1: 180 14% 94%;
7171 --ui-text-2: 180 8% 67%;
7272 --ui-text-3: 190 6% 48%;
73- --ui-accent: 213 94% 68%;
74- --ui-accent-muted: 213 47% 17%;
73+ --ui-accent: 199 92% 62%;
74+ --ui-accent-muted: 199 48% 16%;
7575 --ui-success: 142 69% 58%;
7676 --ui-success-muted: 142 39% 10%;
7777 --ui-warning: 38 92% 50%;
@@ -81,7 +81,7 @@
8181 --ui-info: 199 89% 63%;
8282 --ui-info-muted: 200 50% 13%;
8383 --primary-foreground: 210 20% 98%;
84- --accent-foreground: 213 94% 86%;
84+ --accent-foreground: 199 92% 84%;
8585 --destructive-foreground: 0 0% 100%;
8686 }
8787
@@ -125,11 +125,11 @@
125125 }
126126
127127 .data-shell {
128- @apply rounded-lg border border-border bg-card;
128+ @apply rounded-xl border border-border bg-card;
129129 }
130130
131131 .data-table-wrap {
132- @apply max-h-[62vh] overflow-auto rounded-lg border border-border bg-card;
132+ @apply max-h-[62vh] overflow-auto rounded-xl border border-border bg-card;
133133 }
134134
135135 .data-table {
@@ -156,6 +156,37 @@
156156 background-color: hsl(var(--muted) / 0.28);
157157 }
158158
159+ .side-panel-body form {
160+ @apply space-y-5 pb-5;
161+ }
162+
163+ .side-panel-body form > .space-y-3,
164+ .side-panel-body form > .space-y-4,
165+ .side-panel-body form > .space-y-1\.5,
166+ .side-panel-body form > .grid {
167+ @apply rounded-xl border border-border/80 bg-card p-4 shadow-sm;
168+ }
169+
170+ .side-panel-body label {
171+ @apply text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground;
172+ }
173+
174+ .side-panel-body input,
175+ .side-panel-body textarea,
176+ .side-panel-body select {
177+ @apply rounded-lg bg-background/80;
178+ }
179+
180+ .side-panel-body form > .flex:last-child,
181+ .side-panel-body form > .flex.flex-wrap:last-child {
182+ @apply sticky bottom-0 -mx-6 justify-end border-t border-border/80 bg-background/95 px-6 py-3 shadow-[0_-16px_32px_hsl(var(--background)/0.9)];
183+ }
184+
185+ .side-panel-body form > .flex:last-child button,
186+ .side-panel-body form > .flex.flex-wrap:last-child button {
187+ @apply rounded-lg;
188+ }
189+
159190 .num,
160191 .mono {
161192 font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;