mirror of https://github.com/acid-info/lsd.git
feat: added new class dayIsToday and rebased
This commit is contained in:
parent
2537acf89d
commit
1249d98ac0
|
@ -77,6 +77,9 @@ const componentStyles: Array<ReturnType<typeof withTheme> | SerializedStyles> =
|
|||
ModalStyles,
|
||||
ModalFooterStyles,
|
||||
ModalBodyStyles,
|
||||
DatePickerStyles,
|
||||
DateFieldStyles,
|
||||
CalendarStyles,
|
||||
]
|
||||
|
||||
export const CSSBaseline: React.FC<{ theme?: Theme }> = ({
|
||||
|
|
|
@ -18,6 +18,7 @@ export const calendarClasses = {
|
|||
day: 'lsd-calendar-day',
|
||||
daySelected: 'lsd-calendar-day--selected',
|
||||
dayDisabled: 'lsd-calendar-day--disabled',
|
||||
dayIsToday: 'lsd-calendar-day--today',
|
||||
todayIndicator: 'lsd-calendar-day__today_indicator',
|
||||
dayRange: 'lsd-calendar-day--range',
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ export const Day = ({ day, date, disabled = false }: DayProps) => {
|
|||
return null
|
||||
}
|
||||
|
||||
const isToday =
|
||||
new Date(date).setHours(0, 0, 0, 0) === new Date().setHours(0, 0, 0, 0)
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={(e) => !disabled && onClick()}
|
||||
|
@ -55,11 +58,11 @@ export const Day = ({ day, date, disabled = false }: DayProps) => {
|
|||
calendarClasses.day,
|
||||
!disabled && isDateFocused(date) && calendarClasses.daySelected,
|
||||
disabled && calendarClasses.dayDisabled,
|
||||
isToday && calendarClasses.dayIsToday,
|
||||
)}
|
||||
>
|
||||
<Typography variant="label2">{parseInt(day, 10)}</Typography>
|
||||
{new Date(date).setHours(0, 0, 0, 0) ===
|
||||
new Date().setHours(0, 0, 0, 0) && (
|
||||
{isToday && (
|
||||
<Typography variant="label2" className={calendarClasses.todayIndicator}>
|
||||
■
|
||||
</Typography>
|
||||
|
|
|
@ -34,3 +34,6 @@ export * from './components/NumberInput'
|
|||
export * from './components/Modal'
|
||||
export * from './components/ModalBody'
|
||||
export * from './components/ModalFooter'
|
||||
export * from './components/DateField'
|
||||
export * from './components/DatePicker'
|
||||
export * from './components/Calendar'
|
||||
|
|
Loading…
Reference in New Issue