Advanced toggle alignment (#10844)

This PR address advanced toggle alignment, especially the left yellow
dot placement.
In other advanced settings navigation drawer, the dot appears -20px to
left, while this was not the case for advanced toggle's dot.
Matched the height and paddings to that of NavigationDrawerItem.

@Bonapara FYI

before:
<img width="399" alt="Screenshot 2025-03-13 at 15 49 21"
src="https://github.com/user-attachments/assets/6dd60b3a-1b2e-43a0-ad28-dc44437460ab"
/>

after:
<img width="401" alt="Screenshot 2025-03-13 at 15 47 43"
src="https://github.com/user-attachments/assets/86e51b07-e84a-413a-8a49-1820c165dc68"
/>

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
nitin
2025-03-14 22:58:14 +05:30
committed by GitHub
parent c833b1c449
commit f44f42e9a0
7 changed files with 35 additions and 34 deletions

View File

@ -4,26 +4,27 @@ import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { AnimatedExpandableContainer, IconPoint, MAIN_COLORS } from 'twenty-ui'; import { AnimatedExpandableContainer, IconPoint, MAIN_COLORS } from 'twenty-ui';
type DotPosition = 'top' | 'centered';
const StyledAdvancedWrapper = styled.div` const StyledAdvancedWrapper = styled.div`
position: relative; position: relative;
width: 100%; width: 100%;
`; `;
const StyledIconContainer = styled.div<{ navigationDrawerItem: boolean }>` const StyledDotContainer = styled.div<{ dotPosition: DotPosition }>`
display: flex; display: flex;
position: absolute; position: absolute;
height: 100%;
left: ${({ theme }) => theme.spacing(-5)};
${({ navigationDrawerItem, theme }) => { ${({ dotPosition }) => {
if (navigationDrawerItem) { if (dotPosition === 'top') {
return ` return `
height: 100%; top: 0;
left: ${theme.spacing(-5)};
align-items: center;
`; `;
} }
return ` return `
left: ${theme.spacing(-4)}; align-items: center;
top: ${theme.spacing(1)};
`; `;
}} }}
`; `;
@ -38,36 +39,35 @@ const StyledIconPoint = styled(IconPoint)`
type AdvancedSettingsWrapperProps = { type AdvancedSettingsWrapperProps = {
children: React.ReactNode; children: React.ReactNode;
dimension?: 'width' | 'height'; animationDimension?: 'width' | 'height';
hideIcon?: boolean; hideDot?: boolean;
navigationDrawerItem?: boolean; dotPosition?: DotPosition;
}; };
export const AdvancedSettingsWrapper = ({ export const AdvancedSettingsWrapper = ({
children, children,
dimension = 'height', hideDot = false,
hideIcon = false, dotPosition = 'centered',
navigationDrawerItem = false,
}: AdvancedSettingsWrapperProps) => { }: AdvancedSettingsWrapperProps) => {
const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState); const isAdvancedModeEnabled = useRecoilValue(isAdvancedModeEnabledState);
return ( return (
<AnimatedExpandableContainer <AnimatedExpandableContainer
isExpanded={isAdvancedModeEnabled} isExpanded={isAdvancedModeEnabled}
dimension={dimension} dimension="height"
animationDurations={ADVANCED_SETTINGS_ANIMATION_DURATION} animationDurations={ADVANCED_SETTINGS_ANIMATION_DURATION}
mode="scroll-height" mode="scroll-height"
containAnimation={false} containAnimation={false}
> >
<StyledAdvancedWrapper> <StyledAdvancedWrapper>
{!hideIcon && ( {!hideDot && (
<StyledIconContainer navigationDrawerItem={navigationDrawerItem}> <StyledDotContainer dotPosition={dotPosition}>
<StyledIconPoint <StyledIconPoint
size={12} size={12}
color={MAIN_COLORS.yellow} color={MAIN_COLORS.yellow}
fill={MAIN_COLORS.yellow} fill={MAIN_COLORS.yellow}
/> />
</StyledIconContainer> </StyledDotContainer>
)} )}
<StyledContent>{children}</StyledContent> <StyledContent>{children}</StyledContent>
</StyledAdvancedWrapper> </StyledAdvancedWrapper>

View File

@ -29,7 +29,7 @@ export const SettingsNavigationDrawerItem = ({
if (isDefined(item.isAdvanced) && item.isAdvanced) { if (isDefined(item.isAdvanced) && item.isAdvanced) {
return ( return (
<AdvancedSettingsWrapper navigationDrawerItem> <AdvancedSettingsWrapper>
<NavigationDrawerItem <NavigationDrawerItem
indentationLevel={item.indentationLevel} indentationLevel={item.indentationLevel}
subItemState={subItemState} subItemState={subItemState}

View File

@ -44,7 +44,7 @@ export const SettingsNavigationDrawerItems = () => {
return ( return (
<NavigationDrawerSection key={section.label}> <NavigationDrawerSection key={section.label}>
{section.isAdvanced ? ( {section.isAdvanced ? (
<AdvancedSettingsWrapper hideIcon> <AdvancedSettingsWrapper hideDot>
<NavigationDrawerSectionTitle label={section.label} /> <NavigationDrawerSectionTitle label={section.label} />
</AdvancedSettingsWrapper> </AdvancedSettingsWrapper>
) : ( ) : (

View File

@ -30,9 +30,9 @@ import { applySimpleQuotesToString } from '~/utils/string/applySimpleQuotesToStr
import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper'; import { AdvancedSettingsWrapper } from '@/settings/components/AdvancedSettingsWrapper';
import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState'; import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState';
import { t } from '@lingui/core/macro';
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { SettingsDataModelFieldSelectFormOptionRow } from './SettingsDataModelFieldSelectFormOptionRow'; import { SettingsDataModelFieldSelectFormOptionRow } from './SettingsDataModelFieldSelectFormOptionRow';
import { t } from '@lingui/core/macro';
export const settingsDataModelFieldSelectFormSchema = z.object({ export const settingsDataModelFieldSelectFormSchema = z.object({
defaultValue: selectFieldDefaultValueSchema(), defaultValue: selectFieldDefaultValueSchema(),
@ -251,7 +251,7 @@ export const SettingsDataModelFieldSelectForm = ({
<> <>
<StyledContainer> <StyledContainer>
<StyledLabelContainer> <StyledLabelContainer>
<AdvancedSettingsWrapper dimension="width" hideIcon={true}> <AdvancedSettingsWrapper animationDimension="width" hideDot>
<StyledApiKeyContainer> <StyledApiKeyContainer>
<StyledIconContainer> <StyledIconContainer>
<StyledIconPoint <StyledIconPoint

View File

@ -8,6 +8,7 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown'; import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { t } from '@lingui/core/macro';
import { import {
ColorSample, ColorSample,
IconCheck, IconCheck,
@ -21,7 +22,6 @@ import {
MenuItemSelectColor, MenuItemSelectColor,
} from 'twenty-ui'; } from 'twenty-ui';
import { computeOptionValueFromLabel } from '~/pages/settings/data-model/utils/compute-option-value-from-label.utils'; import { computeOptionValueFromLabel } from '~/pages/settings/data-model/utils/compute-option-value-from-label.utils';
import { t } from '@lingui/core/macro';
type SettingsDataModelFieldSelectFormOptionRowProps = { type SettingsDataModelFieldSelectFormOptionRowProps = {
className?: string; className?: string;
@ -102,7 +102,7 @@ export const SettingsDataModelFieldSelectFormOptionRow = ({
stroke={theme.icon.stroke.sm} stroke={theme.icon.stroke.sm}
color={theme.font.color.extraLight} color={theme.font.color.extraLight}
/> />
<AdvancedSettingsWrapper dimension="width" hideIcon={true}> <AdvancedSettingsWrapper animationDimension="width" hideDot>
<StyledOptionInput <StyledOptionInput
value={option.value} value={option.value}
onChange={(input) => onChange={(input) =>

View File

@ -246,7 +246,10 @@ export const SettingsDataModelObjectAboutForm = ({
tooltip, tooltip,
defaultValue, defaultValue,
}) => ( }) => (
<AdvancedSettingsWrapper key={`object-${fieldName}-text-input`}> <AdvancedSettingsWrapper
key={`object-${fieldName}-text-input`}
dotPosition="top"
>
<StyledInputContainer> <StyledInputContainer>
<Controller <Controller
name={fieldName} name={fieldName}

View File

@ -4,25 +4,27 @@ import { IconPoint } from '@ui/display';
import { Toggle } from '@ui/input'; import { Toggle } from '@ui/input';
import { MAIN_COLORS } from '@ui/theme'; import { MAIN_COLORS } from '@ui/theme';
import { useId } from 'react'; import { useId } from 'react';
const StyledContainer = styled.div` const StyledContainer = styled.div`
align-items: center; align-items: center;
display: flex; display: flex;
width: 100%;
gap: ${({ theme }) => theme.spacing(2)}; gap: ${({ theme }) => theme.spacing(2)};
position: relative; position: relative;
height: ${({ theme }) => theme.spacing(5)};
padding: ${({ theme }) => theme.spacing(1)};
`; `;
const StyledText = styled.div` const StyledText = styled.div`
color: ${({ theme }) => theme.font.color.secondary}; color: ${({ theme }) => theme.font.color.secondary};
font-size: ${({ theme }) => theme.font.size.sm}; font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.medium}; font-weight: ${({ theme }) => theme.font.weight.medium};
padding: ${({ theme }) => theme.spacing(1)};
`; `;
const StyledIconContainer = styled.div` const StyledIconContainer = styled.div`
height: 16px; align-items: center;
display: flex;
left: ${({ theme }) => theme.spacing(-5)};
position: absolute; position: absolute;
left: ${({ theme }) => theme.spacing(-3)};
`; `;
const StyledToggleContainer = styled.label` const StyledToggleContainer = styled.label`
@ -33,10 +35,6 @@ const StyledToggleContainer = styled.label`
width: 100%; width: 100%;
`; `;
const StyledIconPoint = styled(IconPoint)`
margin-right: 0;
`;
type AdvancedSettingsToggleProps = { type AdvancedSettingsToggleProps = {
isAdvancedModeEnabled: boolean; isAdvancedModeEnabled: boolean;
setIsAdvancedModeEnabled: (enabled: boolean) => void; setIsAdvancedModeEnabled: (enabled: boolean) => void;
@ -55,7 +53,7 @@ export const AdvancedSettingsToggle = ({
return ( return (
<StyledContainer> <StyledContainer>
<StyledIconContainer> <StyledIconContainer>
<StyledIconPoint <IconPoint
size={12} size={12}
color={MAIN_COLORS.yellow} color={MAIN_COLORS.yellow}
fill={MAIN_COLORS.yellow} fill={MAIN_COLORS.yellow}