Skip to content

Commit

Permalink
UI Kit | FE | TextInput add new isCondensed prop (#2778)
Browse files Browse the repository at this point in the history
* feat(text-input): add new isCondensed prop

* feat(text-input): remove commented out code

* feat(text-input): add PR feedback

* feat(text-input): add PR feedback

---------

Co-authored-by: Jonathan Creasman <[email protected]>
Co-authored-by: Carlos Cortizas <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2024
1 parent 9933003 commit 2c130c2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/famous-shrimps-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/input-utils': minor
'@commercetools-uikit/text-input': minor
---

Included a new property (**isCondensed**) which allows to render a more visually compact variant of the input.
13 changes: 10 additions & 3 deletions packages/components/inputs/input-utils/src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { css } from '@emotion/react';
import { designTokens } from '@commercetools-uikit/design-system';

type TInputProps = {
isCondensed?: boolean;
isDisabled?: boolean;
disabled?: boolean;
hasError?: boolean;
Expand Down Expand Up @@ -78,9 +79,15 @@ const getInputStyles = (props: TInputProps) => {
display: flex;
flex: 1;
font-family: inherit;
font-size: ${designTokens.fontSize30};
height: ${designTokens.heightForInput};
min-height: ${designTokens.heightForInput};
font-size: ${props.isCondensed
? `${designTokens.fontSize20}`
: `${designTokens.fontSize30}`};
height: ${props.isCondensed
? `${designTokens.heightForInputAsSmall}`
: `${designTokens.heightForInput}`};
min-height: ${props.isCondensed
? `${designTokens.heightForInputAsSmall}`
: `${designTokens.heightForInput}`};
opacity: ${props.isDisabled || props.disabled
? '1'
: 'unset'}; /* fix for mobile safari */
Expand Down
1 change: 1 addition & 0 deletions packages/components/inputs/text-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default Example;
| `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
| `isAutofocussed` | `boolean` | | | Focus the input on initial render |
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
| `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
| `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
| `hasError` | `boolean` | | | Indicates if the input has invalid values |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ storiesOf('Components|Inputs', module)
onChange(event.target.value);
}}
isAutofocussed={boolean('isAutofocussed', false)}
isCondensed={boolean('isCondensed', false)}
isDisabled={boolean('isDisabled', false)}
isReadOnly={boolean('isReadOnly', false)}
hasError={boolean('hasError', false)}
Expand Down
4 changes: 4 additions & 0 deletions packages/components/inputs/text-input/src/text-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export type TTextInputProps = {
* Focus the input on initial render
*/
isAutofocussed?: boolean;
/**
* Use this property to reduce the paddings of the component for a ui compact variant
*/
isCondensed?: boolean;
/**
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,15 @@ export const component = () => (
hasWarning={true}
/>
</Spec>
<Spec label="with isCondensed">
<TextInput
value={value}
onChange={() => {}}
isCondensed={true}
horizontalConstraint={7}
isDisabled={true}
hasWarning={true}
/>
</Spec>
</Suite>
);

0 comments on commit 2c130c2

Please sign in to comment.