diff --git a/resources/views/partials/head.blade.php b/resources/views/partials/head.blade.php index a4a43141da..c8fff4417f 100644 --- a/resources/views/partials/head.blade.php +++ b/resources/views/partials/head.blade.php @@ -47,6 +47,9 @@ @endforeach @stack('head') diff --git a/src/CP/Color.php b/src/CP/Color.php index 4758d73624..689b9d28f4 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 = [ @@ -423,10 +425,14 @@ public static function defaults(bool $dark = false): array ->all(); } - public static function theme(bool $dark = false): array + public static function theme(bool $dark = false): array|string { $config = config('statamic.cp.theme', []); + if (is_string($config) && File::exists(resource_path('themes/'.$config.'.css'))) { + return $config; + } + foreach ($config[$dark ? 'dark-grays' : 'grays'] ?? [] as $shade => $value) { $colorHandle = $dark ? 'dark-gray' : 'gray'; $config["{$colorHandle}-{$shade}"] = $value; @@ -448,6 +454,16 @@ public static function theme(bool $dark = false): 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(bool $dark = false): string { return collect(static::theme($dark))