feat: tailwind 4.0

This commit is contained in:
2025-01-23 14:30:02 +01:00
parent d5a4345600
commit 8039288b33
31 changed files with 108 additions and 1708 deletions
@@ -1,4 +1,8 @@
import os
import subprocess
from dataclasses import dataclass
from django.conf import settings
from django.core.management.base import BaseCommand
from django.template.loader import render_to_string
@@ -6,6 +10,13 @@ from django.core.management import call_command
from web.models import WebSettings
@dataclass
class Color:
name: str
index: int
value: str
class Command(BaseCommand):
"""
Usage:
@@ -16,15 +27,29 @@ class Command(BaseCommand):
def handle(self, *args, **options):
web_settings = WebSettings.load()
path = os.path.join(
settings.BASE_DIR, "theme", "static_src", "tailwind.config.js"
settings.BASE_DIR, "theme", "static", "css", "main.css"
)
colors = []
for color_name, data in web_settings.theme_colors.items():
for index, value in data.items():
color = Color(color_name, index, value)
colors.append(color)
result = str(
render_to_string(
"theme/tailwind.config.template.js", context=web_settings.theme_colors
"theme/main.css.template", context={"colors": colors},
)
)
with open(path, "w") as f:
f.write(result)
call_command("tailwind", "build")
subprocess.run([
"tailwindcss",
"-i",
"theme/static/css/main.css",
"-o",
"theme/static/css/styles.css",
"--minify",
])
call_command("collectstatic", "--no-input")