added users pages, stepper

This commit is contained in:
Jelaletdin12
2026-05-10 23:31:01 +05:00
parent 2424093a4f
commit ab7fdf46b3
30 changed files with 4665 additions and 446 deletions

View File

@@ -182,7 +182,7 @@ function TextInput({
function PhoneInput({
value = '',
onChange,
placeholder = '61 097 651',
placeholder = '61 111213',
error,
disabled,
required,

215
src/components/stepBar.tsx Normal file
View File

@@ -0,0 +1,215 @@
'use client'
import { useEffect, useRef, type KeyboardEvent } from 'react'
import { Check, AlertTriangle } from 'lucide-react'
import { cn } from '@/lib/utils'
// ─── Types ──────────────────────────────────────────────────────────────────
export type StepStatus = 'idle' | 'active' | 'done' | 'error'
export interface StepBarItem {
id: string
label: string
status: StepStatus
}
interface StepBarProps {
steps: StepBarItem[]
onGoTo: (index: number) => void
showLabels?: boolean
}
// ─── Helper ──────────────────────────────────────────────────────────────────
function DotIcon({ status, index }: { status: StepStatus; index: number }) {
if (status === 'done')
return <Check className="w-3.5 h-3.5" strokeWidth={3} aria-hidden />
if (status === 'error')
return <AlertTriangle className="w-3 h-3" aria-hidden />
return (
<span className="text-[11px] font-bold tabular-nums leading-none">
{index + 1}
</span>
)
}
// ─── Component ───────────────────────────────────────────────────────────────
export function StepBar({ steps, onGoTo, showLabels }: StepBarProps) {
const btnRefs = useRef<Array<HTMLButtonElement | null>>([])
const total = steps.length
const activeIdx = steps.findIndex((s) => s.status === 'active')
const fillPct = total > 1 ? (Math.max(0, activeIdx) / (total - 1)) * 100 : 0
useEffect(() => {
btnRefs.current[activeIdx]?.scrollIntoView({
behavior: 'smooth',
inline: 'center',
block: 'nearest',
})
}, [activeIdx])
const isReachable = (i: number) => {
const s = steps[i].status
if (s === 'done' || s === 'active' || s === 'error') return true
return i > 0 && steps[i - 1].status === 'done'
}
const handleKey = (e: KeyboardEvent<HTMLButtonElement>, i: number) => {
let next = i
if (e.key === 'ArrowRight') next = Math.min(total - 1, i + 1)
else if (e.key === 'ArrowLeft') next = Math.max(0, i - 1)
else if (e.key === 'Home') next = 0
else if (e.key === 'End') next = total - 1
else return
e.preventDefault()
const dir = next > i ? 1 : -1
while (next !== i && !isReachable(next)) {
next += dir
if (next < 0 || next >= total) return
}
btnRefs.current[next]?.focus()
}
return (
<nav
role="tablist"
aria-label="Form steps"
className="relative w-full"
>
{/*
* Track layer — z-index: 1 so it sits BELOW the dots (z-index: 2).
* top: 32px = paddingTop(16px) + dotSize(32px)/2
*/}
<div
aria-hidden
className="pointer-events-none absolute"
style={{
top: 32,
left: `calc(${(0.5 / total) * 100}%)`,
right: `calc(${(0.5 / total) * 100}%)`,
transform: 'translateY(-50%)',
zIndex: 1,
}}
>
<div className="relative h-[2px] w-full overflow-hidden rounded-full bg-border">
<div
className="absolute inset-y-0 left-0 rounded-full bg-primary"
style={{
width: `${fillPct}%`,
transition: 'width 500ms cubic-bezier(0.4, 0, 0.2, 1)',
willChange: 'width',
}}
/>
</div>
</div>
{/* Steps row — z-index: 2, establishes stacking context above track */}
<div className="relative flex w-full" style={{ zIndex: 2 }}>
{steps.map((step, i) => {
const isActive = step.status === 'active'
const isDone = step.status === 'done'
const isError = step.status === 'error'
const isIdle = step.status === 'idle'
const reachable = isReachable(i)
const displayLabel = showLabels ?? true
return (
<button
key={step.id}
ref={(el) => { btnRefs.current[i] = el }}
type="button"
role="tab"
aria-selected={isActive}
aria-current={isActive ? 'step' : undefined}
aria-label={`${step.label}${isError ? ' — hata' : ''} (${i + 1} / ${total})`}
onClick={() => reachable && onGoTo(i)}
onKeyDown={(e) => handleKey(e, i)}
disabled={!reachable}
tabIndex={isActive ? 0 : -1}
className={cn(
'group flex flex-1 flex-col items-center',
'pt-4 pb-3 gap-2',
'select-none outline-none rounded-xl',
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
reachable ? 'cursor-pointer' : 'cursor-not-allowed opacity-40',
)}
>
{/*
* Dot wrapper — position: relative + z-index: 2
* This creates a stacking context that sits above the track (z:1).
* Fixed 32×32 for ALL states so track top:32px never shifts.
*/}
<span
className="relative flex h-8 w-8 items-center justify-center"
style={{ zIndex: 2 }}
>
{/* Active pulse ring */}
{isActive && (
<span
className="absolute inset-0 rounded-full bg-primary/20 animate-ping"
aria-hidden
style={{ animationDuration: '2s' }}
/>
)}
<span
className={cn(
'relative flex h-7 w-7 items-center justify-center rounded-full border',
'transition-[transform,box-shadow,background-color,border-color] duration-300',
// Active — opaque bg
isActive && [
'scale-[1.14]',
'bg-primary border-transparent text-primary-foreground',
'shadow-[0_0_0_4px_hsl(var(--primary)/0.18)]',
],
// Done — opaque bg (track cannot bleed through)
isDone && !isActive && [
'bg-emerald-50 border-emerald-400 text-emerald-700',
'dark:bg-emerald-950 dark:border-emerald-500 dark:text-emerald-300',
],
// Error — opaque bg, was /50 (semi-transparent) which caused bleed
isError && !isActive && [
'bg-background border-destructive/60 text-destructive',
],
// Idle — bg-background is always opaque
isIdle && [
'bg-background border-border text-muted-foreground',
],
!isActive && reachable && 'group-hover:scale-110 group-hover:shadow-sm',
)}
>
<DotIcon status={step.status} index={i} />
</span>
</span>
{/* Label */}
{displayLabel && (
<span
className={cn(
'max-w-full truncate px-0.5 text-center text-[11px] leading-snug tracking-tight',
'transition-colors duration-200',
total > 4 && 'hidden sm:block',
isActive && 'font-semibold text-foreground',
isDone && !isActive && 'text-muted-foreground',
isError && !isActive && 'font-medium text-destructive',
isIdle && 'text-muted-foreground',
)}
>
{step.label}
</span>
)}
</button>
)
})}
</div>
</nav>
)
}

View File

@@ -0,0 +1,109 @@
import { type LucideIcon, ChevronRight, Check, AlertTriangle } from 'lucide-react'
import { cn } from '@/lib/utils'
import type { StepStatus } from './stepBar'
export interface StepCardItem {
id: string
title: string
subtitle: string
icon: LucideIcon
status: StepStatus
}
interface StepBarCardsProps {
steps: StepCardItem[]
onGoTo: (index: number) => void
}
/**
* Card-style horizontal step bar (icon + title + subtitle, chevron separators).
* Inspired by the reference mockup. Uses semantic tokens only.
*/
export function StepBarCards({ steps, onGoTo }: StepBarCardsProps) {
return (
<nav
role="tablist"
aria-label="Form adımları"
className={cn(
'flex items-center gap-2 overflow-x-auto',
'[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]',
)}
>
{steps.map((step, i) => {
const Icon = step.icon
const isActive = step.status === 'active'
const isDone = step.status === 'done'
const isError = step.status === 'error'
const isIdle = step.status === 'idle'
const reachable = !isIdle || (i > 0 && steps[i - 1].status === 'done')
return (
<div key={step.id} className="flex items-center gap-2 shrink-0">
<button
type="button"
role="tab"
aria-selected={isActive}
aria-current={isActive ? 'step' : undefined}
disabled={!reachable}
onClick={() => reachable && onGoTo(i)}
className={cn(
'group flex items-center gap-3 rounded-2xl px-3 py-2.5 transition-all duration-200',
'outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
'disabled:cursor-not-allowed disabled:opacity-40',
reachable && !isActive && 'hover:bg-muted/40 cursor-pointer',
isActive && 'bg-muted/60',
)}
>
{/* Icon disc */}
<span
className={cn(
'relative flex items-center justify-center rounded-full w-11 h-11 shrink-0 transition-all duration-300',
isActive &&
'bg-primary text-primary-foreground ring-4 ring-primary/15',
isDone &&
'bg-muted text-foreground',
isError &&
'bg-destructive/10 text-destructive ring-2 ring-destructive/30',
isIdle && 'bg-muted text-muted-foreground',
reachable && !isActive && 'group-hover:scale-105',
)}
>
{isDone ? (
<Check className="w-5 h-5 animate-scale-in" strokeWidth={2.5} />
) : isError ? (
<AlertTriangle className="w-5 h-5 animate-scale-in" />
) : (
<Icon className="w-5 h-5" strokeWidth={2} />
)}
</span>
{/* Texts */}
<span className="flex flex-col items-start text-left leading-tight">
<span
className={cn(
'text-sm font-semibold tracking-tight',
isActive || isDone ? 'text-foreground' : 'text-foreground/90',
isError && 'text-destructive',
)}
>
{step.title}
</span>
<span className="text-xs text-muted-foreground mt-0.5">
{step.subtitle}
</span>
</span>
</button>
{/* Chevron separator */}
{i < steps.length - 1 && (
<ChevronRight
className="w-4 h-4 text-muted-foreground/60 shrink-0 mx-1"
aria-hidden
/>
)}
</div>
)
})}
</nav>
)
}

View File

@@ -0,0 +1,22 @@
import * as React from "react"
import { Label as LabelPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
data-slot="label"
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className
)}
{...props}
/>
)
}
export { Label }