Skip to content

Commit

Permalink
style: Add direction ltr for email and url for rtl languages
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Dec 28, 2024
1 parent d517683 commit 39deacb
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { SerializedStyles } from '@emotion/react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import type { CSSProperties, ReactNode, HTMLInputTypeAttribute } from 'react';
import type { CSSProperties, ReactNode } from 'react';

/**
* Internal dependencies
Expand Down Expand Up @@ -141,7 +141,6 @@ type InputProps = {
dragCursor?: CSSProperties[ 'cursor' ];
paddingInlineStart?: CSSProperties[ 'paddingInlineStart' ];
paddingInlineEnd?: CSSProperties[ 'paddingInlineEnd' ];
type?: HTMLInputTypeAttribute;
};

const disabledStyles = ( { disabled }: InputProps ) => {
Expand All @@ -154,15 +153,6 @@ const disabledStyles = ( { disabled }: InputProps ) => {
} );
};

const directionStyles = ( { type }: InputProps ) => {
if ( type !== 'url' && type !== 'email' ) {
return '';
}
return css`
direction: ltr;
`;
};

export const fontSizeStyles = ( { inputSize: size }: InputProps ) => {
const sizes = {
default: '13px',
Expand Down Expand Up @@ -293,11 +283,16 @@ export const Input = styled.input< InputProps >`
${ fontSizeStyles }
${ sizeStyles }
${ customPaddings }
${ directionStyles }
&::-webkit-input-placeholder {
line-height: normal;
}
&[type='email'],
&[type='url'] {
/* rtl:ignore */
direction: ltr;
}
}
`;

Expand Down

0 comments on commit 39deacb

Please sign in to comment.