Skip to content

Commit d583c14

Browse files
committed
Improve left icon
1 parent c66f354 commit d583c14

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { useMemo, useState } from 'react';
33
import { useRecoilValue } from 'recoil';
44
import {
55
IconApps,
6-
IconComponent,
7-
useIcons,
86
IconButton,
97
IconButtonVariant,
8+
IconComponent,
109
LightIconButton,
10+
useIcons,
1111
} from 'twenty-ui';
1212

1313
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
@@ -99,7 +99,7 @@ export const IconPicker = ({
9999
setHotkeyScopeAndMemorizePreviousScope,
100100
} = usePreviousHotkeyScope();
101101

102-
const { closeDropdown } = useDropdown(dropdownId);
102+
const { closeDropdown, isDropdownOpen } = useDropdown(dropdownId);
103103

104104
const { getIcons, getIcon } = useIcons();
105105
const icons = getIcons();
@@ -169,6 +169,7 @@ export const IconPicker = ({
169169
disabled={disabled}
170170
Icon={icon}
171171
variant={variant}
172+
focus={isDropdownOpen}
172173
/>
173174
}
174175
dropdownMenuWidth={176}

packages/twenty-front/src/modules/ui/input/components/Select.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const Select = <Value extends string | number | null>({
9494
disabledFromProps ||
9595
(options.length <= 1 && !isDefined(callToActionButton));
9696

97-
const { closeDropdown } = useDropdown(dropdownId);
97+
const { closeDropdown, isDropdownOpen } = useDropdown(dropdownId);
9898

9999
const dropDownMenuWidth =
100100
dropdownWidthAuto && selectContainerRef.current?.clientWidth
@@ -114,6 +114,7 @@ export const Select = <Value extends string | number | null>({
114114
<SelectControl
115115
selectedOption={selectedOption}
116116
isDisabled={isDisabled}
117+
isDropdownOpen={false}
117118
/>
118119
) : (
119120
<Dropdown
@@ -124,6 +125,7 @@ export const Select = <Value extends string | number | null>({
124125
<SelectControl
125126
selectedOption={selectedOption}
126127
isDisabled={isDisabled}
128+
isDropdownOpen={isDropdownOpen}
127129
/>
128130
}
129131
disableBlur={disableBlur}

packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {
55
IconChevronDown,
66
isDefined,
77
OverflowingTextWithTooltip,
8+
RGBA,
89
} from 'twenty-ui';
910

1011
const StyledControlContainer = styled.div<{
1112
disabled?: boolean;
1213
hasIcon: boolean;
14+
isDropdownOpen: boolean;
1315
}>`
1416
display: grid;
1517
grid-template-columns: ${({ hasIcon }) =>
@@ -21,8 +23,12 @@ const StyledControlContainer = styled.div<{
2123
max-width: 100%;
2224
padding: 0 ${({ theme }) => theme.spacing(2)};
2325
background-color: ${({ theme }) => theme.background.transparent.lighter};
24-
border: 1px solid ${({ theme }) => theme.border.color.medium};
26+
border: 1px solid
27+
${({ theme, isDropdownOpen }) =>
28+
isDropdownOpen ? theme.color.blue : theme.border.color.medium};
2529
border-radius: ${({ theme }) => theme.border.radius.sm};
30+
box-shadow: ${({ theme, isDropdownOpen }) =>
31+
isDropdownOpen ? `0px 0px 0px 3px ${RGBA(theme.color.blue, 0.1)}` : ''};
2632
color: ${({ disabled, theme }) =>
2733
disabled ? theme.font.color.tertiary : theme.font.color.primary};
2834
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
@@ -39,18 +45,21 @@ const StyledIconChevronDown = styled(IconChevronDown)<{
3945
type SelectControlProps = {
4046
selectedOption: SelectOption<string | number | null>;
4147
isDisabled?: boolean;
48+
isDropdownOpen: boolean;
4249
};
4350

4451
export const SelectControl = ({
4552
selectedOption,
4653
isDisabled,
54+
isDropdownOpen,
4755
}: SelectControlProps) => {
4856
const theme = useTheme();
4957

5058
return (
5159
<StyledControlContainer
5260
disabled={isDisabled}
5361
hasIcon={isDefined(selectedOption.Icon)}
62+
isDropdownOpen={isDropdownOpen}
5463
>
5564
{isDefined(selectedOption.Icon) ? (
5665
<selectedOption.Icon

packages/twenty-front/src/modules/ui/input/components/TextInputV2.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ const StyledInput = styled.input<
4343
border: 1px solid
4444
${({ theme, error }) =>
4545
error ? theme.border.color.danger : theme.border.color.medium};
46-
border-left: ${({ LeftIcon }) => LeftIcon && 'none'};
47-
border-radius: ${({ theme, LeftIcon }) =>
48-
!LeftIcon && theme.border.radius.sm};
46+
border-radius: ${({ theme }) => theme.border.radius.sm};
4947
box-sizing: border-box;
5048
color: ${({ theme }) => theme.font.color.primary};
5149
display: flex;
@@ -55,6 +53,8 @@ const StyledInput = styled.input<
5553
height: 32px;
5654
outline: none;
5755
padding: ${({ theme }) => theme.spacing(2)};
56+
padding-left: ${({ theme, LeftIcon }) =>
57+
LeftIcon ? `calc(${theme.spacing(2)} + 16px)` : theme.spacing(2)};
5858
width: 100%;
5959
6060
&::placeholder,
@@ -84,14 +84,13 @@ const StyledErrorHelper = styled.div`
8484

8585
const StyledLeftIconContainer = styled.div`
8686
align-items: center;
87-
background-color: ${({ theme }) => theme.background.transparent.lighter};
88-
border: 1px solid ${({ theme }) => theme.border.color.medium};
89-
border-bottom-left-radius: ${({ theme }) => theme.border.radius.sm};
90-
border-right: none;
91-
border-top-left-radius: ${({ theme }) => theme.border.radius.sm};
9287
display: flex;
9388
justify-content: center;
9489
padding-left: ${({ theme }) => theme.spacing(2)};
90+
position: absolute;
91+
top: 0;
92+
bottom: 0;
93+
margin: auto 0;
9594
`;
9695

9796
const StyledTrailingIconContainer = styled.div<

0 commit comments

Comments
 (0)