Last active
December 29, 2025 10:18
-
-
Save laurentpellegrino/58859bf00c50152249b9eab5156b81b6 to your computer and use it in GitHub Desktop.
Noticeable Widget rendering with custom settings based on conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const labelId = '83e6Z7u9rW83elan09Nx' | |
| const widgetId = 'iTyk3i4j5sECMquDZLgP' | |
| noticeable.on('widget:ready', widgetId, async function(event) { | |
| const publications = event.detail.publications | |
| if (publications.length > 0) { | |
| if (publications[0].labels.includes(labelId)) { | |
| const widgetOptions = { | |
| backgroundColor: '#ff0000', | |
| backgroundColorHover: 'darkred', | |
| }; | |
| await window.noticeable.set('widget:widget_view:settings', widgetId, widgetOptions) | |
| } | |
| } | |
| }) | |
| noticeable.render('widget', widgetId); |
Author
Author
Note that widget options depend on the widget view used (top banner, modal, etc.). They are not documented yet, but I’ll be happy to assist if needed. All settings you can change in the live editor are also available for real-time updates.
Thanks, this is helpful. I'll try that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To identify the identifier of a label, the easiest is to open the label for edition in the Noticeable dashboard (click "Labels" in the left navigation, then the vertical 3 dots icon next to the label you want and "edit"). In the URL you will see something like:
https://dashboard.noticeable.io/projects/oDl2ozWWAY8yFTFPO7KC/labels/83e6Z7u9rW83elan09Nx/edit
the characters between the last 2 / is your label ID (83e6Z7u9rW83elan09Nx in the example above).