Skip to content

Commit

Permalink
Refactoring cells component pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Jul 27, 2022
1 parent 552316a commit 52c8492
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/components/grid/cell/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,25 @@ interface CellsType {
export const CellComponent: FunctionComponent<CellsType> = ({ mouseDown, children }) => {
switch (children) {
case 0:
return (
<div
className={classNames(styles.closedFrame, styles.emptyFrame, {
// [styles.changedBorderColor]: !mouseDown,
// [styles.transparentClosedFrame]: mouseDown,
})}
/>
);
return <EmptyFrame />;
case 10:
return (
<div
className={classNames(styles.closedFrame, {
[styles.changedBorderColor]: !mouseDown,
[styles.transparentClosedFrame]: mouseDown,
})}
/>
);
return <ClosedFrame mouseDown={mouseDown} />;
default:
return (
<div
className={classNames(styles.closedFrame, {
[styles.changedBorderColor]: !mouseDown,
[styles.transparentClosedFrame]: mouseDown,
})}
/>
);
return <ClosedFrame mouseDown={mouseDown} />;
}
};

const ClosedFrame: FunctionComponent<{ mouseDown: boolean }> = ({ mouseDown }) => {
return (
<div
className={classNames(styles.closedFrame, {
[styles.changedBorderColor]: !mouseDown,
[styles.transparentClosedFrame]: mouseDown,
})}
/>
);
};

const EmptyFrame: FunctionComponent = () => {
return <div className={classNames(styles.closedFrame, styles.emptyFrame)} />;
};

0 comments on commit 52c8492

Please sign in to comment.