merge tailwind and upgraded a17t
a17t v0.10 became a tailwind plugin rather than standalone css, and made some other changes. Much of the original custom CSS now uses tailwind classes, and there have been some other UI changes.
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# scan all typescript and automatically add dark variants to color tags if they're not already present.
|
||||
|
||||
for f in $2/*.ts; do
|
||||
# FIXME: inline html
|
||||
for l in $(grep -n "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" $f | sed -e 's/:.*//g'); do
|
||||
# for l in $(sed -n '/classList/=' $f); do
|
||||
line=$(sed -n "${l}p" $f)
|
||||
echo $line | grep "classList" &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $line | sed 's/.*classList//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# echo "found classList @ " $l
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/\"~${color}\"/\"~${color}\", \"dark:~d_${color}\"/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "FIX: classList found, but color tag wasn't in it"
|
||||
fi
|
||||
else
|
||||
echo $line | grep "querySelector" &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo $line | sed 's/.*querySelector//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
|
||||
done
|
||||
fi
|
||||
#else
|
||||
#echo "FIX: querySelector found, but color tag wasn't in it: " $line
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
@@ -0,0 +1,56 @@
|
||||
let parser = require("jsdom");
|
||||
let fs = require("fs");
|
||||
let path = require("path");
|
||||
|
||||
const hasDark = (item) => {
|
||||
for (let i = 0; i < item.classList.length; i++) {
|
||||
if (item.classList[i].substring(0,5) == "dark:") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
const fixHTML = (infile, outfile) => {
|
||||
console.log(infile, outfile)
|
||||
let doc = new parser.JSDOM(fs.readFileSync(infile));
|
||||
for (let item of ["badge", "chip", "shield", "input", "table", "button", "portal", "select", "aside", "card", "field", "textarea"]) {
|
||||
let items = doc.window.document.body.querySelectorAll("."+item);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let hasColor = false;
|
||||
for (let color of ["neutral", "positive", "urge", "warning", "info", "critical"]) {
|
||||
//console.log(color);
|
||||
if (items[i].classList.contains("~"+color)) {
|
||||
hasColor = true;
|
||||
// console.log("adding to", items[i].classList)
|
||||
if (!hasDark(items[i])) {
|
||||
items[i].classList.add("dark:~d_"+color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasColor) {
|
||||
if (!hasDark(items[i])) {
|
||||
// card without ~neutral look different than with.
|
||||
if (item != "card") items[i].classList.add("~neutral");
|
||||
items[i].classList.add("dark:~d_neutral");
|
||||
}
|
||||
}
|
||||
if (!items[i].classList.contains("@low") && !items[i].classList.contains("@high")) {
|
||||
items[i].classList.add("@low");
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(outfile, doc.window.document.documentElement.outerHTML);
|
||||
};
|
||||
|
||||
let inpath = process.argv[process.argv.length-2];
|
||||
let outpath = process.argv[process.argv.length-1];
|
||||
|
||||
let files = fs.readdirSync(inpath);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
if (files[i].indexOf(".html")>=0) {
|
||||
fixHTML(path.join(inpath, files[i]), path.join(outpath, files[i]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user