Files
2026-03-03 03:56:39 -04:00

108 lines
4.4 KiB
Python

"""CSS styles and theme configurations for modern templates."""
####################################################################################################
# Copyright (C) 2026 by WallyHackenslacker wallyhackenslacker@noreply.git.hackenslacker.space #
# #
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without #
# fee is hereby granted. #
# #
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS #
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE #
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES #
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, #
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE #
# OF THIS SOFTWARE. #
####################################################################################################
import json
from pathlib import Path
# Directory where templates are located
TEMPLATES_DIR = Path(__file__).parent / "templates"
# Theme configurations for Chart.js
THEME_CONFIGS = {
"brutalism": {
"colors": [
"#ff0000", "#0000ff", "#ffff00", "#00ff00", "#ff00ff",
"#00ffff", "#ff8800", "#8800ff", "#0088ff", "#88ff00",
"#888888"
],
"fontFamily": "'Courier New', monospace",
"fontWeight": "bold",
"pointStyle": "rect",
"textColorLight": "#000000",
"textColorDark": "#ffffff",
"borderColorLight": "#000000",
"borderColorDark": "#ffffff",
"borderWidth": 3,
"tooltipBg": "#000000",
"tooltipTitleColor": "#ffffff",
"tooltipBodyColor": "#ffffff",
"tooltipBorderColor": "#ffffff",
"tooltipBorderWidth": 2,
"tooltipCornerRadius": 0,
"uppercaseTooltip": True
},
"glassmorphism": {
"colors": [
"#6366f1", "#8b5cf6", "#ec4899", "#f43f5e", "#f97316",
"#eab308", "#22c55e", "#14b8a6", "#06b6d4", "#3b82f6",
"#64748b"
],
"fontFamily": "'Inter', sans-serif",
"fontWeight": "normal",
"pointStyle": "circle",
"textColorLight": "#1a1a2e",
"textColorDark": "#f0f0f5",
"borderColorLight": "rgba(255, 255, 255, 0.2)",
"borderColorDark": "rgba(255, 255, 255, 0.2)",
"borderWidth": 2,
"tooltipBg": "rgba(0, 0, 0, 0.8)",
"tooltipTitleColor": "#ffffff",
"tooltipBodyColor": "#ffffff",
"tooltipBorderColor": "transparent",
"tooltipBorderWidth": 0,
"tooltipCornerRadius": 8,
"uppercaseTooltip": False
},
"neumorphism": {
"colors": [
"#6366f1", "#8b5cf6", "#ec4899", "#f43f5e", "#f97316",
"#eab308", "#22c55e", "#14b8a6", "#06b6d4", "#3b82f6",
"#64748b"
],
"fontFamily": "'Inter', sans-serif",
"fontWeight": "normal",
"pointStyle": "circle",
"textColorLight": "#2d3436",
"textColorDark": "#f0f0f5",
"borderColorLight": "rgba(255, 255, 255, 0.3)",
"borderColorDark": "rgba(255, 255, 255, 0.3)",
"borderWidth": 3,
"tooltipBg": "rgba(0, 0, 0, 0.8)",
"tooltipTitleColor": "#ffffff",
"tooltipBodyColor": "#ffffff",
"tooltipBorderColor": "transparent",
"tooltipBorderWidth": 0,
"tooltipCornerRadius": 8,
"uppercaseTooltip": False
}
}
def get_theme_css(style: str) -> str:
"""Get the CSS for a given style by reading from the corresponding .css file."""
css_file = TEMPLATES_DIR / f"{style}.css"
if css_file.exists():
return css_file.read_text(encoding="utf-8")
# Fallback to glassmorphism if style not found
fallback = TEMPLATES_DIR / "glassmorphism.css"
return fallback.read_text(encoding="utf-8")
def get_theme_config(style: str) -> str:
"""Get the theme config as JSON string for a given style."""
config = THEME_CONFIGS.get(style, THEME_CONFIGS["glassmorphism"])
return json.dumps(config)