Skip to content

Commit

Permalink
feat(fuselage): Add custom Icon to Select Component (#639)
Browse files Browse the repository at this point in the history
* Add addonIcon prop to Select

* improve: prevent list to open clicking on addon

* chore: remove fluted code

Co-authored-by: dougfabris <devfabris@gmail.com>
Co-authored-by: Tasso Evangelista <tasso.evangelista@rocket.chat>
  • Loading branch information
3 people committed Feb 16, 2022
1 parent 18464ce commit 66021a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/fuselage/src/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ WithEmptyOptions.args = {
options: [],
};

export const WithAddon: ComponentStory<typeof Select> = TemplateWithFilter.bind(
{}
);
WithAddon.args = {
width: '250px',
placeholder: 'Placeholder here...',
options,
addonIcon: 'magnifier',
};

export const CustomEmpty: ComponentStory<typeof Select> =
TemplateWithFilter.bind({});
CustomEmpty.args = {
Expand Down
4 changes: 3 additions & 1 deletion packages/fuselage/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export type SelectProps = Omit<ComponentProps<typeof Box>, 'onChange'> & {
filter?: string;
renderOptions?: ElementType;
customEmpty?: string;
addonIcon?: ComponentProps<typeof Icon>['name'];
};

export const Select = forwardRef(
Expand All @@ -89,6 +90,7 @@ export const Select = forwardRef(
getLabel = ([_, label] = ['', '']) => label,
placeholder = '',
renderOptions: _Options = Options,
addonIcon,
customEmpty,
...props
}: SelectProps,
Expand Down Expand Up @@ -201,7 +203,7 @@ export const Select = forwardRef(
name={
visible === AnimatedVisibility.VISIBLE
? 'cross'
: 'chevron-down'
: addonIcon || 'chevron-down'
}
size='x20'
/>
Expand Down

0 comments on commit 66021a8

Please sign in to comment.