I need to add new button to Sidebar (or some other place possible to discuss too), which will simply toggle user’s custom field value. We set up “SFW” mode, by basically inverting this approach. But as the value is optional to set by user and the website is NSFW by default, it would take time for one user to get into their profile settings in order to find tiny and non-evident checkbox.
That’s why the idea of putting a button with two states (On/Off) which will change the custom field’s value for the user. The default state is NSWF (unchecked user’s field, or 0). The second state is SFW (checked user’s field)
When do you need it done?
It seems to me it should be a quick task for experienced theme-component developer Take your time
What is your budget, in $ USD that you can offer for this task?
What an awesome theme-component User Field Prompt is! No matter how frequent I visit Discourse Meta, it’s always amazing to find something new about Discourse.
The task described is different from the concept of post fields. And it’s also not intended to play with other theme components like Welcome Link Banner you mentioned.
The maximum customization I see now is introducing basic customization options like:
Discourse Text-fields for admin to be able to Create/Update/Delete buttons based on example of numerous theme components like Custom Header Links (icons)
Admin could give button:
a Name (ID for CSS purposes)
SVG Icons names for both states (requires it to be present in font-awesome sprites or website custom SVGs)
Okay haven’t played with it yet. but there is also page publishing.
I would imagine the code may help to get some ideas. There are a few components that use user fields. A more recent addition is a kind of watched words for the member that will hide? posts with word term.
There are also some theme-components that use a switch toggle in iirc Hamburger menu or header.
Custom header links may work as well possibly.
I am not sure but with a checkbox? you might be able to copy the link for that user prefer checkbox.
Thanks need to update the site address. The client changed from.ai to .com.
The idea I meant above. You could look at the source fir the User field prompt to get an idea for the code you need to toggle your nsfw user setting. Then look at maybe something like the Thene-component Light/Dark toggle and combine ideas for the toggle to manipulate your nsfw user setting.
It does what you talk about. Looks into the user’s field value and sets CSS class via JS. Please make sure you use the code from this message as the base one, because the one used in the first post there relies on deprecated Discourse methods.
In addition, you can look into this: CSS Classes for Current User's Groups to adjust the look & functionality of your website based on user’s groups
As for toggle itself, and your reference to Dark/Light toggle, I guess it may be interesting to look into it for the future developers of this component I’d like to share to public as soon as it’s finished. @Lhc_fl is working now on something and we will hopefully be able to test it ourselves in production first