Skip to content

Commit

Permalink
fix: Add directionStyles for input-control-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
im3dabasia committed Dec 27, 2024
1 parent 645a8ed commit d517683
Showing 1 changed file with 12 additions and 7 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 } from 'react';
import type { CSSProperties, ReactNode, HTMLInputTypeAttribute } from 'react';

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

const disabledStyles = ( { disabled }: InputProps ) => {
Expand All @@ -153,6 +154,15 @@ 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 @@ -283,16 +293,11 @@ 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 d517683

Please sign in to comment.