Skip to content

Commit

Permalink
feat(localized-text-input): add support for isCondensed prop in Local…
Browse files Browse the repository at this point in the history
…izedTextInput component
  • Loading branch information
Sarah4VT committed Apr 22, 2024
1 parent d30700f commit 8c70390
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-students-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/localized-text-input': minor
---

Add support for isCondensed prop to LocalizedTextInput
1 change: 1 addition & 0 deletions packages/components/inputs/localized-text-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default Example;
| `hideLanguageExpansionControls` | `boolean` | | | Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true`. |
| `defaultExpandLanguages` | `boolean` | | | Controls whether one or all languages are visible by default |
| `isAutofocussed` | `boolean` | | | Focus the input field on initial render |
| `isCondensed` | `boolean` | | | Whether the input and options are rendered with condensed paddings |
| `isDisabled` | `boolean` | | | Disables all input fields. |
| `isReadOnly` | `boolean` | | | Disables all input fields and shows them in read-only mode. |
| `placeholder` | `Record` | | | Placeholders for each language. Object of the same shape as `value`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ storiesOf('Components|Inputs', module)
defaultExpandLanguages || undefined
}
isAutofocussed={boolean('isAutofocussed', false)}
isCondensed={boolean('isCondensed', false)}
isDisabled={boolean('isDisabled', false)}
isReadOnly={boolean('isReadOnly', false)}
placeholder={object('placeholder', { en: '', de: '' })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ const getLanguageLabelStyles = (props: TLocalizedInputProps) => {
box-sizing: border-box;
color: ${designTokens.colorNeutral60};
cursor: ${props.isDisabled ? 'not-allowed' : 'default'};
height: ${designTokens.heightForInput};
font-size: ${designTokens.fontSize30};
height: ${props.isCondensed
? designTokens.heightForInputAsSmall
: designTokens.heightForInput};
font-size: ${props.isCondensed
? designTokens.fontSize20
: designTokens.fontSize30};
background-color: ${getLanguageLabelBackgroundColor(props)};
border-top-left-radius: ${designTokens.borderRadiusForInput};
border-bottom-left-radius: ${designTokens.borderRadiusForInput};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export type TLocalizedTextInputProps = {
* Focus the input field on initial render
*/
isAutofocussed?: boolean;
/**
* Use this property to reduce the paddings of the component for a ui compact variant
*/
isCondensed?: boolean;
/**
* Disables all input fields.
*/
Expand Down Expand Up @@ -177,6 +181,7 @@ export type TLocalizedInputProps = {
onBlur?: FocusEventHandler<HTMLInputElement>;
onFocus?: FocusEventHandler<HTMLInputElement>;
isAutofocussed?: boolean;
isCondensed?: boolean;
isDisabled?: boolean;
isReadOnly?: boolean;
hasError?: boolean;
Expand Down Expand Up @@ -330,6 +335,7 @@ const LocalizedTextInput = (props: TLocalizedTextInputProps) => {
onBlur={props.onBlur}
onFocus={props.onFocus}
isAutofocussed={index === 0 && props.isAutofocussed}
isCondensed={props.isCondensed}
isDisabled={props.isDisabled}
isReadOnly={props.isReadOnly}
hasError={Boolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ export const component = () => (
isDisabled={true}
/>
</Spec>
<Spec label="when isCondensed and open">
<LocalizedTextInput
value={value}
onChange={() => {}}
selectedLanguage="en"
horizontalConstraint={7}
isCondensed={true}
defaultExpandLanguages={true}
/>
</Spec>
<Spec label="when isCondensed and closed">
<LocalizedTextInput
value={value}
onChange={() => {}}
selectedLanguage="en"
horizontalConstraint={7}
isCondensed={true}
/>
</Spec>
<Spec label="when there is an error for a specific language (first one)">
<LocalizedTextInput
value={value}
Expand Down

0 comments on commit 8c70390

Please sign in to comment.