Skip to content

Commit

Permalink
📦 Add change-case utility + update camelCase custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed Sep 19, 2024
1 parent 6dc59fb commit 7032281
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions website/app/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import * as changeCase from "change-case";

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

export function lower(input: string): string {
return input
.split(/[^a-zA-Z0-9]+/)
.map((word, index) => {
if (index === 0) {
return word.charAt(0).toLowerCase() + word.slice(1);
} else {
return word.charAt(0).toUpperCase() + word.slice(1);
}
})
.join("");
}
export const camelCase = (str: string) => {
if ((str.match(/[A-Z]/g) || []).length >= 2) {
return changeCase.camelCase(str);
}
if (str.includes("-")) {
return changeCase.camelCase(str);
}
return changeCase.camelCase(str);
};

const MIMETYPE = "text/plain";

Expand Down
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@remix-run/serve": "2.11.2",
"@vercel/remix": "2.11.2",
"axios": "1.7.7",
"change-case": "5.4.4",
"class-variance-authority": "0.7.0",
"clsx": "2.1.1",
"fast-npm-meta": "0.2.2",
Expand Down

0 comments on commit 7032281

Please sign in to comment.