-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
0fe838d
commit a993155
Showing
5 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...wenty-front/src/modules/settings/accounts/components/SettingsAccountsColorSettingCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import { ColorPickerButton } from '@/ui/input/button/components/ColorPickerButton'; | ||
import { Card } from '@/ui/layout/card/components/Card'; | ||
import { CardContent } from '@/ui/layout/card/components/CardContent'; | ||
import { mainColorNames, ThemeColor } from '@/ui/theme/constants/colors'; | ||
|
||
type SettingsAccountsColorSettingCardProps = { | ||
onChange: (nextValue: ThemeColor) => void; | ||
value: ThemeColor; | ||
}; | ||
|
||
const StyledCardContent = styled(CardContent)` | ||
display: flex; | ||
padding: ${({ theme }) => theme.spacing(2, 4)}; | ||
justify-content: space-between; | ||
`; | ||
|
||
export const SettingsAccountsColorSettingCard = ({ | ||
onChange, | ||
value, | ||
}: SettingsAccountsColorSettingCardProps) => ( | ||
<Card> | ||
<StyledCardContent> | ||
{mainColorNames.map((colorName) => ( | ||
<ColorPickerButton | ||
colorName={colorName} | ||
isSelected={value === colorName} | ||
onClick={() => onChange(colorName)} | ||
/> | ||
))} | ||
</StyledCardContent> | ||
</Card> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/twenty-front/src/modules/ui/input/button/components/ColorPickerButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
/> | ||
); |
19 changes: 19 additions & 0 deletions
19
...ty-front/src/modules/ui/input/button/components/__stories__/ColorPickerButton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters