From c1e7ef4a65675d88515c76a20877c1d65aec3cac Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 11 Jul 2022 13:06:00 +0300 Subject: skin/base: update header, fix for mobile devices --- skin/base.skin.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'skin/base.skin.php') diff --git a/skin/base.skin.php b/skin/base.skin.php index 616e1b3..aa1da8a 100644 --- a/skin/base.skin.php +++ b/skin/base.skin.php @@ -166,30 +166,43 @@ function getStaticVersion(string $name): string { } function renderHeader($ctx, $theme, $unsafe_logo_html) { - return << 'javascript:void(0)', 'label' => $theme, 'label_id' => 'theme-switcher-label', 'theme_switcher' => true], + ['url' => '/', 'label' => 'blog'], + ['url' => '/projects/', 'label' => 'projects'], + ['url' => 'https://git.ch1p.io/?s=idle', 'label' => 'git'], + ['url' => '/misc/', 'label' => 'misc'], + ['url' => '/contacts/', 'label' => 'contacts'], + ['url' => '/', 'label' => 'blog'], +]; +if (\admin::isAdmin()) + $items[] = ['url' => '/admin/', 'label' => 'admin']; + +// here, items are rendered using for_each, so that there are no gaps (whitespaces) between tags + +return <<
- - - - {$ctx->renderMoonIcon()}{$theme} - - - - blog - projects - git - misc - contacts - {$ctx->if_admin('admin')} + {$ctx->for_each($items, fn($item) => $ctx->renderHeaderItem($item['url'], $item['label'], $item['label_id'], $item['theme_switcher']))}
HTML; } +function renderHeaderItem($ctx, $url, $label, $label_id, $is_theme_switcher) { +return <<if_true($is_theme_switcher, ' onclick="return ThemeSwitcher.next(event)"')}> + + {$ctx->if_true($is_theme_switcher, ''.$ctx->renderMoonIcon().'')} + if_true($label_id, ' id="'.$label_id.'"')}>{$label} + + +HTML; +} + // TODO rewrite this fcking crap function renderLogo($ctx, array $path_map = [], array $link_map = []): string { $uri = RequestDispatcher::path(); -- cgit v1.2.3