handy script i wrote just now

function classlistify(classes) {
    classes = classes.split(" ");
    let allclasses = "";
    classes.forEach((item) => {allclasses = allclasses+`classList.add("${item}");\n`});
    console.log(allclasses);
}
classlistify("bg-white dark:bg-gray-700 p-4 mb-2 rounded-xl flex cursor-pointer hover:bg-white transition-colors");

comments (single view)

const classlistify = (classes) => {
  return (
    "classList.add(" +
    classes
      .split(" ")
      .map((cls) => JSON.stringify(cls))
      .join(", ") +
    ")"
  );
};
console.log(
  classlistify(
    "bg-white dark:bg-gray-700 p-4 mb-2 rounded-xl flex cursor-pointer hover:bg-white transition-colors"
  )
);
View all comments