Skip to content

Commit

Permalink
feat(@clayui.com): icon filtering, make label formatting more generic…
Browse files Browse the repository at this point in the history
…, fix whitespace and fix CI errors caused by tab being undefined
  • Loading branch information
kresimir-coko committed Feb 17, 2020
1 parent cfec748 commit 47a50fe
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 112 deletions.
6 changes: 5 additions & 1 deletion clayui.com/content/docs/components/css-icons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ 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}
label="Search Flags"
placeholder="Search Flags..."
source={flags}
type="flags"
/>

### SVG Icons as Background Images
Expand Down
10 changes: 3 additions & 7 deletions clayui.com/src/components/IconSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const IconSearch = ({
label = 'Search Icons',
placeholder = 'Search Icons...',
source,
type = 'icons',
iconLabelFormatter = icon => icon.name,
}) => {
const [searchQuery, setSearchQuery] = useState('');
let list = [];
Expand All @@ -34,7 +34,7 @@ const IconSearch = ({
name.toLowerCase().includes(query) ||
aliases.some(alias => alias.toLowerCase().includes(query))
);
}, [searchQuery]);
}, [searchQuery, source]);

if (filteredIcons.length) {
list = filteredIcons;
Expand Down Expand Up @@ -64,11 +64,7 @@ const IconSearch = ({
symbol={icon.name}
/>

<span>
{type === 'flags'
? icon.aliases.join(' - ')
: icon.name}
</span>
<span>{iconLabelFormatter(icon)}</span>
</li>
))}
</ul>
Expand Down
8 changes: 4 additions & 4 deletions clayui.com/src/templates/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ export default props => {
}
</p>
)}
{tab.html && (
{tab && tab.html && (
<div
dangerouslySetInnerHTML={{
__html:
mdTab.html,
tab.html,
}}
/>
)}
{tab.code && (
{tab && tab.code && (
<article>
<CodeClipboard>
<MDXProvider
Expand Down Expand Up @@ -294,7 +294,7 @@ export default props => {
>
<MDXRenderer>
{
mdxTab
tab
.code
.body
}
Expand Down
Loading

0 comments on commit 47a50fe

Please sign in to comment.