From 7d2b421047f4bd9dce2b9a9f74592f50552f73f6 Mon Sep 17 00:00:00 2001 From: Titani Date: Wed, 24 May 2023 10:22:07 -0400 Subject: [PATCH 1/5] feat(Input group): Simplified API --- .../components/InputGroup/InputGroupItem.tsx | 6 ++-- .../components/InputGroup/InputGroupText.tsx | 2 +- .../InputGroup/examples/InputGroup.md | 2 +- .../InputGroup/examples/InputGroupBasic.tsx | 20 +++--------- .../examples/InputGroupWithSiblings.tsx | 27 +++------------- .../src/components/InputGroup/index.ts | 1 - .../src/components/Slider/Slider.tsx | 8 ++--- .../__snapshots__/Slider.test.tsx.snap | 4 +-- .../cypress/integration/inputgroup.spec.ts | 4 --- .../demos/InputGroupDemo/InputGroupDemo.tsx | 31 +++++++------------ 10 files changed, 29 insertions(+), 76 deletions(-) diff --git a/packages/react-core/src/components/InputGroup/InputGroupItem.tsx b/packages/react-core/src/components/InputGroup/InputGroupItem.tsx index f3d4ebb205c..95406713942 100644 --- a/packages/react-core/src/components/InputGroup/InputGroupItem.tsx +++ b/packages/react-core/src/components/InputGroup/InputGroupItem.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import styles from '@patternfly/react-styles/css/components/InputGroup/input-group'; import { css } from '@patternfly/react-styles'; +import { InputGroupText } from './InputGroupText'; export interface InputGroupItemProps extends React.HTMLProps { /** Additional classes added to the input group item. */ @@ -15,11 +16,10 @@ export interface InputGroupItemProps extends React.HTMLProps { isFill?: boolean; /** Flag to indicate if the input group item is disabled. */ isDisabled?: boolean; - } export const InputGroupItem: React.FunctionComponent = ({ - className = '', + className, children, isFill = false, isBox = false, @@ -38,7 +38,7 @@ export const InputGroupItem: React.FunctionComponent = ({ )} {...props} > - {children} + {isBox ? {children} : children} ); InputGroupItem.displayName = 'InputGroupItem'; diff --git a/packages/react-core/src/components/InputGroup/InputGroupText.tsx b/packages/react-core/src/components/InputGroup/InputGroupText.tsx index 22b34fc8a46..e9000667b48 100644 --- a/packages/react-core/src/components/InputGroup/InputGroupText.tsx +++ b/packages/react-core/src/components/InputGroup/InputGroupText.tsx @@ -12,7 +12,7 @@ export interface InputGroupTextProps extends React.HTMLProps = ({ - className = '', + className, component = 'span', children, ...props diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroup.md b/packages/react-core/src/components/InputGroup/examples/InputGroup.md index 5095fe18168..e682570ab29 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroup.md +++ b/packages/react-core/src/components/InputGroup/examples/InputGroup.md @@ -2,7 +2,7 @@ id: Input group section: components cssPrefix: null -propComponents: ['InputGroup', 'InputGroupItem', 'InputGroupText'] +propComponents: ['InputGroup', 'InputGroupItem'] --- import AtIcon from '@patternfly/react-icons/dist/esm/icons/at-icon'; diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroupBasic.tsx b/packages/react-core/src/components/InputGroup/examples/InputGroupBasic.tsx index 08378fd11e3..37fc186036f 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroupBasic.tsx +++ b/packages/react-core/src/components/InputGroup/examples/InputGroupBasic.tsx @@ -1,12 +1,6 @@ import React from 'react'; import AtIcon from '@patternfly/react-icons/dist/esm/icons/at-icon'; -import { - InputGroup, - InputGroupText, - InputGroupItem, - TextInput, - ValidatedOptions -} from '@patternfly/react-core'; +import { InputGroup, InputGroupItem, TextInput, ValidatedOptions } from '@patternfly/react-core'; export const InputGroupBasic: React.FunctionComponent = () => ( @@ -14,16 +8,12 @@ export const InputGroupBasic: React.FunctionComponent = () => ( - - @example.com - + @example.com
- - - + ( - - % - + %
diff --git a/packages/react-core/src/components/InputGroup/examples/InputGroupWithSiblings.tsx b/packages/react-core/src/components/InputGroup/examples/InputGroupWithSiblings.tsx index 213d19c2bef..562b63a83d5 100644 --- a/packages/react-core/src/components/InputGroup/examples/InputGroupWithSiblings.tsx +++ b/packages/react-core/src/components/InputGroup/examples/InputGroupWithSiblings.tsx @@ -1,13 +1,6 @@ import React from 'react'; import DollarSignIcon from '@patternfly/react-icons/dist/esm/icons/dollar-sign-icon'; -import { - Button, - TextArea, - InputGroup, - InputGroupText, - InputGroupItem, - TextInput, -} from '@patternfly/react-core'; +import { Button, TextArea, InputGroup, InputGroupItem, TextInput } from '@patternfly/react-core'; export const InputGroupWithSiblings: React.FunctionComponent = () => ( @@ -18,11 +11,7 @@ export const InputGroupWithSiblings: React.FunctionComponent = () => ( -