Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings Option Card component #8456

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1653b45
WIP
ehconitin Nov 11, 2024
42c0923
cleanup
ehconitin Nov 11, 2024
629c475
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 11, 2024
23d973e
add back comment
ehconitin Nov 11, 2024
0944a1b
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 12, 2024
3cc8d8d
WIP
ehconitin Nov 12, 2024
670d338
fix wobble
ehconitin Nov 12, 2024
b489a8f
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 12, 2024
3306273
proof of concept for advanced settings wrapper
ehconitin Nov 12, 2024
74de6a7
lint
ehconitin Nov 13, 2024
2d835de
typo
ehconitin Nov 13, 2024
ecabb94
WIP
ehconitin Nov 13, 2024
909c558
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 13, 2024
919a625
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 13, 2024
a3709f1
grey illustration icons
ehconitin Nov 13, 2024
36ddd6c
select height variant
ehconitin Nov 14, 2024
1029de8
Merge branch 'main' into settings-options
charlesBochet Nov 14, 2024
2bbe7d5
Rebase on main
charlesBochet Nov 14, 2024
4f296e1
new icon
ehconitin Nov 14, 2024
c1e6cfe
remove icons
ehconitin Nov 14, 2024
e0ffe70
seperate components - seperate concern
ehconitin Nov 15, 2024
3e554f4
remove illustrations icon and add IconCustomizer
ehconitin Nov 15, 2024
70980e8
Merge remote-tracking branch 'upstream/main' into settings-options
ehconitin Nov 15, 2024
a3d3358
merge
ehconitin Nov 15, 2024
cac20d7
fix
ehconitin Nov 15, 2024
13d9bf9
line removed
ehconitin Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from '@emotion/styled';
type H2TitleProps = {
title: string;
description?: string;
addornment?: React.ReactNode;
adornment?: React.ReactNode;
};

const StyledContainer = styled.div`
Expand Down Expand Up @@ -33,11 +33,11 @@ const StyledDescription = styled.h3`
margin-top: ${({ theme }) => theme.spacing(3)};
`;

export const H2Title = ({ title, description, addornment }: H2TitleProps) => (
export const H2Title = ({ title, description, adornment }: H2TitleProps) => (
<StyledContainer>
<StyledTitleContainer>
<StyledTitle>{title}</StyledTitle>
{addornment}
{adornment}
</StyledTitleContainer>
{description && <StyledDescription>{description}</StyledDescription>}
</StyledContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CalendarChannel } from '@/accounts/types/CalendarChannel';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { SettingsAccountsEventVisibilitySettingsCard } from '@/settings/accounts/components/SettingsAccountsCalendarVisibilitySettingsCard';
import { SettingsOptionCardContent } from '@/settings/components/SettingsOptionCardContent';
import { SettingsOptionCardContentToggle } from '@/settings/components/SettingsOptions/SettingsOptionCardContentToggle';
import styled from '@emotion/styled';
import { Section } from '@react-email/components';
import { Card, H2Title } from 'twenty-ui';
import { Card, H2Title, IconUserPlus } from 'twenty-ui';
import { CalendarChannelVisibility } from '~/generated-metadata/graphql';

const StyledDetailsContainer = styled.div`
Expand Down Expand Up @@ -63,8 +63,9 @@ export const SettingsAccountsCalendarChannelDetails = ({
title="Contact auto-creation"
description="Automatically create contacts for people you've participated in an event with."
/>
<Card>
<SettingsOptionCardContent
<Card rounded>
<SettingsOptionCardContentToggle
Icon={IconUserPlus}
title="Auto-creation"
description="Automatically create contacts for people."
ehconitin marked this conversation as resolved.
Show resolved Hide resolved
checked={calendarChannel.isContactAutoCreationEnabled}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled';
import { Card, H2Title, Section } from 'twenty-ui';
import { Card, H2Title, IconBriefcase, IconUsers, Section } from 'twenty-ui';

import {
MessageChannel,
Expand All @@ -9,7 +9,7 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
import { SettingsAccountsMessageAutoCreationCard } from '@/settings/accounts/components/SettingsAccountsMessageAutoCreationCard';
import { SettingsAccountsMessageVisibilityCard } from '@/settings/accounts/components/SettingsAccountsMessageVisibilityCard';
import { SettingsOptionCardContent } from '@/settings/components/SettingsOptionCardContent';
import { SettingsOptionCardContentToggle } from '@/settings/components/SettingsOptions/SettingsOptionCardContentToggle';
import { MessageChannelVisibility } from '~/generated-metadata/graphql';

type SettingsAccountsMessageChannelDetailsProps = {
Expand Down Expand Up @@ -98,8 +98,9 @@ export const SettingsAccountsMessageChannelDetails = ({
/>
</Section>
<Section>
<Card>
<SettingsOptionCardContent
<Card rounded>
<SettingsOptionCardContentToggle
Icon={IconBriefcase}
title="Exclude non-professional emails"
description="Don’t create contacts from/to Gmail, Outlook emails"
ehconitin marked this conversation as resolved.
Show resolved Hide resolved
divider
Expand All @@ -110,7 +111,8 @@ export const SettingsAccountsMessageChannelDetails = ({
);
}}
/>
<SettingsOptionCardContent
<SettingsOptionCardContentToggle
Icon={IconUsers}
title="Exclude group emails"
description="Don’t sync emails from team@ support@ noreply@..."
ehconitin marked this conversation as resolved.
Show resolved Hide resolved
checked={messageChannel.excludeGroupEmails}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { useExpandedAnimation } from '@/settings/hooks/useExpandedAnimation';
import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState';
import styled from '@emotion/styled';
import { AnimatePresence, motion } from 'framer-motion';
import { useRecoilValue } from 'recoil';
import { IconTool, MAIN_COLORS } from 'twenty-ui';

const StyledAdvancedWrapper = styled.div`
position: relative;
width: 100%;
`;

const StyledIconContainer = styled.div`
border-right: 1px solid ${MAIN_COLORS.yellow};
display: flex;
height: 100%;
left: ${({ theme }) => theme.spacing(-6)};
position: absolute;
top: 0;
`;
ehconitin marked this conversation as resolved.
Show resolved Hide resolved

const StyledContent = styled.div`
width: 100%;
`;
const StyledIconTool = styled(IconTool)`
margin-right: ${({ theme }) => theme.spacing(0.5)};
`;
ehconitin marked this conversation as resolved.
Show resolved Hide resolved

type AdvancedSettingsWrapperProps = {
children: React.ReactNode;
dimension?: 'width' | 'height';
hideIcon?: boolean;
};

export const AdvancedSettingsWrapper = ({
children,
dimension = 'height',
hideIcon = false,
}: AdvancedSettingsWrapperProps) => {
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState);
const { contentRef, motionAnimationVariants } = useExpandedAnimation(
isAdvancedModeEnabled,
dimension,
);

return (
<AnimatePresence>
{isAdvancedModeEnabled && (
<motion.div
ref={contentRef}
initial="initial"
animate="animate"
exit="exit"
variants={motionAnimationVariants}
>
<StyledAdvancedWrapper>
{!hideIcon && (
<StyledIconContainer>
<StyledIconTool size={12} color={MAIN_COLORS.yellow} />
</StyledIconContainer>
)}
<StyledContent>{children}</StyledContent>
</StyledAdvancedWrapper>
</motion.div>
)}
</AnimatePresence>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { TextInput } from '@/ui/input/components/TextInput';
import styled from '@emotion/styled';
import { Button, IconMinus, IconPlus } from 'twenty-ui';
import { castAsNumberOrNull } from '~/utils/cast-as-number-or-null';

type SettingsCounterProps = {
value: number;
onChange: (value: number) => void;
minValue?: number;
maxValue?: number;
disabled?: boolean;
};

const StyledCounterContainer = styled.div`
align-items: center;
display: flex;
gap: ${({ theme }) => theme.spacing(1)};
margin-left: auto;
width: ${({ theme }) => theme.spacing(30)};
`;

const StyledTextInput = styled(TextInput)`
width: ${({ theme }) => theme.spacing(16)};
input {
width: ${({ theme }) => theme.spacing(16)};
height: ${({ theme }) => theme.spacing(6)};
text-align: center;
font-weight: ${({ theme }) => theme.font.weight.medium};
}
`;

const StyledControlButton = styled(Button)`
height: ${({ theme }) => theme.spacing(6)};
width: ${({ theme }) => theme.spacing(6)};
padding: 0;
justify-content: center;
svg {
height: ${({ theme }) => theme.spacing(4)};
width: ${({ theme }) => theme.spacing(4)};
}
`;

export const SettingsCounter = ({
value,
onChange,
minValue = 0,
maxValue = 100,
disabled = false,
}: SettingsCounterProps) => {
const handleIncrementCounter = () => {
if (value < maxValue) {
onChange(value + 1);
}
};

const handleDecrementCounter = () => {
if (value > minValue) {
onChange(value - 1);
}
};

const handleTextInputChange = (value: string) => {
const castedNumber = castAsNumberOrNull(value);
if (castedNumber === null) {
onChange(minValue);
return;
}

if (castedNumber < minValue) {
return;
}
ehconitin marked this conversation as resolved.
Show resolved Hide resolved

if (castedNumber > maxValue) {
onChange(maxValue);
return;
}
onChange(castedNumber);
};

return (
<StyledCounterContainer>
<StyledControlButton
variant="secondary"
onClick={handleDecrementCounter}
Icon={IconMinus}
disabled={disabled}
/>
<StyledTextInput
name="counter"
fullWidth
value={value.toString()}
onChange={handleTextInputChange}
disabled={disabled}
/>
ehconitin marked this conversation as resolved.
Show resolved Hide resolved
<StyledControlButton
variant="secondary"
onClick={handleIncrementCounter}
Icon={IconPlus}
disabled={disabled}
/>
</StyledCounterContainer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { useAuth } from '@/auth/hooks/useAuth';
import { billingState } from '@/client-config/states/billingState';
import { SettingsNavigationDrawerItem } from '@/settings/components/SettingsNavigationDrawerItem';
import { useExpandedHeightAnimation } from '@/settings/hooks/useExpandedHeightAnimation';
import { useExpandedAnimation } from '@/settings/hooks/useExpandedAnimation';
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
import { SettingsPath } from '@/types/SettingsPath';
import {
Expand Down Expand Up @@ -69,7 +69,7 @@ const StyledIconTool = styled(IconTool)`

export const SettingsNavigationDrawerItems = () => {
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState);
const { contentRef, motionAnimationVariants } = useExpandedHeightAnimation(
const { contentRef, motionAnimationVariants } = useExpandedAnimation(
isAdvancedModeEnabled,
);
ehconitin marked this conversation as resolved.
Show resolved Hide resolved
const { signOut } = useAuth();
Expand Down

This file was deleted.

Loading
Loading