Overview
A Theme Component that allows you to lay out Components (âwidgets*â) on top and side bars
- Specify a set of âwidgetsâ distinctly for Route and Position.
- Supports setups for each of: discovery[1], topic, tag[2], category[2:1], categories[2:2] or the new custom homepage![3]
- âBarsâ can be either: top, left, right OR alternative right location.
- Each bar can be collapsed or dismissed (refresh browser to reset dismiss).
- Handles the Official Sidebar, but if you intend you use a Bars Left Sidebar, the Dropdown mode of the official Sidebar is recommended (change setting
navigation menu
to âDropdownâ) - It comes with existing example settings that show some big letters, partly as a demo and partly so you can see example settings. Delete these and replace with your own Component names.
- Ships with one Component:
bars-custom-html
(see pre-filled example settings) - but components from many existing Theme Components & Plugins are compatible. - Mobile support is not yet implemented.
Quick Links
Get the code | https://github.com/merefield/discourse-tc-bars |
See the code | GitHub - merefield/discourse-tc-bars: A Theme Component that allows you to lay out Components ("widgets") on top and side bars |
Installation Guide | Install a theme or theme component |
Enjoying this Theme Component? Please it on GitHub !
Gratuitous example:
Upon first load:
Some important things to note about this TC!
-
This Theme Component is mainly intended for developers and administrators that have some technical understanding of Theme development. If you are not sufficiently technical and need help with implementing sidebars using Bars, you can hire me or a developer in marketplace
-
This Theme Component is intended to provide a framework for supporting sidebars. It does not and is not intended to provide final visual polish which you will need to add in your Theme with additional CSS. However, it does a lot of work for you and gives you less things to think about and maybe even give you the ability to do things you didnât have the ability to do before âŚ
-
Consider this a little experimental at this stage! Be prepared for potential volatility in function and styling selectors
Component considerations
-
You must specify a Component name. The component name is in fact the same as the filename in the theme, tc or plugin
component
directory without the suffix.- the component name is not the name of the Theme Component (which could hold many Ember Glimmer Components), itâs the name of the actual Ember Component file , so e.g.:
so
layouts-tag-list
-
They can be from an existing Theme Component or Plugin. Existing Components may work. Examples are:
- đˇď¸ Tag List Widget (Bars & RSB Theme Component)
- Render a component within a Widget. (Using select-kit components within plugin code) - #31 by merefield
- Discourse AI Topic Summary: đ¤ automated summaries and smart tagging ⌠and possibly even:
- The Leaderboard widget: discourse-gamification/assets/javascripts/discourse/components/minimal-gamification-leaderboard.js at main ¡ discourse/discourse-gamification ¡ GitHub (let me know if you try it down below!)
-
It requires some expertise to build Components
- But have a go at building your own Component in another Theme Component and make sure they are both active in the same Theme.
-
Components must source their own data (they canât use plugin outlet pass-through models unfortunately due to the specific plugin outlets required to be used to lay things out in this way)
- Out of the box, you can only use existing json API data from e.g. Discourse core or ones provided by an existing Plugin. If you need bespoke data that you canât source from current APIâs, you can hire me or someone in marketplace to help you.
-
You may need to style the sidebar and component boundaries to taste. (again if you need help, consider hiring a developer).
- Strategic use of box shadows and borders can make things look really nice - be artistic!
Why
-
With the update of Discourse core to Ember 5, the trick Pavilionâs plugin Layouts used to provide an excellent way to manipulate the Discourse layout ceased to work. There was now no easy way to show a sidebar on a Topic route via a relatively easy end-user interface.
-
In addition, Ember introduced Glimmer Components that were much nicer to work with. (Layouts used the Widgets API which is deprecated in favour of Glimmer Components).
-
Finally Discourse core team provided a new JSON editor for Theme Component settings which made deploying a more complex setting possible
-
Rather than fix the Layouts plugin (TCâs didnât exist back in Layouts day), it made sense to rebuild as a Theme Component, because we can achieve most things we need just in the front end.
-
Enter âBarsâ Cheers!!
Known Issues
- Top bar doesnât stick (I may remove the corresponding setting if I canât resolve).
Credits
- Spiritual successor to the now broken Layouts Plugin built by @angus (Cheers!) which served us well for many years.
- Uses the params system from Right Side Blocks (thanks @pmusaraj!)
the term âdiscoveryâ (route) refers to the main Topic List pages (e.g. âLatestâ, âNewâ) that allow you to browse available Topics before clicking and diving into a specific one. âŠď¸
technically also a âdiscoveryâ route but weâre breaking these out to distinct names so you can treat them differently if you so choose. âŠď¸ âŠď¸ âŠď¸
currently not yet available on
stable
, onlytests-passed
. See here for more details. So that this remains optional (not all installers of Bars will want a custom homepage) Bars does not add the required modifier inabout.json
so you must add this in the parent Theme or another TC to activate it. âŠď¸