Write theme JSON files from buildThemes script
Co-Authored-By: Nate Butler <1714999+iamnbutler@users.noreply.github.com>
This commit is contained in:
parent
70a783c8d1
commit
d2a070c345
9 changed files with 771 additions and 445 deletions
21
styles/utils/decamelizeTree.ts
Normal file
21
styles/utils/decamelizeTree.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { snakeCase } from "case-anything";
|
||||
|
||||
export default function decamelizeTree(object: { [key: string]: any }) {
|
||||
const snakeObject: { [key: string]: any } = {};
|
||||
for (const key in object) {
|
||||
snakeObject[snakeCase(key)] = decamelizeValue(object[key]);
|
||||
}
|
||||
return snakeObject;
|
||||
}
|
||||
|
||||
function decamelizeValue(value: any): any {
|
||||
if (typeof value === "object") {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(decamelizeValue);
|
||||
} else {
|
||||
return decamelizeTree(value);
|
||||
}
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue