SEC_Warehouse/src/components/popup/index.tsx

39 lines
812 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { View, Text } from '@tarojs/components'
import type { ReactNode } from 'react'
import styles from './index.module.scss'
interface Props {
visible: boolean
position?: 'top' | 'center' | 'bottom'
onClose: () => void
children?: ReactNode
maxHeight?: string // e.g. '60vh'
}
export function Popup({
visible,
position = 'bottom',
onClose,
children,
maxHeight = '60vh'
}: Props) {
if (!visible) return null
const positionClass = styles[`pos-${position}`]
return (
<>
<View className={styles.mask} onClick={onClose} />
<View
className={`${styles.panel} ${positionClass}`}
style={{ maxHeight }}
>
{children}
<View className={styles.close} onClick={onClose}>
<Text>×</Text>
</View>
</View>
</>
)
}