color-mode icon indicating copy to clipboard operation
color-mode copied to clipboard

Change theme without saving a cookie

Open markusressel opened this issue 3 years ago • 11 comments

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?

markusressel avatar Apr 25 '21 04:04 markusressel

Hi @markusressel

The cookie is a functional one, not related to user tracking at all, so there should not be any problem regarding it

atinux avatar Apr 27 '21 07:04 atinux

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?

markusressel avatar Apr 27 '21 17:04 markusressel

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.

pi0 avatar Apr 27 '21 18:04 pi0

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 :)

markusressel avatar Apr 28 '21 06:04 markusressel

I see, in that case you should not even display the color switcher until the user approved the consent banner right?

atinux avatar May 14 '21 09:05 atinux

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.

markusressel avatar May 14 '21 16:05 markusressel

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.

atinux avatar Jun 11 '21 16:06 atinux

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

markusressel avatar Jun 11 '21 17:06 markusressel

How comfortable are you to open a PR?

atinux avatar Jun 13 '21 12:06 atinux

Actually, we discussed with Pooya and since we won't support many storage, we could have remember: false option (default to true)

atinux avatar Jun 14 '21 09:06 atinux

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:

markusressel avatar Jun 14 '21 21:06 markusressel

Closing this due to lack of activity and outdated infos. Thx for the conversation!

markusressel avatar Mar 20 '23 07:03 markusressel