Skip to content

Commit 006a2ae

Browse files
committed
Only use hover effect in CellButton if the onClick prop is provided
1 parent 8154f1d commit 006a2ae

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

gui/src/renderer/components/cell/CellButton.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,34 @@ import { colors } from '../../../config.json';
44
import { CellDisabledContext } from './Container';
55
import { CellSectionContext } from './Section';
66

7-
interface IStyledCellButtonProps {
7+
interface IStyledCellButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
88
selected?: boolean;
99
containedInSection: boolean;
1010
}
1111

12-
const StyledCellButton = styled.button({}, (props: IStyledCellButtonProps) => ({
13-
display: 'flex',
14-
padding: '0 16px 0 22px',
15-
marginBottom: '1px',
16-
flex: 1,
17-
alignItems: 'center',
18-
alignContent: 'center',
19-
cursor: 'default',
20-
border: 'none',
21-
backgroundColor: props.selected
12+
export const StyledCellButton = styled.button({}, (props: IStyledCellButtonProps) => {
13+
const backgroundColor = props.selected
2214
? colors.green
2315
: props.containedInSection
2416
? colors.blue40
25-
: colors.blue,
26-
':not(:disabled):hover': {
27-
backgroundColor: props.selected ? colors.green : colors.blue80,
28-
},
29-
}));
17+
: colors.blue;
18+
const backgroundColorHover = props.selected ? colors.green : colors.blue80;
19+
20+
return {
21+
display: 'flex',
22+
padding: '0 16px 0 22px',
23+
marginBottom: '1px',
24+
flex: 1,
25+
alignItems: 'center',
26+
alignContent: 'center',
27+
cursor: 'default',
28+
border: 'none',
29+
backgroundColor,
30+
':not(:disabled):hover': {
31+
backgroundColor: props.onClick ? backgroundColorHover : backgroundColor,
32+
},
33+
};
34+
});
3035

3136
interface ICellButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3237
selected?: boolean;

0 commit comments

Comments
 (0)