Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 1x 1x 1x 1x 1x 1x 1x 1x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
import type { ReactNode } from 'react'
import { css, cx } from '../../../../styled-system/css'
import { hstack, vstack } from '../../../../styled-system/patterns'
// Shared input styles
export const inputStyles = {
w: 'full',
px: 2,
py: 1,
border: '1px solid',
borderColor: 'gray.300',
rounded: 'sm',
fontSize: 'xs',
} as const
export const labelStyles = {
fontSize: 'xs',
color: 'gray.600',
mb: 1,
display: 'block',
} as const
// Shared Editor Layout Component - wraps entire editor with consistent styling
interface EditorLayoutProps {
title: string
onClose: () => void
onDelete?: () => void
deleteLabel?: string
children: ReactNode
className?: string
}
export function EditorLayout({
title,
onClose,
onDelete,
deleteLabel = 'Delete',
children,
className,
}: EditorLayoutProps) {
return (
<div
className={cx(
css({
p: 3,
bg: 'purple.50',
border: '1px solid',
borderColor: 'purple.200',
rounded: 'lg',
height: '100%',
overflowY: 'auto',
}),
className
)}
>
<div className={vstack({ gap: 3, alignItems: 'stretch' })}>
{/* Header */}
<EditorHeader
title={title}
onClose={onClose}
onDelete={onDelete}
deleteLabel={deleteLabel}
/>
{/* Content */}
{children}
</div>
</div>
)
}
// Shared Editor Header Component
interface EditorHeaderProps {
title: string
onClose: () => void
onDelete?: () => void
deleteLabel?: string
}
export function EditorHeader({
title,
onClose,
onDelete,
deleteLabel = 'Delete',
}: EditorHeaderProps) {
return (
<div
className={hstack({
justifyContent: 'space-between',
alignItems: 'center',
})}
>
<h3
className={css({
fontSize: 'md',
fontWeight: 'semibold',
color: 'purple.800',
})}
>
{title}
</h3>
<div className={hstack({ gap: 1 })}>
{onDelete && (
<button
onClick={onDelete}
className={css({
px: 2,
py: 1,
bg: 'red.500',
color: 'white',
rounded: 'sm',
fontSize: 'xs',
cursor: 'pointer',
_hover: { bg: 'red.600' },
})}
>
{deleteLabel}
</button>
)}
<button
onClick={onClose}
className={css({
p: 1,
borderRadius: 'sm',
cursor: 'pointer',
_hover: { bg: 'gray.100' },
})}
>
✕
</button>
</div>
</div>
)
}
// Shared Field Component
interface FieldProps {
label: string
children: ReactNode
}
export function Field({ label, children }: FieldProps) {
return (
<div>
<label className={css(labelStyles)}>{label}</label>
{children}
</div>
)
}
// Shared Text Input Component
interface TextInputProps {
label: string
value: string
onChange: (value: string) => void
placeholder?: string
multiline?: boolean
rows?: number
}
export function TextInput({
label,
value,
onChange,
placeholder,
multiline = false,
rows = 2,
}: TextInputProps) {
return (
<Field label={label}>
{multiline ? (
<textarea
value={value}
onChange={(e) => onChange(e.target.value)}
rows={rows}
className={css({
...inputStyles,
resize: 'none',
})}
placeholder={placeholder}
/>
) : (
<input
type="text"
value={value}
onChange={(e) => onChange(e.target.value)}
className={css(inputStyles)}
placeholder={placeholder}
/>
)}
</Field>
)
}
// Shared Number Input Component
interface NumberInputProps {
label: string
value: number | string
onChange: (value: number) => void
min?: number
max?: number
placeholder?: string
}
export function NumberInput({ label, value, onChange, min, max, placeholder }: NumberInputProps) {
return (
<Field label={label}>
<input
type="number"
min={min}
max={max}
value={value}
onChange={(e) => onChange(parseInt(e.target.value, 10) || 0)}
className={css(inputStyles)}
placeholder={placeholder}
/>
</Field>
)
}
// Shared Grid Layout Component
interface GridLayoutProps {
columns: 1 | 2 | 3 | 4
gap?: number
children: ReactNode
}
export function GridLayout({ columns, gap = 2, children }: GridLayoutProps) {
const gridCols = {
1: '1fr',
2: '1fr 1fr',
3: '1fr 1fr 1fr',
4: '1fr 1fr 1fr 1fr',
}
return (
<div
className={css({
display: 'grid',
gridTemplateColumns: gridCols[columns],
gap: gap,
})}
>
{children}
</div>
)
}
// Shared Section Component
interface SectionProps {
title?: string
children: ReactNode
collapsible?: boolean
defaultOpen?: boolean
background?: 'white' | 'gray' | 'none'
}
export function Section({ title, children, background = 'white' }: SectionProps) {
const bgStyles = {
white: {
p: 2,
bg: 'white',
border: '1px solid',
borderColor: 'gray.200',
rounded: 'md',
},
gray: {
p: 2,
bg: 'gray.50',
border: '1px solid',
borderColor: 'gray.200',
rounded: 'sm',
},
none: {},
}
return (
<div className={css(bgStyles[background])}>
{title && (
<h4
className={css({
fontSize: 'sm',
fontWeight: 'medium',
mb: 2,
color: 'gray.800',
})}
>
{title}
</h4>
)}
{children}
</div>
)
}
// Shared Form Group Component - handles common form layouts
interface FormGroupProps {
children: ReactNode
columns?: 1 | 2 | 3
gap?: number
}
export function FormGroup({ children, columns = 1, gap = 2 }: FormGroupProps) {
if (columns === 1) {
return <div className={vstack({ gap: gap, alignItems: 'stretch' })}>{children}</div>
}
return (
<GridLayout columns={columns} gap={gap}>
{children}
</GridLayout>
)
}
// Shared Compact Step Item Component
interface CompactStepItemProps {
type: 'concept' | 'practice'
index: number
title: string
subtitle?: string
description?: string
isSelected?: boolean
hasErrors?: boolean
hasWarnings?: boolean
errorCount?: number
warningCount?: number
onClick?: () => void
onPreview?: () => void
onDelete?: () => void
children?: ReactNode
// Hover-add functionality
onAddStepBefore?: () => void
onAddPracticeStepBefore?: () => void
onAddStepAfter?: () => void
onAddPracticeStepAfter?: () => void
}
export function CompactStepItem({
type,
index,
title,
subtitle,
description,
isSelected = false,
hasErrors = false,
hasWarnings = false,
errorCount = 0,
warningCount = 0,
onClick,
onPreview,
onDelete,
children,
onAddStepBefore,
onAddPracticeStepBefore,
onAddStepAfter,
onAddPracticeStepAfter,
}: CompactStepItemProps) {
const getBorderColor = () => {
if (isSelected) return 'blue.500'
if (hasErrors) return 'red.300'
return 'gray.200'
}
const getBgColor = () => {
if (isSelected) return 'blue.50'
if (hasWarnings) return 'yellow.50'
if (hasErrors) return 'red.50'
return 'white'
}
const getHoverBg = () => {
return isSelected ? 'blue.100' : 'gray.50'
}
const typeIcon = type === 'concept' ? '📝' : '🎯'
const typeLabel = type === 'concept' ? 'Step' : 'Practice'
const _hasAddActions =
onAddStepBefore || onAddPracticeStepBefore || onAddStepAfter || onAddPracticeStepAfter
return (
<div className={css({ position: 'relative' })}>
{/* Main step item */}
<div
onClick={onClick}
className={css({
px: 1.5,
py: 1,
border: '1px solid',
borderColor: getBorderColor(),
borderRadius: 'sm',
bg: getBgColor(),
cursor: onClick ? 'pointer' : 'default',
_hover: onClick ? { bg: getHoverBg() } : {},
})}
>
<div
className={hstack({
justifyContent: 'space-between',
alignItems: 'center',
gap: 2,
})}
>
<div className={css({ flex: 1, minWidth: 0 })}>
{/* Inline header: badges, title, and subtitle on same line when possible */}
<div
className={hstack({
gap: 1.5,
alignItems: 'center',
flexWrap: 'wrap',
})}
>
<span
className={css({
fontSize: 'xs',
fontWeight: 'bold',
color: type === 'concept' ? 'blue.800' : 'purple.800',
bg: type === 'concept' ? 'blue.100' : 'purple.100',
px: 0.5,
py: 0.5,
borderRadius: 'xs',
flexShrink: 0,
})}
>
{typeIcon} {typeLabel} {index + 1}
</span>
{/* Title inline */}
<div
className={css({
fontWeight: 'medium',
fontSize: 'xs',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
flex: 1,
minWidth: 0,
})}
>
{title}
</div>
{/* Error/warning badges - compact */}
{hasErrors && (
<span
className={css({
fontSize: 'xs',
color: 'red.600',
bg: 'red.100',
px: 1,
py: 0.5,
borderRadius: 'xs',
flexShrink: 0,
})}
>
{errorCount}❌
</span>
)}
{hasWarnings && (
<span
className={css({
fontSize: 'xs',
color: 'yellow.600',
bg: 'yellow.100',
px: 1,
py: 0.5,
borderRadius: 'xs',
flexShrink: 0,
})}
>
{warningCount}⚠️
</span>
)}
</div>
{/* Subtitle on separate line if provided */}
{subtitle && (
<div
className={css({
fontSize: 'xs',
color: 'gray.600',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
mt: 0.5,
})}
>
{subtitle}
</div>
)}
{/* Custom children content */}
{children}
</div>
{/* Action buttons */}
<div className={hstack({ gap: 1, flexShrink: 0 })}>
{onPreview && (
<button
onClick={(e) => {
e.stopPropagation()
onPreview()
}}
className={css({
p: 1,
bg: 'blue.100',
color: 'blue.700',
border: '1px solid',
borderColor: 'blue.300',
borderRadius: 'sm',
fontSize: 'xs',
cursor: 'pointer',
_hover: { bg: 'blue.200' },
})}
title="Preview"
>
👁
</button>
)}
{onDelete && (
<button
onClick={(e) => {
e.stopPropagation()
onDelete()
}}
className={css({
p: 1,
bg: 'red.100',
color: 'red.700',
border: '1px solid',
borderColor: 'red.300',
borderRadius: 'sm',
fontSize: 'xs',
cursor: 'pointer',
_hover: { bg: 'red.200' },
})}
title="Delete"
>
🗑
</button>
)}
</div>
</div>
</div>
</div>
)
}
// Between-step hover area with dropdown
interface BetweenStepAddProps {
onAddStep: () => void
onAddPracticeStep: () => void
}
export function BetweenStepAdd({ onAddStep, onAddPracticeStep }: BetweenStepAddProps) {
return (
<div
className={css({
position: 'relative',
height: '16px',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 50, // Higher z-index for the container
'&:hover .add-button': {
opacity: 0.5,
},
})}
>
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild>
<button
className={`${css({
px: 2,
py: 0.5,
bg: 'gray.100',
color: 'gray.600',
border: '1px dashed',
borderColor: 'gray.300',
borderRadius: 'sm',
fontSize: 'xs',
cursor: 'pointer',
opacity: 0,
transition: 'opacity 0.2s ease',
zIndex: 50, // Higher z-index for the button
position: 'relative',
_hover: {
opacity: '1 !important',
bg: 'gray.200',
borderColor: 'gray.400',
},
})} add-button`}
>
+ New
</button>
</DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content
className={css({
mt: 1,
bg: 'white',
border: '1px solid',
borderColor: 'gray.200',
borderRadius: 'md',
shadow: 'md',
zIndex: 100, // Very high z-index for dropdown content
minW: '150px',
})}
sideOffset={4}
>
<DropdownMenu.Item asChild>
<button
onClick={onAddStep}
className={css({
w: 'full',
px: 3,
py: 2,
textAlign: 'left',
fontSize: 'sm',
cursor: 'pointer',
border: 'none',
bg: 'transparent',
_hover: { bg: 'blue.50', color: 'blue.700' },
borderBottom: '1px solid',
borderColor: 'gray.100',
})}
>
📝 Concept Step
</button>
</DropdownMenu.Item>
<DropdownMenu.Item asChild>
<button
onClick={onAddPracticeStep}
className={css({
w: 'full',
px: 3,
py: 2,
textAlign: 'left',
fontSize: 'sm',
cursor: 'pointer',
border: 'none',
bg: 'transparent',
_hover: { bg: 'purple.50', color: 'purple.700' },
})}
>
🎯 Problem Page
</button>
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu.Root>
</div>
)
}
// Shared Button Component
interface ButtonProps {
children: ReactNode
onClick: () => void
variant?: 'primary' | 'secondary' | 'outline'
size?: 'xs' | 'sm' | 'md'
disabled?: boolean
title?: string
}
export function Button({
children,
onClick,
variant = 'secondary',
size = 'sm',
disabled = false,
title,
}: ButtonProps) {
const variantStyles = {
primary: { bg: 'blue.500', color: 'white', _hover: { bg: 'blue.600' } },
secondary: {
bg: 'blue.100',
color: 'blue.800',
border: '1px solid',
borderColor: 'blue.300',
_hover: { bg: 'blue.200' },
},
outline: {
bg: 'gray.100',
color: 'gray.700',
border: '1px solid',
borderColor: 'gray.300',
_hover: { bg: 'gray.200' },
},
}
const sizeStyles = {
xs: { px: 1, py: 1, fontSize: 'xs' },
sm: { px: 2, py: 1, fontSize: 'xs' },
md: { px: 3, py: 2, fontSize: 'sm' },
}
return (
<button
onClick={onClick}
disabled={disabled}
title={title}
className={css({
...variantStyles[variant],
...sizeStyles[size],
rounded: 'sm',
cursor: disabled ? 'not-allowed' : 'pointer',
opacity: disabled ? 0.5 : 1,
textAlign: 'center',
})}
>
{children}
</button>
)
}
|