Skip to content

Commit

Permalink
Merge pull request #296 from dawsonbooth/185-dropdown-search
Browse files Browse the repository at this point in the history
#185 Add searching to dropdown
  • Loading branch information
aVileBroker committed Aug 24, 2021
2 parents 36c396b + 7389649 commit 80f35c0
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 148 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"dependencies": {
"@mdi/js": "^5.9.55",
"@mdi/react": "^1.4.0",
"fuse.js": "^6.4.6",
"lodash.debounce": "^4.0.8",
"nanoid": "^3.1.20",
"polished": "^4.1.1",
Expand Down
24 changes: 20 additions & 4 deletions src/components/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const Basic: Story<BasicProps> = ({
numCities,
onClear,
onSelect,
searchable,
searchFiltersOptions,
onSearchChange,
onDebouncedSearchChange,
...args
}: BasicProps) => {
const [cities, setCities] = useState<OptionProps[]>([]);
Expand All @@ -57,25 +61,31 @@ export const Basic: Story<BasicProps> = ({
}}
options={cities}
values={values}
searchable={searchable}
searchFiltersOptions={searchFiltersOptions}
onSearchChange={onSearchChange}
onDebouncedSearchChange={onDebouncedSearchChange}
/>
</Label>
);
};
Basic.args = {
color: colors.primaryDark,
elevation: 0,
multi: false,
multi: true,
placeholder: 'Choose a city...',
clearable: false,
clearable: true,
rememberScrollPosition: true,
variant: variants.fill,
optionsVariant: variants.outline,
valueVariant: variants.text,
valueVariant: variants.outline,
shouldStayInView: true,
intersectionObserverPrecision: 100,
intersectionThreshold: 1.0,
numCities: 200,
virtualizeOptions: true,
searchable: true,
searchFiltersOptions: true,
};

const teaOptions = [
Expand Down Expand Up @@ -119,7 +129,9 @@ const teaOptions = [
},
];

export const Icons: Story<DropdownProps> = ({ onSelect, ...args }: DropdownProps) => {
type IconsProps = DropdownProps & { clearable: boolean };

export const Icons: Story<IconsProps> = ({ onSelect, ...args }: IconsProps) => {
const [values, setValues] = useState<(string | number)[] | undefined>();
return (
<Label labelText="How strong do you like your tea?" htmlFor="tea-rank">
Expand All @@ -138,9 +150,13 @@ export const Icons: Story<DropdownProps> = ({ onSelect, ...args }: DropdownProps
};
Icons.args = {
...Basic.args,
multi: false,
placeholder: 'Choose a rating...',
clearable: false,
color: '#0A7700',
valueVariant: variants.text,
elevation: 1,
searchable: false,
};

export default {
Expand Down
Loading

0 comments on commit 80f35c0

Please sign in to comment.