This file contains hidden or 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
{ | |
"New React FC": { | |
"prefix": "nfc", | |
"body": [ | |
"import React from 'react';", | |
"import classes from './${1}.module.scss';", | |
"", | |
"interface ${1}Props {}", | |
"", | |
"const ${1} = (props: ${1}Props) => {", |
This file contains hidden or 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
export const setOrReplaceFavoritesIcon = (icon: string = defaultFavIcon) => { | |
const link: HTMLLinkElement = | |
document.querySelector('link[rel*="icon"]') || | |
document.createElement('link'); | |
link.type = 'image/x-icon'; | |
link.rel = 'shortcut icon'; | |
link.href = icon; | |
document.getElementsByTagName('head')[0].appendChild(link); | |
}; |
This file contains hidden or 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
export const camelToKebabCase = (text: string) => { | |
return text.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase(); | |
}; |
This file contains hidden or 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
export const chunkArray = <T>(array: Array<T>, size: number) => { | |
const results = []; | |
while (array.length) { | |
results.push(array.splice(0, size)); | |
} | |
return results; | |
}; |
This file contains hidden or 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
/** | |
* Swedish/Finnish special characters: åäö | |
* Danish/Norwegian special characters: æøå | |
* Latin characters: a-z | |
* Other special characters: ç (e.g. country Curaçao) | |
*/ | |
const wordRegex = /[åäöçæøa-z]+/gi; | |
export const capitalizeWord = (word: string): string => | |
word.charAt(0).toUpperCase() + word.substring(1).toLowerCase(); |
NewerOlder