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 | 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 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 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 | import type { ReactNode } from 'react'
export interface ModalProps {
/**
* Whether the modal is open
*/
isOpen: boolean
/**
* Callback when modal should close (clicking overlay or ESC)
*/
onClose: () => void
/**
* Modal content
*/
children: ReactNode
/**
* Optional CSS class for the modal content
*/
className?: string
}
/**
* Reusable modal overlay component
*
* Handles:
* - Overlay click to close
* - Prevents content click from closing
* - Portal rendering
* - Backdrop blur
*
* @example
* ```tsx
* <Modal isOpen={showModal} onClose={() => setShowModal(false)}>
* <ModalContent title="My Modal">
* Content here
* </ModalContent>
* </Modal>
* ```
*/
export function Modal({ isOpen, onClose, children, className }: ModalProps) {
if (!isOpen) return null
return (
<div
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
background: 'rgba(0, 0, 0, 0.7)',
backdropFilter: 'blur(4px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 10000,
}}
onClick={onClose}
onKeyDown={(e) => {
if (e.key === 'Escape') {
onClose()
}
}}
>
<div
className={className}
onClick={(e) => e.stopPropagation()}
style={{
background: 'linear-gradient(135deg, rgba(17, 24, 39, 0.98), rgba(31, 41, 55, 0.98))',
borderRadius: '16px',
padding: '32px',
maxWidth: className ? 'none' : '500px',
width: '90%',
maxHeight: '90vh',
overflow: 'auto',
boxShadow: '0 20px 60px rgba(0, 0, 0, 0.5)',
boxSizing: 'border-box',
}}
>
{children}
</div>
</div>
)
}
export interface ModalContentProps {
/**
* Modal title
*/
title: string
/**
* Modal description/subtitle
*/
description?: string
/**
* Modal content
*/
children: ReactNode
/**
* Border color for the modal
*/
borderColor?: string
/**
* Title color
*/
titleColor?: string
}
/**
* Standard modal content wrapper with consistent styling
*/
export function ModalContent({
title,
description,
children,
borderColor = 'rgba(139, 92, 246, 0.3)',
titleColor = 'rgba(196, 181, 253, 1)',
}: ModalContentProps) {
return (
<div
style={{
border: `2px solid ${borderColor}`,
borderRadius: '16px',
padding: 0,
}}
>
<h2
style={{
fontSize: '24px',
fontWeight: 'bold',
marginBottom: description ? '8px' : '24px',
color: titleColor,
}}
>
{title}
</h2>
{description && (
<p
style={{
fontSize: '14px',
color: 'rgba(209, 213, 219, 0.8)',
marginBottom: '24px',
}}
>
{description}
</p>
)}
{children}
</div>
)
}
|