Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Display custom logo as plain text #10350

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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
Loading