mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-18 14:38:24 +00:00
feat(packages): Added aria-hidden fallback for decorative icons to all packages (#3604)
* Add aria hidden to lucide package * Add aria-hidden to astro package * Add tests for shared package * Fix test for props * add aria prop to lucide-solid * Add aria-hidden to lucide-vue-next * Add aria-hidden prop to angular package * Fix builds * Add notice about aria-label in docs * Format code * Update packages/svelte/tests/Icon.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/lucide-svelte/tests/Icon.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/shared/src/utils/hasA11yProp.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Adjusted docs * Fix import * update tests * test(shared): fix hasA11yProp unit test * fix(packages/lucide-angular): fix hasA11yProp import path (non-relative import path will not get properly resolved by ng-packagr) * Format code * Adjust aria props to root element * Format code --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Karsa <contact@karsa.org>
This commit is contained in:
co-authored by
Copilot
Karsa
parent
9b10d1d9bb
commit
b6ed43d48c
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Check if a component has an accessibility prop
|
||||
*
|
||||
* @param {object} props
|
||||
* @returns {boolean} Whether the component has an accessibility prop
|
||||
*/
|
||||
export const hasA11yProp = (props: Record<string, any>) => {
|
||||
for (const prop in props) {
|
||||
if (prop.startsWith('aria-') || prop === 'role' || prop === 'title') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Is empty string
|
||||
*
|
||||
* @param {unknown} value
|
||||
* @returns {boolean} Whether the value is an empty string
|
||||
*/
|
||||
export const isEmptyString = (value: unknown): boolean => value === '';
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Merges classes into a single string
|
||||
*
|
||||
* @param {array} classes
|
||||
* @returns {string} A string of classes
|
||||
*/
|
||||
export const mergeClasses = <ClassType = string | undefined | null>(...classes: ClassType[]) =>
|
||||
classes
|
||||
.filter((className, index, array) => {
|
||||
return (
|
||||
Boolean(className) &&
|
||||
(className as string).trim() !== '' &&
|
||||
array.indexOf(className) === index
|
||||
);
|
||||
})
|
||||
.join(' ')
|
||||
.trim();
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Converts string to camel case
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A camelized string
|
||||
*/
|
||||
export const toCamelCase = <T extends string>(string: T) =>
|
||||
string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) =>
|
||||
p2 ? p2.toUpperCase() : p1.toLowerCase(),
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Converts string to kebab case
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A kebabized string
|
||||
*/
|
||||
export const toKebabCase = (string: string) =>
|
||||
string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
@@ -0,0 +1,14 @@
|
||||
import { CamelToPascal } from '../utility-types';
|
||||
import { toCamelCase } from './toCamelCase';
|
||||
|
||||
/**
|
||||
* Converts string to pascal case
|
||||
*
|
||||
* @param {string} string
|
||||
* @returns {string} A pascalized string
|
||||
*/
|
||||
export const toPascalCase = <T extends string>(string: T): CamelToPascal<T> => {
|
||||
const camelCase = toCamelCase(string);
|
||||
|
||||
return (camelCase.charAt(0).toUpperCase() + camelCase.slice(1)) as CamelToPascal<T>;
|
||||
};
|
||||
Reference in New Issue
Block a user