feat: add Color calendar setting (#4141)

* feat: add Color calendar setting

Closes #4067

* fix: fix wrong imports

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thaïs
2024-02-24 08:34:56 -03:00
committed by GitHub
parent 0fe838d320
commit a993155fb0
5 changed files with 115 additions and 5 deletions

View File

@ -0,0 +1,44 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import {
ColorSample,
ColorSampleProps,
} from '@/ui/display/color/components/ColorSample';
import {
LightIconButton,
LightIconButtonProps,
} from '@/ui/input/button/components/LightIconButton';
type ColorPickerButtonProps = Pick<ColorSampleProps, 'colorName'> &
Pick<LightIconButtonProps, 'onClick'> & {
isSelected?: boolean;
};
const StyledButton = styled(LightIconButton)<{
isSelected?: boolean;
}>`
${({ isSelected, theme }) =>
isSelected
? css`
background-color: ${theme.background.transparent.medium};
&:hover {
background-color: ${theme.background.transparent.medium};
}
`
: ''}
`;
export const ColorPickerButton = ({
colorName,
isSelected,
onClick,
}: ColorPickerButtonProps) => (
<StyledButton
size="medium"
isSelected={isSelected}
Icon={() => <ColorSample colorName={colorName} />}
onClick={onClick}
/>
);

View File

@ -0,0 +1,19 @@
import { Meta, StoryObj } from '@storybook/react';
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
import { ColorPickerButton } from '../ColorPickerButton';
const meta: Meta<typeof ColorPickerButton> = {
title: 'UI/Input/Button/ColorPickerButton',
component: ColorPickerButton,
decorators: [ComponentDecorator],
args: { colorName: 'green' },
};
export default meta;
type Story = StoryObj<typeof ColorPickerButton>;
export const Default: Story = {};
export const Selected: Story = { args: { isSelected: true } };