Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions client/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
import type { ButtonHTMLAttributes } from "react";
import { type ButtonHTMLAttributes } from "react";

type Variant = "primary" | "secondary" | "danger";
type Variant = "primary" | "secondary" | "ghost" | "danger";
type Size = "sm" | "md" | "lg";

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant;
size?: Size;
loading?: boolean;
}

export function Button({
variant = "primary",
size = "md",
loading,
className = "",
children,
disabled,
type = "button",
...props
}: ButtonProps) {
const base =
"inline-flex items-center justify-center gap-2 rounded-[10px] px-4 py-2.5 text-sm font-semibold transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50";
const variants: Record<Variant, string> = {
danger:
"border border-[rgba(239,68,68,0.3)] bg-[rgba(239,68,68,0.15)] text-[#F87171] hover:bg-[rgba(239,68,68,0.25)]",
primary: "glow-btn",
secondary:
"border border-[var(--border)] bg-[var(--bg-elevated)] text-[var(--text-primary)] hover:border-[var(--border-hover)] hover:bg-[var(--bg-hover)]",
danger: "btn btn-danger",
ghost: "btn btn-ghost",
primary: "btn btn-primary",
secondary: "btn btn-secondary",
};
const sizes: Record<Size, string> = {
lg: "btn-lg",
md: "",
sm: "btn-sm",
};

return (
<button className={`${base} ${variants[variant]} ${className}`} type={type} {...props}>
<button
className={`${variants[variant]} ${sizes[size]} ${className}`}
disabled={disabled || loading}
type={type}
{...props}
>
{loading ? (
<svg className="animate-spin" fill="none" height="13" viewBox="0 0 24 24" width="13">
<circle
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeDasharray="40 20"
strokeWidth="3"
/>
</svg>
) : null}
{children}
</button>
);
Expand Down
65 changes: 65 additions & 0 deletions client/src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { useEffect } from "react";

interface Props {
open: boolean;
title: string;
message: string;
confirmLabel?: string;
destructive?: boolean;
onConfirm: () => void;
onCancel: () => void;
}

export function ConfirmModal({
open,
title,
message,
confirmLabel = "Confirm",
destructive = false,
onConfirm,
onCancel,
}: Props) {
useEffect(() => {
if (!open) {
return;
}

const handler = (event: KeyboardEvent) => {
if (event.key === "Escape") {
onCancel();
}
};

document.addEventListener("keydown", handler);
return () => document.removeEventListener("keydown", handler);
}, [onCancel, open]);

if (!open) {
return null;
}

return (
<div className="modal-backdrop" onClick={onCancel}>
<div className="modal-box" onClick={(event) => event.stopPropagation()}>
<h3 style={{ color: "var(--text-1)", fontSize: 15, fontWeight: 600, marginBottom: 8 }}>
{title}
</h3>
<p style={{ color: "var(--text-2)", fontSize: 13, lineHeight: 1.6, marginBottom: 20 }}>
{message}
</p>
<div style={{ display: "flex", gap: 8, justifyContent: "flex-end" }}>
<button className="btn btn-secondary btn-sm" onClick={onCancel} type="button">
Cancel
</button>
<button
className={`btn btn-sm ${destructive ? "btn-danger" : "btn-primary"}`}
onClick={onConfirm}
type="button"
>
{confirmLabel}
</button>
</div>
</div>
</div>
);
}
37 changes: 12 additions & 25 deletions client/src/components/PlanBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
import type { HTMLAttributes } from "react";

import { normalizePlan } from "@/lib/plan";

type PlanBadgeProps = HTMLAttributes<HTMLSpanElement> & {
plan: string;
};

export function PlanBadge({ plan, className = "", ...props }: PlanBadgeProps) {
const normalizedPlan = normalizePlan(plan);
const isPro = normalizedPlan === "pro";
export function PlanBadge({ plan }: { plan: string }) {
const isPro = plan?.toLowerCase() === "pro";

return (
<span
className={`inline-flex items-center ${className}`}
style={{
background: isPro
? "linear-gradient(135deg, var(--accent), var(--accent-cyan))"
: "var(--bg-elevated)",
border: isPro ? "none" : "1px solid var(--border)",
borderRadius: 20,
boxShadow: isPro ? "0 0 12px var(--accent-glow)" : "none",
color: isPro ? "white" : "var(--text-muted)",
fontSize: 11,
fontWeight: 700,
letterSpacing: "0.05em",
padding: "2px 10px",
background: isPro ? "var(--accent-dim)" : "var(--bg-2)",
border: `1px solid ${isPro ? "rgba(79,110,247,0.25)" : "var(--border)"}`,
borderRadius: 4,
color: isPro ? "var(--accent)" : "var(--text-3)",
fontFamily: "IBM Plex Mono, monospace",
fontSize: 10,
fontWeight: 600,
letterSpacing: "0.06em",
padding: "2px 7px",
textTransform: "uppercase",
}}
{...props}
>
{isPro ? "✦ PRO" : "FREE"}
{isPro ? "PRO" : "FREE"}
</span>
);
}
24 changes: 10 additions & 14 deletions client/src/components/StatusBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { InvoiceStatus, ProposalStatus } from "@/types/invoice";
type Status = "DRAFT" | "SENT" | "PAID" | "OVERDUE" | "ACCEPTED" | "DECLINED";

interface StatusBadgeProps {
status: InvoiceStatus | ProposalStatus;
}

const statusClasses: Record<InvoiceStatus | ProposalStatus, string> = {
ACCEPTED: "badge-paid",
DECLINED: "badge-overdue",
DRAFT: "badge-draft",
OVERDUE: "badge-overdue",
PAID: "badge-paid",
SENT: "badge-sent",
const map: Record<Status, string> = {
ACCEPTED: "badge badge-accepted",
DECLINED: "badge badge-declined",
DRAFT: "badge badge-draft",
OVERDUE: "badge badge-overdue",
PAID: "badge badge-paid",
SENT: "badge badge-sent",
};

export function StatusBadge({ status }: StatusBadgeProps) {
return <span className={statusClasses[status] ?? "badge-draft"}>{status}</span>;
export function StatusBadge({ status }: { status: string }) {
return <span className={map[status as Status] ?? "badge badge-draft"}>{status}</span>;
}
59 changes: 37 additions & 22 deletions client/src/components/Toast.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,60 @@
type ToastProps = {
message: string;
onDismiss: () => void;
tone?: "success" | "error";
type ToastType = "success" | "error" | "info";

const icons: Record<ToastType, string> = {
error: "✕",
info: "·",
success: "✓",
};

const toneClasses = {
success: "var(--success)",
error: "#F87171",
const colors: Record<ToastType, string> = {
error: "var(--red)",
info: "var(--accent)",
success: "var(--green)",
};

export function Toast({ message, onDismiss, tone = "success" }: ToastProps) {
export function Toast({
message,
type = "success",
onDismiss,
}: {
message: string;
type?: ToastType;
onDismiss: () => void;
}) {
return (
<div
className="fixed bottom-6 right-6 z-50 animate-fade-in-up"
style={{
alignItems: "center",
background: "var(--bg-elevated)",
animation: "fadeIn 200ms ease both",
background: "var(--bg-2)",
border: "1px solid var(--border)",
borderRadius: 14,
boxShadow: "0 0 40px rgba(99,102,241,0.2)",
color: "var(--text-primary)",
borderRadius: 8,
bottom: 20,
boxShadow: "0 4px 24px rgba(0,0,0,0.4)",
color: "var(--text-1)",
display: "flex",
fontSize: 14,
fontWeight: 500,
gap: 12,
maxWidth: 360,
padding: "14px 20px",
alignItems: "center",
fontSize: 13,
gap: 10,
maxWidth: 340,
padding: "10px 14px",
position: "fixed",
right: 20,
zIndex: 99,
}}
>
<span style={{ color: toneClasses[tone], fontSize: 18 }}>{tone === "error" ? "!" : "✓"}</span>
<span style={{ color: colors[type], fontSize: 14, fontWeight: 600 }}>{icons[type]}</span>
<span style={{ flex: 1 }}>{message}</span>
<button
aria-label="Dismiss notification"
onClick={onDismiss}
style={{
background: "none",
border: "none",
color: "var(--text-muted)",
color: "var(--text-3)",
cursor: "pointer",
fontSize: 18,
fontSize: 16,
lineHeight: 1,
padding: 2,
}}
type="button"
>
Expand Down
47 changes: 47 additions & 0 deletions client/src/components/TopLoadingBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useCallback, useEffect, useRef, useState } from "react";

export function TopLoadingBar({ active, complete }: { active: boolean; complete: boolean }) {
if (!active) {
return null;
}

return <div className={`top-loading-bar ${complete ? "done" : ""}`} />;
}

export function useLoadingBar() {
const [active, setActive] = useState(false);
const [complete, setComplete] = useState(false);
const timeoutRef = useRef<number | null>(null);

const clearTimer = useCallback(() => {
if (timeoutRef.current !== null) {
window.clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
}, []);

const start = useCallback(() => {
clearTimer();
setComplete(false);
setActive(true);
}, [clearTimer]);

const done = useCallback(() => {
setComplete(true);
clearTimer();
timeoutRef.current = window.setTimeout(() => {
setActive(false);
setComplete(false);
timeoutRef.current = null;
}, 220);
}, [clearTimer]);

useEffect(() => clearTimer, [clearTimer]);

return {
active,
complete,
done,
start,
};
}
Loading
Loading