color-mode
color-mode copied to clipboard
Change theme without saving a cookie
Hey there, using this module and it works great so far.
Due to GDPR I am not allowed to save things in the user's browser, without receiving their consent first. But, when using:
this.$colorMode.preference = this.currentTheme
a cookie is automatically set. While I understand that the user experience is not exactly great when I can not save the theme selection for the next visit of the user, I still don't want to prevent users that didn't give me their consent (yet!) from trying out the alternative theme.
Is there a way to change the current theme without saving a cookie?
Hi @markusressel
The cookie is a functional one, not related to user tracking at all, so there should not be any problem regarding it
I don't have the link handy, but what I have read so far wasn't exactly clear on whether this counts as functional or not, so I wanted to be on the safe side. Afaik even a simple language setting does not count as functional. Do you happen to know of websites that do this? Or have a source that is trustworthy?
checking last code, are we still using cookies? /cc @Atinux (https://github.com/nuxt-community/color-mode-module/blob/master/lib/templates/plugin.client.js)
Regarding cookies, Language and color seems to be same category (preferences/functionality)
https://gdpr.eu/cookies Preferences cookies — Also known as “functionality cookies,” these cookies allow a website to remember choices you have made in the past, like what language you prefer, what region you would like weather reports for, or what your user name and password are so you can automatically log in.
If you are sure (*) no notice is required for lang, it should be fine. Only i guess max 12M ttl is important.
(*) Receive users’ consent before you use any cookies except strictly necessary cookies.
checking last code, are we still using cookies?
Well it's not a cookie but a local storage entry. But that is irrelevant, the GDPR doesn't specifically target cookies only.
(*) Receive users’ consent before you use any cookies except strictly necessary cookies.
I mean, thats the tricky part for me :smile: Beeing able to set a theme imo isn't strictly necessary. It's a convenience feature. Without nuxt color mode my whole site could be used without anything stored anywhere. Thats my goal :)
I see, in that case you should not even display the color switcher until the user approved the consent banner right?
Again, as mentioned in OP, I would like to let users select a theme, even if it is only used for their current session and not persisted. This is currently not possible, because setting a theme value also sets a cookie. I should probably make the user aware of that with a little tooltip or something, but thats for me to decide.
The theme selection could (and imo should) be fully functional without the cookie, it just doesn't persist for the next session. I think this is a use case that would be beneficial to all GDPR compliant sites. But of course its not a huge issue or anything. I thought it might be pretty easy to separate the cookie from the current theme selection so I asked.
From what I see, we could have an option to disable storing the theme into the localStorage
but only in memory.
Something like:
export default {
colorMode: {
storage: 'memory' // default: 'localStorage'
}
}
Would that work for you?
But if using the localStorage for this is fine and does not need any GPDR approval, then no need to add such feature.
Yes, I think this would work.
It would also be great if it were possible to change this after the fact using javascript.
Something like this (storage initially set to memory):
$colorMode.storage = 'localStorage'
$colorMode.preference = currentSelection
How comfortable are you to open a PR?
Actually, we discussed with Pooya and since we won't support many storage, we could have remember: false
option (default to true
)
Would also work :+1:
I am not sure if I can find the time to deep dive into the repository and change something without breaking things :sweat_smile: If you cannot spare the time I guess I will have to, but it would be very much appreciated if one of you guys were able to work this in. Regardless of the response: Thank you for taking the time! :nerd_face:
Closing this due to lack of activity and outdated infos. Thx for the conversation!