AvanzaCast/shared/components/modal-parts/ModalDateTimeGroup.tsx
Cesar Mendivil e43686e36d feat(modal-parts): add modular components for modal UI
- 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.
2025-11-06 00:32:08 -07:00

97 lines
2.4 KiB
TypeScript

import React from 'react'
import styles from './ModalDateTimeGroup.module.css'
interface Props {
label?: string
helpIcon?: React.ReactNode
dateValue: string
hourValue: string
minuteValue: string
onDateChange: (value: string) => void
onHourChange: (value: string) => void
onMinuteChange: (value: string) => void
timezone?: string
className?: string
}
const ModalDateTimeGroup: React.FC<Props> = ({
label,
helpIcon,
dateValue,
hourValue,
minuteValue,
onDateChange,
onHourChange,
onMinuteChange,
timezone = 'GMT-7',
className = ''
}) => {
// Generate hour options (00-23)
const hours = Array.from({ length: 24 }, (_, i) => {
const hour = i.toString().padStart(2, '0')
return { value: hour, label: hour }
})
// Generate minute options (00-59)
const minutes = Array.from({ length: 60 }, (_, i) => {
const minute = i.toString().padStart(2, '0')
return { value: minute, label: minute }
})
return (
<div className={`${styles.container} ${className}`}>
{label && (
<div className={styles.labelRow}>
<label className={styles.label}>
{label} <span className={styles.timezone}>{timezone}</span>
</label>
{helpIcon && (
<button
type="button"
className={styles.helpButton}
aria-label="Ayuda"
>
{helpIcon}
</button>
)}
</div>
)}
<div className={styles.inputs}>
<input
type="date"
value={dateValue}
onChange={(e) => onDateChange(e.target.value)}
className={styles.dateInput}
/>
<select
value={hourValue}
onChange={(e) => onHourChange(e.target.value)}
className={styles.timeSelect}
>
{hours.map((hour) => (
<option key={hour.value} value={hour.value}>
{hour.label}
</option>
))}
</select>
<select
value={minuteValue}
onChange={(e) => onMinuteChange(e.target.value)}
className={styles.timeSelect}
>
{minutes.map((minute) => (
<option key={minute.value} value={minute.value}>
{minute.label}
</option>
))}
</select>
</div>
</div>
)
}
export default ModalDateTimeGroup