Skip to content
Open
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
19 changes: 14 additions & 5 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ public function registerSites(
continue;
}

$navigationManager->add(function () use ($site, $url): array {
if ($site['icon'] !== '') {
$image = $url->linkToRoute('external.icon.showIcon', ['icon' => $site['icon']]);
} else {
$image = $url->linkToRoute('external.icon.showIcon', ['icon' => 'external.svg']);
$navigationManager->add(function () use ($site, $url, $sitesManager): array {
$icon = $site['icon'] !== '' ? $site['icon'] : 'external.svg';

// Settings-menu entries are recoloured by Nextcloud core via the
// `--background-invert-if-dark` CSS filter, which expects a
// dark-coloured source icon. Prefer the paired `-dark` variant
// so the icon stays visible in the dark theme (nextcloud/external#430).
if ($site['type'] === SitesManager::TYPE_SETTING && !str_contains($icon, '-dark.')) {
$darkIcon = preg_replace('/(\.[^.]+)$/', '-dark$1', $icon);
if (is_string($darkIcon) && in_array($darkIcon, $sitesManager->getAvailableIcons(), true)) {
$icon = $darkIcon;
}
}

$image = $url->linkToRoute('external.icon.showIcon', ['icon' => $icon]);

$href = $site['url'];
if (!$site['redirect']) {
$href = $url->linkToRoute('external.site.showPage', ['id' => $site['id'], 'path' => '']);
Expand Down
15 changes: 14 additions & 1 deletion lib/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,20 @@ protected function generateNavigationLinks(): void {
}

$this->navigationManager->add(function () use ($site) {
$image = $this->generateImageLink($site, false);
$icon = $site['icon'] !== '' ? $site['icon'] : 'external.svg';

// Settings-menu entries are recoloured by Nextcloud core via the
// `--background-invert-if-dark` CSS filter, which expects a
// dark-coloured source icon. Prefer the paired `-dark` variant
// so the icon stays visible in the dark theme (nextcloud/external#430).
if ($site['type'] === SitesManager::TYPE_SETTING && !str_contains($icon, '-dark.')) {
$darkIcon = preg_replace('/(\.[^.]+)$/', '-dark$1', $icon);
if (is_string($darkIcon) && in_array($darkIcon, $this->sitesManager->getAvailableIcons(), true)) {
$icon = $darkIcon;
}
}

$image = $this->urlGenerator->linkToRoute('external.icon.showIcon', ['icon' => $icon, 'dark' => false]);
$href = $this->getHref($site);

return [
Expand Down