feat(icons): setup icons package (#536)

This commit is contained in:
Sam Potts
2026-02-16 14:11:40 +11:00
committed by GitHub
parent edefc2a2d6
commit 78de97ec23
35 changed files with 504 additions and 14 deletions
+7
View File
@@ -0,0 +1,7 @@
export function pascalCase(str: string): string {
return str.replace(/[-_](.)/g, (_, c) => c.toUpperCase()).replace(/^(.)/, (_, c) => c.toUpperCase());
}
export function camelCase(str: string): string {
return pascalCase(str).replace(/^(.)/, (_, c) => c.toLowerCase());
}
+1
View File
@@ -0,0 +1 @@
export * from './casing';
@@ -0,0 +1,44 @@
import { describe, expect, it } from 'vitest';
import { camelCase, pascalCase } from '../casing';
describe('casing', () => {
describe('pascalCase', () => {
it('converts simple strings', () => {
expect(pascalCase('hello')).toBe('Hello');
});
it('converts kebab-case', () => {
expect(pascalCase('hello-world')).toBe('HelloWorld');
});
it('converts snake_case', () => {
expect(pascalCase('hello_world')).toBe('HelloWorld');
});
it('converts mixed case', () => {
expect(pascalCase('hello-World')).toBe('HelloWorld');
});
it('handles already pascal case', () => {
expect(pascalCase('HelloWorld')).toBe('HelloWorld');
});
});
describe('camelCase', () => {
it('converts simple strings', () => {
expect(camelCase('hello')).toBe('hello');
});
it('converts pascal case', () => {
expect(camelCase('HelloWorld')).toBe('helloWorld');
});
it('converts kebab-case', () => {
expect(camelCase('hello-world')).toBe('helloWorld');
});
it('converts snake_case', () => {
expect(camelCase('hello_world')).toBe('helloWorld');
});
});
});