Skip to content

Commit

Permalink
fix: use data grid switch visible in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
matusmlichsk committed Nov 15, 2024
1 parent bf1117c commit 24b338b
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Stack } from "@mui/material";
import { Switch } from "@equinor/eds-core-react";
import { useOperationState } from "../../../../../../hooks/useOperationState.tsx";
import { UserTheme } from "../../../../../../contexts/operationStateReducer.tsx";
import styled from "styled-components";
import { Colors } from "../../../../../../styles/Colors.tsx";

type DataGridSwitchProps = {
onClick: ChangeEventHandler<HTMLInputElement>;
Expand All @@ -13,19 +15,26 @@ const DataGridSwitch: FC<DataGridSwitchProps> = ({
onClick,
dataGridActive
}) => {
const isCompact =
useOperationState().operationState.theme === UserTheme.Compact;
const { theme, colors } = useOperationState().operationState;
const isCompact = theme === UserTheme.Compact;

return (
<Stack direction="row" alignItems="center" justifyContent="flex-start">
<Switch
<StyledSwitch
checked={dataGridActive}
onChange={onClick}
size={isCompact ? "small" : "default"}
label="Use data grid view"
colors={colors}
/>
</Stack>
);
};

const StyledSwitch = styled(Switch)<{ colors: Colors }>`
& > span:nth-child(2) {
color: ${({ colors }) => colors.interactive.primaryResting};
}
`;

export default DataGridSwitch;

0 comments on commit 24b338b

Please sign in to comment.