From 5337ff6f39bb9422a95ea30b40bca7270cd4d36c Mon Sep 17 00:00:00 2001 From: Jack McDade Date: Tue, 4 Nov 2025 11:07:49 -0500 Subject: [PATCH 1/4] Themes can now be .css files in resources/themes --- resources/views/partials/head.blade.php | 10 +++++++--- src/CP/Color.php | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/resources/views/partials/head.blade.php b/resources/views/partials/head.blade.php index c954d5e5ef1..56ee50129fb 100644 --- a/resources/views/partials/head.blade.php +++ b/resources/views/partials/head.blade.php @@ -47,9 +47,13 @@ @endforeach @stack('head') diff --git a/src/CP/Color.php b/src/CP/Color.php index fc1c6d131ee..8bf580eb2ae 100644 --- a/src/CP/Color.php +++ b/src/CP/Color.php @@ -2,6 +2,8 @@ namespace Statamic\CP; +use Statamic\Facades\File; + class Color { public const Slate = [ @@ -400,10 +402,14 @@ public static function defaults(): array ]; } - public static function theme(): array + public static function theme(): array|string { $config = config('statamic.cp.theme', []); + if (is_string($config) && File::exists(resource_path('themes/'.$config.'.css'))) { + return $config; + } + foreach ($config['grays'] ?? [] as $shade => $value) { $config["gray-{$shade}"] = $value; } @@ -413,8 +419,22 @@ public static function theme(): array ->all(); } + public static function isUsingThemeFile(): bool + { + return is_string(static::theme()) && File::exists(resource_path('themes/'.static::theme().'.css')); + } + + public static function themeCss(): string + { + return File::get(resource_path('themes/'.static::theme().'.css')); + } + public static function cssVariables(): string { + if (is_string(static::theme())) { + return File::get(resource_path('themes/'.static::theme().'.css')); + } + return collect(static::theme()) ->map(fn ($color, $name) => "--theme-color-{$name}: {$color};") ->implode("\n"); From dde95f036955a09af78405fd2fc0060cfe036519 Mon Sep 17 00:00:00 2001 From: Jack McDade Date: Tue, 4 Nov 2025 11:30:52 -0500 Subject: [PATCH 2/4] don't need this now that I added themeCss() --- src/CP/Color.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/CP/Color.php b/src/CP/Color.php index 8bf580eb2ae..ed4b31d4b2e 100644 --- a/src/CP/Color.php +++ b/src/CP/Color.php @@ -431,10 +431,6 @@ public static function themeCss(): string public static function cssVariables(): string { - if (is_string(static::theme())) { - return File::get(resource_path('themes/'.static::theme().'.css')); - } - return collect(static::theme()) ->map(fn ($color, $name) => "--theme-color-{$name}: {$color};") ->implode("\n"); From df72a844f3eb719e8700db6cb3c11ed5add6c2dd Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Fri, 14 Nov 2025 15:55:54 -0500 Subject: [PATCH 3/4] import --- resources/views/partials/head.blade.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/views/partials/head.blade.php b/resources/views/partials/head.blade.php index c8fff4417f9..d2fbf2e2719 100644 --- a/resources/views/partials/head.blade.php +++ b/resources/views/partials/head.blade.php @@ -1,4 +1,5 @@ @php + use Statamic\CP\Color; use function Statamic\trans as __; @endphp @@ -47,14 +48,14 @@ @endforeach