Skip to content

Commit

Permalink
[5.x] Display custom logo as plain text (#10350)
Browse files Browse the repository at this point in the history
  • Loading branch information
daun authored Jul 12, 2024
1 parent d2951d9 commit 9b3ff54
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@

'custom_dark_logo_url' => env('STATAMIC_CUSTOM_DARK_LOGO_URL', null),

'custom_logo_text' => env('STATAMIC_CUSTOM_LOGO_TEXT', null),

'custom_favicon_url' => env('STATAMIC_CUSTOM_FAVICON_URL', null),

'custom_css_url' => env('STATAMIC_CUSTOM_CSS_URL', null),
Expand Down
2 changes: 2 additions & 0 deletions resources/views/partials/global-header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
@if ($customLogo)
<img src="{{ $customLogo }}" alt="{{ config('statamic.cp.custom_cms_name') }}" class="white-label-logo dark:hidden">
<img src="{{ $customDarkLogo }}" alt="{{ config('statamic.cp.custom_cms_name') }}" class="white-label-logo hidden dark:block">
@elseif ($customLogoText)
<span class="font-medium">{{ $customLogoText }}</span>
@else
@cp_svg('statamic-wordmark', 'w-24 logo')
@if (Statamic::pro())<span class="font-bold text-4xs align-top uppercase">{{ __('Pro') }}</span>@endif
Expand Down
2 changes: 2 additions & 0 deletions resources/views/partials/outside-logo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@if ($customLogo)
<img src="{{ $customLogo }}" alt="{{ config('statamic.cp.custom_cms_name') }}" class="white-label-logo dark:hidden">
<img src="{{ $customDarkLogo }}" alt="{{ config('statamic.cp.custom_cms_name') }}" class="white-label-logo hidden dark:block">
@elseif ($customLogoText)
<div class="max-w-xs mx-auto mb-8 text-lg font-medium text-center opacity-50">{{ $customLogoText }}</div>
@else
@cp_svg('statamic-wordmark')
@endif
Expand Down
12 changes: 8 additions & 4 deletions src/Http/View/Composers/CustomLogoComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ class CustomLogoComposer

public function compose(View $view)
{
$view->with('customLogo', $this->customLogo($view, false));
$view->with('customDarkLogo', $this->customLogo($view, true));
$view->with('customLogo', $this->customLogo($view));
$view->with('customDarkLogo', $this->customLogo($view, dark: true));
$view->with('customLogoText', $this->customLogo($view, text: true));
}

protected function customLogo($view, bool $darkMode = false)
protected function customLogo($view, bool $dark = false, bool $text = false)
{
if (! Statamic::pro()) {
return false;
}

$config = config('statamic.cp.custom_logo_url');
if ($darkMode && config('statamic.cp.custom_dark_logo_url')) {
if ($dark && config('statamic.cp.custom_dark_logo_url')) {
$config = config('statamic.cp.custom_dark_logo_url');
}
if ($text && config('statamic.cp.custom_logo_text')) {
$config = config('statamic.cp.custom_logo_text');
}

switch ($view->name()) {
case 'statamic::partials.outside-logo':
Expand Down

0 comments on commit 9b3ff54

Please sign in to comment.