From 4367628ebea35391e27c20c3322e2649d879ede1 Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Thu, 10 Nov 2022 10:52:11 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20new=20hybrid=20header=20layou?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: #282 --- CHANGELOG.md | 1 + assets/css/compiled/main.css | 8 +++ assets/js/search.js | 8 ++- config/_default/params.toml | 2 +- exampleSite/config/_default/params.toml | 2 +- exampleSite/content/docs/configuration.md | 2 +- layouts/partials/header/hybrid.html | 81 +++++++++++++++++++++++ 7 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/header/hybrid.html diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd4126a..63b4037e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Support for article thumbnails, covers and featured images +- Hybrid header layout that switches between the hamburger and basic menus at appropriate viewport sizes - Traditional Chinese (Taiwan) translation ([#262](https://github.com/jpanther/congo/pull/262)) - New `list.paginationWidth` parameter to specify how many pagination links are generated before they are truncated - Tailwind plugin for Prettier to standardise the order of CSS classes ([#268](https://github.com/jpanther/congo/pull/268)) diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css index f20565a9..547d7483 100644 --- a/assets/css/compiled/main.css +++ b/assets/css/compiled/main.css @@ -2862,6 +2862,14 @@ body:has(#menu-controller:checked) { margin-bottom: 0px; } + .sm\:flex { + display: flex; + } + + .sm\:hidden { + display: none; + } + .sm\:w-1\/2 { width: 50%; } diff --git a/assets/js/search.js b/assets/js/search.js index 49b4d8e7..8e331fa5 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -1,5 +1,5 @@ var fuse; -var showButton = document.getElementById("search-button"); +var showButtons = document.querySelectorAll("[id^='search-button']"); var hideButton = document.getElementById("close-search-button"); var wrapper = document.getElementById("search-wrapper"); var modal = document.getElementById("search-modal"); @@ -12,7 +12,9 @@ var indexed = false; var hasResults = false; // Listen for events -showButton.addEventListener("click", displaySearch); +showButtons.forEach((button) => { + button.addEventListener("click", displaySearch); +}); hideButton.addEventListener("click", hideSearch); wrapper.addEventListener("click", hideSearch); modal.addEventListener("click", function (event) { @@ -107,7 +109,7 @@ function fetchJSON(path, callback) { function buildIndex() { var baseURL = wrapper.getAttribute("data-url"); - baseURL = baseURL.replace(/\/?$/, '/'); + baseURL = baseURL.replace(/\/?$/, "/"); fetchJSON(baseURL + "index.json", function (data) { var options = { shouldSort: true, diff --git a/config/_default/params.toml b/config/_default/params.toml index 342309c0..517c4907 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -16,7 +16,7 @@ enableCodeCopy = false # robots = "" [header] - layout = "basic" # valid options: basic, hamburger, custom + layout = "basic" # valid options: basic, hamburger, hybrid, custom [footer] showCopyright = true diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index a99f9500..63873a27 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -16,7 +16,7 @@ mainSections = ["samples"] # robots = "" [header] - layout = "basic" # valid options: basic, hamburger, custom + layout = "basic" # valid options: basic, hamburger, hybrid, custom [footer] showCopyright = true diff --git a/exampleSite/content/docs/configuration.md b/exampleSite/content/docs/configuration.md index a1fd1ec4..379db250 100644 --- a/exampleSite/content/docs/configuration.md +++ b/exampleSite/content/docs/configuration.md @@ -123,7 +123,7 @@ Many of the article defaults here can be overridden on a per article basis by sp |`logo`|_Not set_|The relative path to the site logo file within the `assets/` folder. The logo file should be provided at 2x resolution and supports any image dimensions.| |`mainSections`|_Not set_|The sections that should be displayed in the recent articles list. If not provided the section with the greatest number of articles is used.| |`robots`|_Not set_|String that indicates how robots should handle your site. If set, it will be output in the page head. Refer to [Google's docs](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives) for valid values.| -|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.| +|`header.layout`|`"basic"`|The layout of the page header and menu. Valid values are `basic`, `hamburger`, `hybrid` or `custom`. When set to `custom`, you must provide your own layout by creating a `/layouts/partials/header/custom.html` file.| |`footer.showCopyright`|`true`|Whether or not to show the copyright string in the site footer. Note that the string itself can be customised using the `copyright` parameter in the [languages configuration](#language-and-i18n).| |`footer.showThemeAttribution`|`true`|Whether or not to show the "powered by" theme attribution in the site footer. If you choose to disable this message, please consider attributing the theme somewhere else on your site (for example, on your about page).| |`footer.showAppearanceSwitcher`|`false`|Whether or not to show the appearance switcher in the site footer. The browser's local storage is used to persist the visitor's preference.| diff --git a/layouts/partials/header/hybrid.html b/layouts/partials/header/hybrid.html new file mode 100644 index 00000000..20cb57ef --- /dev/null +++ b/layouts/partials/header/hybrid.html @@ -0,0 +1,81 @@ +
+ +