Skip to content

Commit

Permalink
refactor(Calendar): remove past items styling
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Nov 28, 2024
1 parent 83c5c5a commit 7b87715
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
6 changes: 0 additions & 6 deletions src/routes/Calendar/List/Item/Item.less
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@
}
}

&.past {
.body {
opacity: 0.5;
}
}

&.active {
border-color: var(--primary-foreground-color);
}
Expand Down
13 changes: 5 additions & 8 deletions src/routes/Calendar/List/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}
>
Expand Down
6 changes: 0 additions & 6 deletions src/routes/Calendar/Table/Cell/Cell.less
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@
}
}

&.past {
.items {
opacity: 0.5;
}
}

&.active {
border-color: var(--primary-foreground-color);
}
Expand Down
13 changes: 5 additions & 8 deletions src/routes/Calendar/Table/Cell/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ 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);
};

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']}>
Expand Down

0 comments on commit 7b87715

Please sign in to comment.