-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStepSection.tsx
More file actions
51 lines (45 loc) · 1.38 KB
/
StepSection.tsx
File metadata and controls
51 lines (45 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {ReactNode, useMemo} from "react";
interface NumberComponentProps {
number: number
done?: boolean
}
const NumberComponent = ({ number, done }: NumberComponentProps) => {
return (
<div
className={`text-lg font-bold text-cyan-900 w-6 h-6 flex justify-center items-center rounded-full ${
done ? 'bg-green-500' : 'bg-white'
}`}
>
{done ? '✓' : number}
</div>
)
}
interface Props {
number: number
active: boolean
done?: boolean
children: (disabled: boolean) => ReactNode
}
export default function StepSection ({ children, number, active, done }: Props){
const disabled = useMemo(() => {
return !active
}, [active])
return (
<section className={'flex items-start gap-4'}>
<div
aria-disabled={done ? false : disabled}
className={
'aria-disabled:opacity-50 aria-disabled:pointer-events-none'
}
>
<NumberComponent number={number} done={done} />
</div>
<div
aria-disabled={disabled}
className={`transition-[max-height] duration-500 overflow-y-auto aria-disabled:opacity-50 aria-disabled:pointer-events-none`}
>
{children(disabled)}
</div>
</section>
)
}