mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
* remove * remove style observer from icons * fix size example * unbreak the themer * remove old test * remove abstraction * remove createProperty and initial; fix default attribute values * skip it to ship it * cleanup and add ? fallback * update tests * fix types * remove default * update test * update tests * update deps * update deps * update deps * update dep * fix comment * downgrade 11ty * revert deps * add nunjucks * prettier * skip tests for now * fix parsing error * prettier * skip * sigh webkit * tidy up icon library examples * change rando `solid` icon to `regular` * restore tests * fix radio group size * fix button group size * remove size from card * fix menu item sizes * remove card `size` from visual tests and docs --------- Co-authored-by: lindsaym-fa <dev@lindsaym.design>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
/**
|
|
* Make the first letter of a string uppercase
|
|
* @param {*} str
|
|
* @returns
|
|
*/
|
|
export function capitalize(str) {
|
|
str += '';
|
|
return str[0]?.toUpperCase() + str.slice(1);
|
|
}
|
|
|
|
/**
|
|
* Convert a readable string to a slug.
|
|
* @param {*} str - Input string. If argument is not a string, it will be stringified.
|
|
* @returns {string} - The slugified string
|
|
*/
|
|
export function slugify(str) {
|
|
return (str + '')
|
|
.normalize('NFD')
|
|
.replace(/[\u0300-\u036f]/g, '') // Convert accented letters to ASCII
|
|
.replace(/[^\w\s-]/g, '') // Remove remaining non-ASCII characters
|
|
.trim()
|
|
.replace(/\s+/g, '-') // Convert whitespace to hyphens
|
|
.toLowerCase();
|
|
}
|
|
|
|
/**
|
|
* Convert a string to camel case.
|
|
* @param {string} str - The string to convert.
|
|
* @returns {string} The camel case string.
|
|
*/
|
|
export function camelCase(str) {
|
|
return str.replace(/-([a-z])/g, (_, letter) => letter?.toUpperCase());
|
|
}
|
|
|
|
/**
|
|
* Convert a string to kebab case.
|
|
* @param {string} str - The string to convert.
|
|
* @returns {string} The kebab case string.
|
|
*/
|
|
export function kebabCase(str) {
|
|
return str.replace(/([A-Z])/g, '-$1')?.toLowerCase();
|
|
}
|