feat: improve alias and variants

This commit is contained in:
Anthony Fu 2023-03-18 16:29:14 +01:00
parent 29fac271a4
commit d87383d42b
3 changed files with 51 additions and 18 deletions

View File

@ -168,7 +168,7 @@ function getVariantCategories(collection: CollectionMeta) {
const variants: Record<string, string[]> = {}
for (const icon of collection.icons) {
const name = variantsRule.find(i => icon.endsWith(i[1]))?.[0] || 'Regular'
const name = variantsRule.find(i => typeof i[1] === 'string' ? icon.endsWith(i[1]) : i[1].test(icon))?.[0] || 'Regular'
if (!variants[name])
variants[name] = []
variants[name].push(icon)

View File

@ -1,18 +1,44 @@
export const searchAlias: string[][] = [
['cog', 'gear', 'setting', 'settings', 'adjust'],
['close', 'cross'],
['person', 'account', 'people', 'user'],
['plus', 'add'],
['minus', 'remove'],
['trash', 'delete'],
['check', 'tick', 'done'],
['arrow', 'direction'],
['globe', 'global', 'earth', 'world'],
['search', 'find', 'magnify', 'magnifier'],
['file', 'document', 'paper'],
['folder', 'directory'],
['download', 'save'],
['upload', 'import'],
['accessibility', 'a11y'],
['alert', 'warning', 'warn'],
['account', 'person', 'profile', 'user'],
['add', 'create', 'new', 'plus'],
['alert', 'bell', 'notification', 'notify', 'reminder'],
['approve', 'like', 'recommend', 'thumbs-up'],
['left', 'previous'],
['next', 'right'],
['attach', 'connect', 'link'],
['bag', 'basket', 'cart'],
['bookmark', 'flag', 'marker'],
['building', 'home', 'house'],
['calendar', 'date', 'event'],
['cancel', 'close'],
['delete', 'remove', 'trash'],
['chat', 'conversation', 'message'],
['clock', 'time', 'timer', 'alarm'],
['cog', 'gear', 'preferences', 'settings'],
['directory', 'folder'],
['disapprove', 'dislike', 'thumbs-down'],
['document', 'file', 'paper'],
['earth', 'globe', 'world', 'planet', 'global'],
['email', 'envelope', 'mail'],
['eye', 'view', 'visible'],
['favorite', 'heart', 'love'],
['feed', 'rss', 'subscribe', 'subscription'],
['list', 'menu'],
['lock', 'password', 'secure', 'security', 'shield'],
['log-in', 'login', 'sign-in'],
['log-out', 'logout', 'sign-out'],
['magnifier', 'search', 'find', 'magnify'],
['photo', 'picture', 'image'],
['refresh', 'reload', 'update'],
['speaker', 'audio', 'volume', 'sound'],
['speed', 'fast'],
['accessibility', 'ally', 'a11y'],
['edit', 'pen', 'pencil', 'write'],
['moon', 'night', 'dark'],
['bulb', 'idea'],
['pin', 'location', 'map', 'marker'],
['bot', 'robot', 'android'],
['db', 'database'],
['external', 'launch'],
['airplane', 'flight'],
]

View File

@ -1,4 +1,4 @@
export const variantCategories: Record<string, [string, string][]> = {
export const variantCategories: Record<string, [string, string | RegExp][]> = {
'ph': [
['Bold', '-bold'],
['Duetone', '-duotone'],
@ -100,4 +100,11 @@ export const variantCategories: Record<string, [string, string][]> = {
['Filled 10', '-10-filled'],
['Regular 10', '-10-regular'],
],
'ic': [
['Outline', /^outline-/],
['Round', /^round-/],
['Sharp', /^sharp-/],
['Twotone', /^twotone-/],
['Baseline', /^baseline-/],
],
}