b2be2fb398
Followup of @bosiraphael's design <img width="333" alt="Screenshot 2024-12-06 at 17 25 45" src="https://github.com/user-attachments/assets/b744a7a6-99cb-4d4c-b9da-df0661536208"> <img width="614" alt="Screenshot 2024-12-06 at 17 26 19" src="https://github.com/user-attachments/assets/e9f31fed-66b2-4ed7-a5cd-97a9bc526752"> --------- Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import { IconPoint } from '@ui/display';
|
|
import { Toggle } from '@ui/input';
|
|
import { MAIN_COLORS } from '@ui/theme';
|
|
import { useId } from 'react';
|
|
|
|
const StyledContainer = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
width: 100%;
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
position: relative;
|
|
`;
|
|
|
|
const StyledLabel = styled.label`
|
|
color: ${({ theme }) => theme.font.color.secondary};
|
|
font-size: ${({ theme }) => theme.font.size.sm};
|
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
|
padding: ${({ theme }) => theme.spacing(1)};
|
|
`;
|
|
|
|
const StyledIconContainer = styled.div`
|
|
height: 16px;
|
|
position: absolute;
|
|
left: ${({ theme }) => theme.spacing(-3)};
|
|
`;
|
|
|
|
const StyledToggleContainer = styled.div`
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
width: 100%;
|
|
`;
|
|
|
|
const StyledIconPoint = styled(IconPoint)`
|
|
margin-right: 0;
|
|
`;
|
|
|
|
type AdvancedSettingsToggleProps = {
|
|
isAdvancedModeEnabled: boolean;
|
|
setIsAdvancedModeEnabled: (enabled: boolean) => void;
|
|
};
|
|
|
|
export const AdvancedSettingsToggle = ({
|
|
isAdvancedModeEnabled,
|
|
setIsAdvancedModeEnabled,
|
|
}: AdvancedSettingsToggleProps) => {
|
|
const onChange = (newValue: boolean) => {
|
|
setIsAdvancedModeEnabled(newValue);
|
|
};
|
|
const inputId = useId();
|
|
|
|
return (
|
|
<StyledContainer>
|
|
<StyledIconContainer>
|
|
<StyledIconPoint
|
|
size={12}
|
|
color={MAIN_COLORS.yellow}
|
|
fill={MAIN_COLORS.yellow}
|
|
/>
|
|
</StyledIconContainer>
|
|
<StyledToggleContainer>
|
|
<StyledLabel htmlFor={inputId}>Advanced:</StyledLabel>
|
|
|
|
<Toggle
|
|
id={inputId}
|
|
onChange={onChange}
|
|
color={MAIN_COLORS.yellow}
|
|
value={isAdvancedModeEnabled}
|
|
/>
|
|
</StyledToggleContainer>
|
|
</StyledContainer>
|
|
);
|
|
};
|