refactor(Calendar): remove past items styling

This commit is contained in:
Tim 2024-11-28 15:07:39 +01:00
parent 83c5c5ab0f
commit 7b87715153
4 changed files with 10 additions and 28 deletions

View file

@ -88,12 +88,6 @@
}
}
&.past {
.body {
opacity: 0.5;
}
}
&.active {
border-color: var(--primary-foreground-color);
}

View file

@ -20,13 +20,10 @@ const Item = ({ selected, monthInfo, date, items, profile, onClick }: Props) =>
const ref = useRef<HTMLDivElement>(null);
const { toDayMonth } = useCalendarDate(profile);
const [active, today, past] = useMemo(() => {
const active = date.day === selected?.day;
const today = date.day === monthInfo.today;
const past = date.day < (monthInfo.today ?? 1);
return [active, today, past];
}, [selected, monthInfo, date]);
const [active, today] = useMemo(() => [
date.day === selected?.day,
date.day === monthInfo.today,
], [selected, monthInfo, date]);
const onItemClick = () => {
onClick && onClick(date);
@ -42,7 +39,7 @@ const Item = ({ selected, monthInfo, date, items, profile, onClick }: Props) =>
return (
<div
ref={ref}
className={classNames(styles['item'], { [styles['active']]: active, [styles['today']]: today, [styles['past']]: past })}
className={classNames(styles['item'], { [styles['active']]: active, [styles['today']]: today })}
key={date.day}
onClick={onItemClick}
>

View file

@ -124,12 +124,6 @@
}
}
&.past {
.items {
opacity: 0.5;
}
}
&.active {
border-color: var(--primary-foreground-color);
}

View file

@ -15,13 +15,10 @@ type Props = {
};
const Cell = ({ selected, monthInfo, date, items, onClick }: Props) => {
const [active, today, past] = useMemo(() => {
const active = date.day === selected?.day;
const today = date.day === monthInfo.today;
const past = date.day < (monthInfo.today ?? 1);
return [active, today, past];
}, [selected, monthInfo, date]);
const [active, today] = useMemo(() => [
date.day === selected?.day,
date.day === monthInfo.today,
], [selected, monthInfo, date]);
const onCellClick = () => {
onClick && onClick(date);
@ -29,7 +26,7 @@ const Cell = ({ selected, monthInfo, date, items, onClick }: Props) => {
return (
<Button
className={classNames(styles['cell'], { [styles['active']]: active, [styles['today']]: today, [styles['past']]: past })}
className={classNames(styles['cell'], { [styles['active']]: active, [styles['today']]: today })}
onClick={onCellClick}
>
<div className={styles['heading']}>