Skip to content

Commit

Permalink
add dark variants to ts
Browse files Browse the repository at this point in the history
janky but works, and should report if theres a situation its not ready
to handle.
  • Loading branch information
hrfee committed Dec 30, 2021
1 parent 18ae035 commit a31f174
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,4 +18,5 @@ instructions-debian.txt
cl.md
./telegram/
mautrix/
tempts/
matacc.txt
19 changes: 12 additions & 7 deletions Makefile
Expand Up @@ -52,7 +52,7 @@ ifeq ($(DEBUG), on)
SOURCEMAP := --sourcemap
TYPECHECK := tsc -noEmit --project ts/tsconfig.json
# jank
COPYTS := rm -r $(DATA)/web/js/ts; cp -r ts $(DATA)/web/js
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js
UNCSS := cp $(DATA)/web/css/bundle.css $(DATA)/bundle.css
else
LDFLAGS := -s -w $(LDFLAGS)
Expand Down Expand Up @@ -91,13 +91,18 @@ email:

typescript:
$(TYPECHECK)
$(adding dark variants to typescript)
-rm -r tempts
cp -r ts tempts
scripts/dark-variant.sh ts tempts
scripts/dark-variant.sh ts tempts/modules
$(info compiling typescript)
-mkdir -p $(DATA)/web/js
-$(ESBUILD) --bundle ts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js --minify
-$(ESBUILD) --bundle ts/pwr.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr.js --minify
-$(ESBUILD) --bundle ts/form.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/form.js --minify
-$(ESBUILD) --bundle ts/setup.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/setup.js --minify
-$(ESBUILD) --bundle ts/crash.ts --outfile=./$(DATA)/crash.js --minify
-$(ESBUILD) --bundle tempts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js --minify
-$(ESBUILD) --bundle tempts/pwr.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/pwr.js --minify
-$(ESBUILD) --bundle tempts/form.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/form.js --minify
-$(ESBUILD) --bundle tempts/setup.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/setup.js --minify
-$(ESBUILD) --bundle tempts/crash.ts --outfile=./$(DATA)/crash.js --minify
$(COPYTS)

swagger:
Expand Down Expand Up @@ -130,7 +135,7 @@ variants-html:
$(info copying html)
cp -r html $(DATA)/
$(info adding dark variants to html)
scripts/dark-variant.sh $(DATA)/html
scripts/dark-variant.sh html $(DATA)/html

copy:
$(info copying fonts)
Expand Down
33 changes: 29 additions & 4 deletions scripts/dark-variant.sh
@@ -1,7 +1,32 @@
#!/bin/bash

for f in $1/*.html; do
for color in neutral positive urge warning info critical; do
sed -i "s/~${color}/~${color} dark:~d_${color}/g" $f
if [[ "$1" == "html" ]]; then
for f in $2/*.html; do
for color in neutral positive urge warning info critical; do
sed -i "s/~${color}/~${color} dark:~d_${color}/g" $f
done
done
done
elif [[ "$1" == "ts" ]]; then
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
for color in neutral positive urge warning info critical; do
sed -i "${l},${l}s/\"~${color}\"/\"~${color}\", \"dark:~d_${color}\"/g" $f
done
else
echo "FIX: classList found, but color tag wasn't in it"
fi
else
echo "found inline @ " $l ", " $(sed -n "${l}p" $f)
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
fi
done
done
fi

0 comments on commit a31f174

Please sign in to comment.