Skip to content

Commit

Permalink
feat: add Color calendar setting
Browse files Browse the repository at this point in the history
Closes #4067
  • Loading branch information
thaisguigon committed Feb 22, 2024
1 parent 09a39eb commit 906775e
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 6 deletions.
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>
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { ThemeColor } from '@/ui/theme/constants/colors';

export type ColorSampleVariant = 'default' | 'pipeline';

const StyledColorSample = styled.div<{
export type ColorSampleProps = {
colorName: ThemeColor;
variant?: ColorSampleVariant;
}>`
};

const StyledColorSample = styled.div<ColorSampleProps>`
background-color: ${({ theme, colorName }) =>
theme.tag.background[colorName]};
border: 1px solid ${({ theme, colorName }) => theme.tag.text[colorName]};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { LightIconButton, LightIconButtonProps } from 'tsup.ui.index';

import {
ColorSample,
ColorSampleProps,
} from '@/ui/display/color/components/ColorSample';

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}
/>
);
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 } };
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useParams } from 'react-router-dom';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { Section } from '@react-email/components';

import {
EventSettingsVisibilityValue,
SettingsAccountsEventVisibilitySettingsCard,
} from '@/settings/accounts/components/SettingsAccountsCalendarVisibilitySettingsCard';
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
import { SettingsAccountsColorSettingCard } from '@/settings/accounts/components/SettingsAccountsColorSettingCard';
import { SettingsAccountsToggleSettingCard } from '@/settings/accounts/components/SettingsAccountsToggleSettingCard';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
import { SettingsPath } from '@/types/SettingsPath';
import { IconRefresh, IconSettings, IconUser } from '@/ui/display/icon';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
import { Section } from '@/ui/layout/section/components/Section';
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
import { mockedConnectedAccounts } from '~/testing/mock-data/accounts';

Expand Down Expand Up @@ -45,14 +46,24 @@ export const SettingsAccountsCalendarsSettings = () => {
{ children: connectedAccount?.handle || '' },
]}
/>
<Section>
<H2Title
title="Color"
description="Define the color associated with this calendar"
/>
<SettingsAccountsColorSettingCard
value="blue"
onChange={(_colorName) => {}}
/>
</Section>
<Section>
<H2Title
title="Event visibility"
description="Define what will be visible to other users in your workspace"
/>
<SettingsAccountsEventVisibilitySettingsCard
value={EventSettingsVisibilityValue.Everything}
onChange={() => {}}
onChange={(_value) => {}}
/>
</Section>
<Section>
Expand All @@ -71,7 +82,7 @@ export const SettingsAccountsCalendarsSettings = () => {
}
title="Auto-creation"
value={false}
onToggle={() => {}}
onToggle={(_value) => {}}
/>
</Section>
<Section>
Expand All @@ -90,7 +101,7 @@ export const SettingsAccountsCalendarsSettings = () => {
}
title="Sync events"
value={false}
onToggle={() => {}}
onToggle={(_value) => {}}
/>
</Section>
</SettingsPageContainer>
Expand Down

0 comments on commit 906775e

Please sign in to comment.