- Introduced ModalDestinationButton for destination selection with customizable icons and labels. - Added ModalInput for text input with optional character counter. - Implemented ModalLink for reusable links styled as underlined text. - Created ModalPlatformCard for platform selection with badges. - Developed ModalRadioGroup for radio button groups with custom styling. - Added ModalSection for grouping modal content with optional labels. - Implemented ModalSelect for dropdown selections with custom styling. - Created ModalShareButtons for sharing options via Gmail, Email, and Messenger. - Developed ModalTextarea for multi-line text input with character counter. - Introduced ModalToggle for toggle switches with optional help text and links. - Updated README.md with component descriptions, usage examples, and design guidelines. - Added index.ts for centralized exports of modal components.
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import React from 'react'
|
|
import { BsInfoCircle } from 'react-icons/bs'
|
|
import styles from './ModalToggle.module.css'
|
|
|
|
interface Props {
|
|
checked: boolean
|
|
onChange: (checked: boolean) => void
|
|
label: string
|
|
helpText?: string
|
|
helpLink?: string
|
|
className?: string
|
|
}
|
|
|
|
/**
|
|
* Componente de toggle/checkbox para modales
|
|
* Estilo StreamYard: switch + texto + icono de ayuda opcional
|
|
*/
|
|
export const ModalToggle: React.FC<Props> = ({
|
|
checked,
|
|
onChange,
|
|
label,
|
|
helpText,
|
|
helpLink,
|
|
className = ''
|
|
}) => {
|
|
return (
|
|
<div className={`${styles.container} ${className}`}>
|
|
<label className={styles.label}>
|
|
<input
|
|
type="checkbox"
|
|
checked={checked}
|
|
onChange={(e) => onChange(e.target.checked)}
|
|
className={styles.checkbox}
|
|
/>
|
|
<span className={styles.slider}></span>
|
|
<span className={styles.text}>{label}</span>
|
|
</label>
|
|
|
|
{(helpText || helpLink) && (
|
|
<button
|
|
type="button"
|
|
className={styles.helpButton}
|
|
aria-label="Más información"
|
|
onClick={() => helpLink && window.open(helpLink, '_blank')}
|
|
>
|
|
<BsInfoCircle size={16} />
|
|
</button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ModalToggle
|