From 739b91cb59a15ab8deecde05cab0fa4b709a6183 Mon Sep 17 00:00:00 2001 From: Ty Correll Date: Mon, 5 Feb 2024 12:41:52 -0600 Subject: [PATCH] FEATURE: add outlet above-main-container & additional settings (#17) Adds settings for above-main-container outlet, to work with site's with sidebar. And setting to show alongside category banners, which allows further customization if wanted to hide category banners for instance. --- common/common.scss | 4 ++++ .../components/discourse-tag-banners.hbs | 15 ++++++++++----- .../above-main-container/tag-header-widget.hbs | 10 ++++++++++ .../above-main-container/tag-header-widget.js | 16 ++++++++++++++++ .../above-site-header/tag-header-widget.hbs | 9 +++++++-- .../below-site-header/tag-header-widget.hbs | 9 +++++++-- .../category-banner-tag-connector.hbs | 4 +++- settings.yml | 10 ++++++++++ 8 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 javascripts/discourse/connectors/above-main-container/tag-header-widget.hbs create mode 100644 javascripts/discourse/connectors/above-main-container/tag-header-widget.js diff --git a/common/common.scss b/common/common.scss index 28dbd75..8cac467 100644 --- a/common/common.scss +++ b/common/common.scss @@ -1,3 +1,7 @@ +#main-outlet .tag-banner-container { + margin-bottom: 1em; +} + .tag-title-header { display: flex; text-align: center; diff --git a/javascripts/discourse/components/discourse-tag-banners.hbs b/javascripts/discourse/components/discourse-tag-banners.hbs index f2a7891..791ab29 100644 --- a/javascripts/discourse/components/discourse-tag-banners.hbs +++ b/javascripts/discourse/components/discourse-tag-banners.hbs @@ -6,19 +6,24 @@ {{did-update this.getTagInfo this.shouldRender}} {{will-destroy this.resetTag}} > - {{#if this.categoryBannerPresence.isPresent}} - {{else}} - {{/if}} diff --git a/javascripts/discourse/connectors/above-main-container/tag-header-widget.hbs b/javascripts/discourse/connectors/above-main-container/tag-header-widget.hbs new file mode 100644 index 0000000..100d9b5 --- /dev/null +++ b/javascripts/discourse/connectors/above-main-container/tag-header-widget.hbs @@ -0,0 +1,10 @@ +{{#if (theme-setting "show_above_main_container")}} + {{#if + (or + (not this.categoryBannerPresence.isPresent) + (theme-setting "show_with_category_banners") + ) + }} + + {{/if}} +{{/if}} diff --git a/javascripts/discourse/connectors/above-main-container/tag-header-widget.js b/javascripts/discourse/connectors/above-main-container/tag-header-widget.js new file mode 100644 index 0000000..b732062 --- /dev/null +++ b/javascripts/discourse/connectors/above-main-container/tag-header-widget.js @@ -0,0 +1,16 @@ +import Component from "@ember/component"; +import { tracked } from "@glimmer/tracking"; +import { getOwner } from "@ember/application"; + +export default class extends Component { + @tracked categoryBannerPresence = null; + + constructor() { + super(...arguments); + + // this prevents a failure if the category banner component is not installed + this.categoryBannerPresence = getOwner(this).lookup( + "service:categoryBannerPresence" + ); + } +} diff --git a/javascripts/discourse/connectors/above-site-header/tag-header-widget.hbs b/javascripts/discourse/connectors/above-site-header/tag-header-widget.hbs index a5afc90..146a624 100644 --- a/javascripts/discourse/connectors/above-site-header/tag-header-widget.hbs +++ b/javascripts/discourse/connectors/above-site-header/tag-header-widget.hbs @@ -1,5 +1,10 @@ {{#if (theme-setting "show_above_site_header")}} - {{#unless this.categoryBannerPresence.isPresent}} + {{#if + (or + (not this.categoryBannerPresence.isPresent) + (theme-setting "show_with_category_banners") + ) + }} - {{/unless}} + {{/if}} {{/if}} diff --git a/javascripts/discourse/connectors/below-site-header/tag-header-widget.hbs b/javascripts/discourse/connectors/below-site-header/tag-header-widget.hbs index 4e30ea1..3ab7897 100644 --- a/javascripts/discourse/connectors/below-site-header/tag-header-widget.hbs +++ b/javascripts/discourse/connectors/below-site-header/tag-header-widget.hbs @@ -1,5 +1,10 @@ {{#if (theme-setting "show_below_site_header")}} - {{#unless this.categoryBannerPresence.isPresent}} + {{#if + (or + (not this.categoryBannerPresence.isPresent) + (theme-setting "show_with_category_banners") + ) + }} - {{/unless}} + {{/if}} {{/if}} diff --git a/javascripts/discourse/connectors/category-banners-after-title/category-banner-tag-connector.hbs b/javascripts/discourse/connectors/category-banners-after-title/category-banner-tag-connector.hbs index 8372cd9..6706b8f 100644 --- a/javascripts/discourse/connectors/category-banners-after-title/category-banner-tag-connector.hbs +++ b/javascripts/discourse/connectors/category-banners-after-title/category-banner-tag-connector.hbs @@ -1 +1,3 @@ - +{{#if (not (theme-setting "show_with_category_banners"))}} + +{{/if}} diff --git a/settings.yml b/settings.yml index 758c05e..dfa7d55 100644 --- a/settings.yml +++ b/settings.yml @@ -16,6 +16,11 @@ show_below_site_header: type: bool description: "Display the banner in the below site header connector." +show_above_main_container: + default: false + type: bool + description: "Display the banner in the above main container connector, for sites with the sidebar enabled." + remove_tag_hyphen: default: false type: bool @@ -30,3 +35,8 @@ hide_tag_icon: default: false type: bool description: "Hide the tag icon when used along with category banners" + +show_with_category_banners: + default: false + type: bool + description: "Show full banner alongside category banners"