-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* closes #35 * rename heroSection tag to hero
- Loading branch information
Showing
4 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
const aliases: { [tag: string]: string[] } = { | ||
"alert": [ | ||
"success", | ||
"info", | ||
"warning", | ||
"error", | ||
"danger", | ||
"feedback", | ||
"notification" | ||
], | ||
"authentication": [ | ||
"login", | ||
"register", | ||
"account", | ||
"signin", | ||
"password", | ||
"email" | ||
], | ||
"card": [ | ||
"image", | ||
"socials", | ||
"product", | ||
"stars" | ||
], | ||
"cookies": [ | ||
"browser", | ||
"web", | ||
"internet", | ||
"http", | ||
"session" | ||
], | ||
"dropdown": [ | ||
"list", | ||
"select" | ||
], | ||
"faq": [ | ||
"questions", | ||
"q&a", | ||
"support", | ||
"help", | ||
"assistance" | ||
], | ||
"footer": [ | ||
"bottom", | ||
"section", | ||
"bar" | ||
], | ||
"hero": [ | ||
"welcome", | ||
"section", | ||
"home", | ||
"page" | ||
], | ||
"input": [ | ||
"text", | ||
"data", | ||
"typing", | ||
"form" | ||
], | ||
"modal": [ | ||
"popup", | ||
"dialog", | ||
"overlay", | ||
"window" | ||
], | ||
"navbar": [ | ||
"section", | ||
"menu", | ||
"header", | ||
"bar" | ||
], | ||
"pricing": [ | ||
"money", | ||
"costing", | ||
"fee", | ||
"charge" | ||
], | ||
"sidebar": [ | ||
"bar", | ||
"column", | ||
"menu", | ||
"section" | ||
], | ||
"subscribe": [ | ||
"register", | ||
"signup", | ||
"follow", | ||
"email", | ||
"update" | ||
], | ||
"team": [ | ||
"group", | ||
"company", | ||
"squad", | ||
"employees" | ||
] | ||
}; | ||
|
||
export default aliases; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
import aliases from "./aliases"; | ||
|
||
// Format tag and filter before comparison | ||
function format(name: string) { | ||
return name.toLowerCase().replace(/\s+/g, ""); // Case and whitespace insensitive | ||
} | ||
|
||
export function isMatch(tag: string, filter: string): boolean { | ||
tag = tag.toLowerCase(); | ||
filter = filter.replace(/\s+/g, "").toLowerCase(); // Case and whitespace insensitive | ||
filter = format(filter) | ||
|
||
const targets = [tag] | ||
|
||
if (tag in aliases) { | ||
targets.push(...aliases[tag]); | ||
} | ||
|
||
for (let target of targets) { | ||
target = format(target); | ||
|
||
if (target.startsWith(filter)) { | ||
return true; | ||
} | ||
} | ||
|
||
return tag.startsWith(filter); | ||
return false; | ||
} |