Skip to content

Commit

Permalink
Removed 'color-' and added GoatHunter (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonolave authored Oct 9, 2023
1 parent c5bb991 commit 4e3c5e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
</head>
<body>
<div id="app"></div>
<script data-goatcounter="https://warp.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
<script type="module" src="/src/main.js"></script>
</body>
</html>
17 changes: 13 additions & 4 deletions src/lib/dataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,19 @@ function flattenTokens(prefix, tokenObj) {
continue;
}

let fullTokenName = prefix
? `${prefix}-${key}`
: key;


// Remove "color-" from the token name
fullTokenName = fullTokenName.replace("-color-", "-");


// if string value
if (typeof tokenObj[key] === "string") {
let fullTokenName = prefix
? `${prefix}-${key}`
: key;



// Remove trailing "-_"
if (fullTokenName.endsWith("-_")) {
Expand All @@ -124,7 +132,8 @@ function flattenTokens(prefix, tokenObj) {
}
// If more nested stuff
else if (typeof tokenObj[key] === "object") {
const nextPrefix = prefix ? `${prefix}-${key}` : key;
const nextPrefix = fullTokenName; // Use the already cleaned fullTokenName as the next prefix

const nestedResults = flattenTokens(nextPrefix, tokenObj[key]);

// If the object has a "_" property, use its value for the parent token
Expand Down

0 comments on commit 4e3c5e2

Please sign in to comment.