桌面/移动端上相同的导航栏

Continuing the discussion from Use desktop navigation-bar on mobile?:

We don’t like this (bad):

We like consistency, and we are not using all the selectors on the desktop (good) navbar:

navigation-bar

So, reusing this navbar on mobile is fine for us, in order to display latest, categories, and top.

Is that possible without breaking changes?

AI point me here, because there were changes on core in 2024, and making this change is not as easy as before.

1 个赞

Hello :wave:

I have this theme component: Floating Navigation Controls and Desktop Navigation Bar for Mobile, and there have been some requests to make it work again, as it’s currently broken.
Previously, the component used to override the template, but that method no longer works.

However, I hadn’t noticed this in the core code until now :sweat_smile:

If everything works, it’s actually easier to implement now with value transformer than before.

Add this to a theme component JS section in admin:

import { apiInitializer } from "discourse/lib/api";

export default apiInitializer((api) => {
  api.registerValueTransformer("navigation-bar-dropdown-mode", ({ value }) => {
    return false;
  });
});

Hopefully works :slight_smile:

3 个赞

this works :slight_smile:

thanks Don!

3 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.