helloflask / bootstrap-flask

Bootstrap 4 & 5 helper for your Flask projects.
https://bootstrap-flask.readthedocs.io
Other
1.1k stars 189 forks source link

Bootswatch Theme stored locally in session cookies #342

Closed mobone closed 4 months ago

mobone commented 8 months ago

This is more of a request than an issue. Wondering if there is an easy way to make the bootswatch theme local to the persons session cookies vs global for all users.

PanderMusubi commented 8 months ago

This should be possible. Also via flask-login you can store it in a user profile. How exactly, I also have to figure out. If you have some answers, please share them here.

PanderMusubi commented 4 months ago

@mobone, can this issue be closed?

greyli commented 4 months ago

You can just implement this by yourself. Here is an example:

PanderMusubi commented 4 months ago

Probably more people will find this information useful. @greyli would it be interesting to add an implementation for it to https://github.com/helloflask/bootstrap-flask/blob/master/examples/bootstrap5/templates/bootswatch.html ? Because now, when somebody changes the Bootswatch theme, it changes for all users.

greyli commented 4 months ago

Sounds good! Could you help to submit a PR for it?

PanderMusubi commented 4 months ago

@mobone would you like to have a go at a PR?

mobone commented 4 months ago

Yes I would. When I was testing it I saw the same. I assume because the theme is set in the backend it changes for all users.

On Fri, Feb 23, 2024 at 6:00 AM Pander @.***> wrote:

@mobone https://github.com/mobone would you like to have a go at a PR?

— Reply to this email directly, view it on GitHub https://github.com/helloflask/bootstrap-flask/issues/342#issuecomment-1961202547, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVFX2AMNWXPFP3377RWLKLYVCAEDAVCNFSM6AAAAAA6P35PF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRGIYDENJUG4 . You are receiving this because you were mentioned.Message ID: @.***>

PanderMusubi commented 4 months ago

Yes, that is the case now, but you can make it a user selection in a cookie. I can also share you some code to switch Bootstrap light and dark theme.

mobone commented 4 months ago

i understand the workaround you gave with setting the cookie and I think that'll work fine, I just haven't tried it out yet. I'll leave whether or not it needs a PR up to you.

On Fri, Feb 23, 2024 at 1:36 PM Pander @.***> wrote:

Yes, that is the case now, but you can make it a user selection in a cookie. I can also share you some code to switch Bootstrap light and dark theme.

— Reply to this email directly, view it on GitHub https://github.com/helloflask/bootstrap-flask/issues/342#issuecomment-1961883757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVFX2HMYV2GACMKBV7GLRLYVDVTTAVCNFSM6AAAAAA6P35PF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRHA4DGNZVG4 . You are receiving this because you were mentioned.Message ID: @.***>

PanderMusubi commented 4 months ago

Yes, please make a PR :-)