Skip to content

Commit

Permalink
feat(@clayui.com): icon filtering, simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
kresimir-coko committed Feb 17, 2020
1 parent 47a50fe commit 0d8f815
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
6 changes: 1 addition & 5 deletions clayui.com/content/docs/components/css-icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ Or, to paraphrase Winston Churchill, "Using flags is the worst system for indica

To use the flags below, follow the same process as you would for a standard icon, and use the locale and country code indicated in parenthesis for the icon's name (e.g. to use the Japanese icon, you would use `ja-jp`)

export function flagLabelFormatter(icon) {
return icon.aliases.join(' - ');
}

<IconSearch
iconLabelFormatter={flagLabelFormatter}
iconLabelFormatter={icon => icon.aliases.join(' - ')}
label="Search Flags"
placeholder="Search Flags..."
source={flags}
Expand Down
7 changes: 1 addition & 6 deletions clayui.com/src/components/IconSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const IconSearch = ({
iconLabelFormatter = icon => icon.name,
}) => {
const [searchQuery, setSearchQuery] = useState('');
let list = [];

const filteredIcons = useMemo(() => {
const query = searchQuery.toLowerCase();
Expand All @@ -36,11 +35,7 @@ const IconSearch = ({
);
}, [searchQuery, source]);

if (filteredIcons.length) {
list = filteredIcons;
} else {
list = searchQuery ? [] : source;
}
const list = searchQuery ? filteredIcons : source;

return (
<>
Expand Down

0 comments on commit 0d8f815

Please sign in to comment.