Discourse Persistent banner

AI-generated summary

The Discourse Persistent banner theme component is a customizable banner that can be displayed at the top of every page, with settings to control its appearance, including background color, text color, border color, and thickness. The banner can be placed at different outlets, such as above-site-header, below-site-header, above-main-container, and before-topic-list. NateDhaliwal created this component, which has 7 settings to control the banner, including banner_background_color, banner_text_color, banner_border_color, banner_border_thickness, banner_text_content, banner_visible, and banner_location.

Lilly provided feedback and suggestions, including issues with placement on desktop mode, controlling border size and color, and adding options for placement with different plugin outlets. NateDhaliwal addressed these concerns and implemented the suggested changes, including adding a multi-line textbox for the banner text input setting and allowing admins to use hex values, valid CSS colors, or theme variables for color choices.

The updated component has been tested by Lilly, who confirmed that the issues with placement on desktop mode have been fixed. NateDhaliwal also simplified the .gjs file by moving the if statements to the .scss file. The component is available for installation, and a preview can be seen at https://discourse.theme-creator.io/theme/NateDhaliwal/persistent-banner.

:information_source: Summary A persistent banner is shown at the top of every page that can only be hidden by Admins.
:eyeglasses: Preview Theme Creator
:hammer_and_wrench: Repository GitHub - NateDhaliwal/discourse-persistent-banner: A theme component for Discourse that cannot be closed by the user. · GitHub
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

This component displays a banner at the top of every page. Any valid CSS colours can be used. If you are planning to use discourse theme variables, wrap them in var(), so you’ll get something like var(--tertiary-very-low).


There are 7 settings to control the banner.

  1. banner_background_color changes the background color of the banner.
  2. banner_text_color changes the text color of the banner.
  3. banner_border_color changes the border color of the banner.
  4. banner_border_thickness changes the border thickness of the banner.
  5. banner_text_content changes the text of the banner. The text will wrap in the banner if it is longer than 1 line.
  6. banner_visible changes the visibility of the banner. show to show the banner, hide hides the banner.
  7. banner_location places the banner at 1 of the 4 outlets given: above-site-header, below-site-header, above-main-container and before-topic-list.

Special thanks to @Lilly for helping out to sort out the files!

4 Likes

I find it quite similar to the theme components “Notification banners” and it has more customization.

2 Likes

Yes, but this way, the banner stays there (people have asked how to make the banner come back after closing it).

2 Likes

Nice work Nate. :clap: :slight_smile:
I like the simplicity

I don’t think the theme creator preview is working. :thinking:

A few suggestions for you to think about:

  • there is a bit of an issue of placement on desktop mode, especially if one is using a wide / full screen.

  • it would be nice to control that border size and color.

  • perhaps options for placement with different plugin outlets, like below-site-header and above-main-containter?

  • while the use of enum list vs text input for color choices is convenient, it also limits admins from using the color pallet variables that work with dark / light modes, or for being more granular with hex color values.

  • I would suggest making the banner string text input setting with the textarea: true property, then you will get a multi-line textbox that the user can expand. Then it’s easier to do this:

2 Likes

I’ll play around with the placings of the banner, and try to get this working.

Shouldn’t be to much of a problem, I’ll add this.

Got it. I have some sort of an idea on how to implement this.

I think I can implement this.

Got it, I’ll add this.

1 Like

@Lilly Just to check, do I add this in settings.yml?

1 Like

yes, you can see it here in the versatile banner component:

result in component settings:

2 Likes

Implemented.

Done.

You can now use hex values (include the #), valid CSS colours or theme variables (var(–var-name)).

Also done.

I think it’s fixed. Could you try it on your side?

2 Likes

this is definitely fixed. nice work. :smiley: :discourse:

screenshot from my widescreen desktop view

3 Likes

UPDATE:
I have simplified the .gjs file by moving the if statements of checking if the banner text is empty and the visibility of the banner to the .scss file.

2 Likes