Created
May 18, 2024 08:19
-
-
Save fucksophie/c0d466cebf4a30c5b5fa2f8c36d4f89b to your computer and use it in GitHub Desktop.
combine two lists of tailwind classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function combineTailwind(first, second) { | |
const secondSplit = second.split(" ") | |
let classes = []; | |
const secondIds = secondSplit.map(z => z.split("-")[0]); | |
for(const defaultClass of first.split(" ")) { | |
if(!secondIds.includes(defaultClass.split("-")[0])) { | |
classes.push(defaultClass); | |
} | |
} | |
return classes.concat(secondSplit).join(" ") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment