diff --git a/.changeset/famous-shrimps-change.md b/.changeset/famous-shrimps-change.md new file mode 100644 index 0000000000..b933abab69 --- /dev/null +++ b/.changeset/famous-shrimps-change.md @@ -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. diff --git a/packages/components/inputs/input-utils/src/styles.ts b/packages/components/inputs/input-utils/src/styles.ts index d8f105ede5..4f1ba92169 100644 --- a/packages/components/inputs/input-utils/src/styles.ts +++ b/packages/components/inputs/input-utils/src/styles.ts @@ -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; @@ -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 */ diff --git a/packages/components/inputs/text-input/README.md b/packages/components/inputs/text-input/README.md index 56c48a9432..f697ec7147 100644 --- a/packages/components/inputs/text-input/README.md +++ b/packages/components/inputs/text-input/README.md @@ -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 | diff --git a/packages/components/inputs/text-input/src/text-input.story.js b/packages/components/inputs/text-input/src/text-input.story.js index fd8abfbb26..296dd9fd64 100644 --- a/packages/components/inputs/text-input/src/text-input.story.js +++ b/packages/components/inputs/text-input/src/text-input.story.js @@ -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)} diff --git a/packages/components/inputs/text-input/src/text-input.tsx b/packages/components/inputs/text-input/src/text-input.tsx index e3d197d04a..55a59472e5 100644 --- a/packages/components/inputs/text-input/src/text-input.tsx +++ b/packages/components/inputs/text-input/src/text-input.tsx @@ -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). */ diff --git a/packages/components/inputs/text-input/src/text-input.visualroute.jsx b/packages/components/inputs/text-input/src/text-input.visualroute.jsx index 8bdfbfce76..4e25fcf21a 100644 --- a/packages/components/inputs/text-input/src/text-input.visualroute.jsx +++ b/packages/components/inputs/text-input/src/text-input.visualroute.jsx @@ -86,5 +86,15 @@ export const component = () => ( hasWarning={true} /> + + {}} + isCondensed={true} + horizontalConstraint={7} + isDisabled={true} + hasWarning={true} + /> + );