feat: pick select field option colors (#2748)

Closes #2433

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thaïs
2023-11-29 12:49:41 +01:00
committed by GitHub
parent aa4bd0146b
commit 3617abb0e6
14 changed files with 186 additions and 97 deletions

View File

@ -2,7 +2,7 @@ import styled from '@emotion/styled';
import { IconPlus } from '@/ui/display/icon';
import { Button } from '@/ui/input/button/components/Button';
import { mainColors, ThemeColor } from '@/ui/theme/constants/colors';
import { mainColorNames, ThemeColor } from '@/ui/theme/constants/colors';
import { SettingsObjectFieldSelectFormOption } from '../types/SettingsObjectFieldSelectFormOption';
@ -46,9 +46,11 @@ const StyledButton = styled(Button)`
`;
const getNextColor = (currentColor: ThemeColor) => {
const colors = Object.keys(mainColors) as ThemeColor[];
const currentColorIndex = colors.findIndex((color) => color === currentColor);
return colors[(currentColorIndex + 1) % colors.length];
const currentColorIndex = mainColorNames.findIndex(
(color) => color === currentColor,
);
const nextColorIndex = (currentColorIndex + 1) % mainColorNames.length;
return mainColorNames[nextColorIndex];
};
export const SettingsObjectFieldSelectForm = ({