diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-11-03 17:11:53 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-11-16 17:17:36 +0100 |
| commit | 006a2aef34e9864af32c87f51a2499d7ae39b7c7 (patch) | |
| tree | 33172cdc42a4287ba91bcae452c35b2d1355744b /gui/src | |
| parent | 8154f1df30c6beda0f14265a429dc50b99df5d61 (diff) | |
| download | mullvadvpn-006a2aef34e9864af32c87f51a2499d7ae39b7c7.tar.xz mullvadvpn-006a2aef34e9864af32c87f51a2499d7ae39b7c7.zip | |
Only use hover effect in CellButton if the onClick prop is provided
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/cell/CellButton.tsx | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/gui/src/renderer/components/cell/CellButton.tsx b/gui/src/renderer/components/cell/CellButton.tsx index a55ffc1153..68f1dc1f32 100644 --- a/gui/src/renderer/components/cell/CellButton.tsx +++ b/gui/src/renderer/components/cell/CellButton.tsx @@ -4,29 +4,34 @@ import { colors } from '../../../config.json'; import { CellDisabledContext } from './Container'; import { CellSectionContext } from './Section'; -interface IStyledCellButtonProps { +interface IStyledCellButtonProps extends React.HTMLAttributes<HTMLButtonElement> { selected?: boolean; containedInSection: boolean; } -const StyledCellButton = styled.button({}, (props: IStyledCellButtonProps) => ({ - display: 'flex', - padding: '0 16px 0 22px', - marginBottom: '1px', - flex: 1, - alignItems: 'center', - alignContent: 'center', - cursor: 'default', - border: 'none', - backgroundColor: props.selected +export const StyledCellButton = styled.button({}, (props: IStyledCellButtonProps) => { + const backgroundColor = props.selected ? colors.green : props.containedInSection ? colors.blue40 - : colors.blue, - ':not(:disabled):hover': { - backgroundColor: props.selected ? colors.green : colors.blue80, - }, -})); + : colors.blue; + const backgroundColorHover = props.selected ? colors.green : colors.blue80; + + return { + display: 'flex', + padding: '0 16px 0 22px', + marginBottom: '1px', + flex: 1, + alignItems: 'center', + alignContent: 'center', + cursor: 'default', + border: 'none', + backgroundColor, + ':not(:disabled):hover': { + backgroundColor: props.onClick ? backgroundColorHover : backgroundColor, + }, + }; +}); interface ICellButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { selected?: boolean; |
