mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 20:02:29 +00:00
Improve phone input UI (#8266)
[FIX] #8251 Changes made as suggested by @Bonapara.     For the `The country code should be Tertiary instead of Primary ` task, the library "react-phone-number-input" doesn't provide any out of the box functionality to style the country code. If the feature **needs** to be implemented here are the possible solution/workarounds: 1. Finding a more customizable library that allows to change the style of the country code OR 2. Implement custom country selection (😰...) OR 3. The lib allows a custom input element and a provides a function (onCountryChange) that triggers whenever the country changes (a country can be changed in two ways- 1. When the user deliberately chooses it from dropdown OR 2. Changes the code in the input) We'll have to get the length of the country code and then style the first X digits in the custom input field...   Let me know if someone has a better approach. --------- Co-authored-by: Thomas des Francs <tdesfrancs@gmail.com> Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@ const StyledCustomPhoneInput = styled(ReactPhoneNumberInput)`
|
||||
background: none;
|
||||
border: none;
|
||||
color: ${({ theme }) => theme.font.color.primary};
|
||||
margin-left: ${({ theme }) => theme.spacing(2)};
|
||||
|
||||
&::placeholder,
|
||||
&::-webkit-input-placeholder {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { IconChevronDown, IconWorld } from 'twenty-ui';
|
||||
|
||||
import { useCountries } from '@/ui/input/components/internal/hooks/useCountries';
|
||||
import { Country } from '@/ui/input/components/internal/types/Country';
|
||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { IconChevronDown, IconWorld } from 'twenty-ui';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { CountryPickerHotkeyScope } from '../types/CountryPickerHotkeyScope';
|
||||
@@ -31,9 +30,7 @@ const StyledDropdownButtonContainer = styled.div<StyledDropdownButtonProps>`
|
||||
height: 32px;
|
||||
|
||||
padding-left: ${({ theme }) => theme.spacing(2)};
|
||||
padding-right: ${({ theme }) => theme.spacing(2)};
|
||||
|
||||
padding-right: ${({ theme }) => theme.spacing(2)};
|
||||
padding-right: ${({ theme }) => theme.spacing(1)};
|
||||
user-select: none;
|
||||
|
||||
border-right: 1px solid ${({ theme }) => theme.border.color.light};
|
||||
@@ -47,13 +44,24 @@ const StyledIconContainer = styled.div`
|
||||
align-items: center;
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
gap: ${({ theme }) => theme.spacing(0.5)};
|
||||
justify-content: center;
|
||||
|
||||
svg {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
height: 12px;
|
||||
width: 16px;
|
||||
justify-content: center;
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledCheveronIconContainer = styled.div`
|
||||
svg {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
justify-content: center;
|
||||
}
|
||||
`;
|
||||
@@ -95,7 +103,9 @@ export const PhoneCountryPickerDropdownButton = ({
|
||||
<StyledDropdownButtonContainer isUnfolded={isDropdownOpen}>
|
||||
<StyledIconContainer>
|
||||
{selectedCountry ? <selectedCountry.Flag /> : <IconWorld />}
|
||||
<IconChevronDown size={theme.icon.size.sm} />
|
||||
<StyledCheveronIconContainer>
|
||||
<IconChevronDown size={theme.icon.size.sm} />
|
||||
</StyledCheveronIconContainer>
|
||||
</StyledIconContainer>
|
||||
</StyledDropdownButtonContainer>
|
||||
}
|
||||
|
||||
@@ -31,14 +31,13 @@ const StyledInput = styled.input<{
|
||||
|
||||
const StyledInputContainer = styled.div`
|
||||
box-sizing: border-box;
|
||||
padding: ${({ theme }) => theme.spacing(1)};
|
||||
position: relative;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const StyledRightContainer = styled.div`
|
||||
position: absolute;
|
||||
right: ${({ theme }) => theme.spacing(2)};
|
||||
right: ${({ theme }) => theme.spacing(1)};
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
`;
|
||||
|
||||
@@ -56,7 +56,7 @@ const StyledButton = styled.button<
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
height: ${({ size }) => (size === 'small' ? '24px' : '32px')};
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
padding: ${({ theme }) => theme.spacing(1)};
|
||||
transition: background 0.1s ease;
|
||||
|
||||
white-space: nowrap;
|
||||
|
||||
Reference in New Issue
Block a user