Skip to content

Commit

Permalink
feat(search-select-input): add isCondensed prop to SearchSelectInput …
Browse files Browse the repository at this point in the history
…component (#2801)
  • Loading branch information
Sarah4VT authored May 2, 2024
1 parent 4013cd3 commit 91a86d8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/four-gifts-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/search-select-input': minor
'@commercetools-uikit/select-utils': minor
---

Add support for isCondensed prop on SearchSelectInput component
1 change: 1 addition & 0 deletions packages/components/inputs/search-select-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default Example;
| `isReadOnly` | `boolean` | | | Is the select read-only |
| `isDisabled` | `boolean` | | | Is the select disabled |
| `isClearable` | `boolean` | | | Is the select value clearable |
| `isCondensed` | `boolean` | | | Whether the input and options are rendered with condensed paddings |
| `isOptionDisabled` | `AsyncProps['isOptionDisabled']` | | | Override the built-in logic to detect whether an option is disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isMulti` | `AsyncProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted. Renamed autoFocus of react-select |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class SearchSelectInputStory extends Component {
id={text('id', '')}
containerId={text('containerId', '')}
isClearable={boolean('isClearable', false)}
isCondensed={boolean('isCondensed', false)}
isDisabled={boolean('isDisabled', false)}
isReadOnly={boolean('isReadOnly', false)}
isMulti={isMulti}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { designTokens } from '@commercetools-uikit/design-system';
import type { TSearchSelectInputProps } from './search-select-input';

const SearchSelectInputWrapper = styled.div<
Pick<TSearchSelectInputProps, 'isDisabled' | 'isReadOnly'>
Pick<TSearchSelectInputProps, 'isDisabled' | 'isReadOnly' | 'isCondensed'>
>`
${(props) =>
!props.isDisabled && !props.isReadOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export type TSearchSelectInputProps = {
* Is the select value clearable
*/
isClearable?: boolean;
/**
* Whether the input and options are rendered with condensed paddings
*/
isCondensed?: boolean;
/**
* Override the built-in logic to detect whether an option is disabled
* <br>
Expand Down Expand Up @@ -337,6 +341,7 @@ const SearchSelectInput = (props: TSearchSelectInputProps) => {
<SearchSelectInputWrapper
isDisabled={props.isDisabled}
isReadOnly={props.isReadOnly}
isCondensed={props.isCondensed}
>
<AsyncSelectInput
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ export const component = () => (
isClearable={true}
/>
</Spec>
<Spec label="when condensed">
<SearchSelectInput
value={value}
onChange={() => {}}
loadOptions={loadOptions}
horizontalConstraint={7}
isCondensed={true}
/>
</Spec>
<Spec label="when input has an error and a warning">
<SearchSelectInput
value={value}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { components, DropdownIndicatorProps } from 'react-select';
import { SearchIcon } from '@commercetools-uikit/icons';
import { TSelectInputCustomComponentProps } from '../types';

const SearchIconDropdownIndicator = (props: DropdownIndicatorProps) => {
export type TDropdownIndicatorProps =
TSelectInputCustomComponentProps<DropdownIndicatorProps>;

const SearchIconDropdownIndicator = (props: TDropdownIndicatorProps) => {
return (
<components.DropdownIndicator {...props}>
<SearchIcon color={'neutral60'} size="big" />
<SearchIcon
color={'neutral60'}
size={props.selectProps.isCondensed ? 'medium' : 'big'}
/>
</components.DropdownIndicator>
);
};
Expand Down

0 comments on commit 91a86d8

Please sign in to comment.