Announcement Bar

Install this theme component

Settings

There are a few options to set content, cookie and layout placement:

Styles

For CSS styling the component structure is:

.announcement-bar {
  &__wrapper { }

  &__container { }

  &__content { }

  &__close { }
}
20 Likes

Nice work as always @nolo :clap: :slight_smile:

7 Likes

Awesome component idea!

Would it be possible to add settings which would limit groups of users to which the announcement should be visible?

6 Likes

Thanks for the suggestion @kinetiksoft! I like to keep shared components without group features though :smile: . The reason is that in my experience the actual use cases are often more specific than just selecting a group. You might need to distinguish anonymous visitors as well. Or display different content to different groups. And then it adds complexity already.

I usually fork components or just implement different layout options with CSS. So I’m afraid this would be my recommendation as well.

With respect to targeting groups with CSS, the Discourse groups css classes in body is a great helper component.

2 Likes

2 posts were split to a new topic: Install theme button not working under Ember 5

Hi
After installing and enabling i get the following error:

I think the this console error is relevant:

Am i missing something? Thanks

2 Likes

It looks like you are using a Discourse version that doesn’t support .gjs format file.

I believe this was introduced in v3.2.0.beta3 (2023, July – specifically a this commit)

Unfortunately, unless someone would make a version without using .gjs file, you can either upgrade Discourse or uninstall the component.

4 Likes

We’re on 3.1 - so that will make sense.

Hopefully Events will upgrade soon to support 3.2 and we’ll jump ship.

Thanks

4 Likes

Sorry for the confusion @martyn_thomas and thanks for explaining the reason @Arkshine! I’ve updated the about file to state "minimum_discourse_version": "3.2.0.beta3".

6 Likes

Hi,

I could be mistaken, but I believe when someone dismisses the announcement (which should be an option for the admin to remove), it removes it for everyone else separately in desktop view or mobile view.

I only know this because I turned it off and on to test it, and left it running. I haven’t crossed it off, and now it’s disappeared?

I don’t exactly understand what you’re referring to. Could you state again what you did on the admin backend and then what you saw as outcome for users? And for which users?

I’m referring to this theme component.

I have this on my forum, but it disappears when I haven’t crossed it off as you have an option to show it or not, as an end user.

I’ve disabled and enabled it again to see if it was an issue, but I believe when someone dismisses the theme components it removes it for everyone else. First, I noticed it on my desktop view, then next on mobile view.

1 Like

It shouldn’t. Dismissing a global banner or pinned topic should only dismiss it for that logged in user. Not all users.

1 Like

Disabling the component does remove it for all.

Now if you dismissed the current banner and disable and re enabled the component. It will not reappear unless either changed or iirc you might need to clear cookies.

Hmm… I’ve done this. I’ve also impersonated someone who hasn’t logged in for a while and cannot see the announcement bar.

@Aaron_Walsh what I can reproduce:

  • dismiss the announcement bar, either as a user or anonymous visitor
  • log out or switch to a different user account on the same browser
  • the bar will not show on the same browser

So I assume this is a cache issue. Apparently the way the cookie is implemented is not sensitive to the user account but to the browser history. I copied the cookie code from another component and I’m not very knowledgeable about how cookies work in detail. Happy to change the code if it’s actually possible and someone has the code. Else I’m not that concerned about it. What I see is that it only affects the same browser, and the bar is not dismissed for other users on their respective session.

3 Likes

I can confirm. Loaded bar. Dismissed with my admin account.

Logged in an anon browser with different user.

Not logged in Bar shows. Logged in test user bar shows. Disniss bar and log out and back in no bar. Close incognito chrome browser and open new one. Announce bar is back.

So definitely a cookie/browser cache related issue.

1 Like

Impersonate does not clear your browser cookies.

Yes, I know this. I mean, I’ve done a clear cookies matter of fact data with Chrome just to be sure.

Impersonate was just a test to see if they have this showing on their account.

1 Like