Changelog

Discover the latest Nuxt Color Mode updates.


What's Changed

New Contributors

Full Changelog: https://github.com/nuxt-modules/color-mode/compare/v3.1.4...v3.1.5

馃憤 2馃憖 1

v3.1.5

@Atinux

September 9, 2022

What's Changed

New Contributors

Full Changelog: https://github.com/nuxt-community/color-mode-module/compare/v3.1.3...v3.1.4

鉂わ笍 3

v3.1.4

@Atinux

June 9, 2022

Bug Fixes

  • handle data attribute in script as well (30b173e)
馃殌 5

v3.1.3

@Atinux

May 31, 2022

What's Changed

Full Changelog: https://github.com/nuxt-community/color-mode-module/compare/v3.0.3...v3.1.0

v3.1.0

@Atinux

May 31, 2022

What's Changed

New Contributors

Full Changelog: https://github.com/nuxt-community/color-mode-module/compare/v3.0.2...v3.0.3

馃憤 3

v3.0.2

@Atinux

May 10, 2022

Bug Fixes

  • move script to head and set forced color mode on <html> element (#128) (273f07e)

v3.0.1

@danielroe

February 21, 2022

v3 of @nuxtjs/color-mode requires either Nuxt Bridge or Nuxt 3. If you are using Nuxt 2 without Bridge, you should continue to use v2.

馃敟 Notable changes

  1. Uses @nuxt/module-builder to build module.
  2. Refactor structure (lib -> src/dist, templates -> runtime)
  3. rewrite in TypeScript
  4. Move from templating options to creating a virtual module for greater performance
  5. Use esbuild to minify the script - note: 鈿狅笍 it's likely this raises the minimum browser target 鈿狅笍

馃憠 Migration

  1. The main change between Nuxt 2 -> Nuxt 3 is that you will define your color mode at the page level with definePageMeta:
      <template>    <h1>This page is forced with light mode</h1>  </template>    <script>- export default {-   colorMode: 'light',- }+ definePageMeta({+   colorMode: 'light',+ })  </script>

    鈿狅笍 If you are using Nuxt Bridge, you should not use definePageMeta but instead continue using the component option colorMode.
  2. The $colorMode helper remains the same, but there is also a new composable (useColorMode) which is the recommended way of accessing color mode information.
  3. If you were directly importing color mode configuration types, note that this has been renamed to ModuleOptions.
馃憤 4馃帀 6鉂わ笍 6馃殌 8

v3.0.0

@danielroe

February 16, 2022

  • fix: add script to webpack build (in dev) for storybook support (#99) 路 54b482b

v2.1.1

@Atinux

August 2, 2021

  • feat: add csp hash for color script (#94) 路 e2f1ffc
  • test: migrate to @nuxt/test-utils (#96) 路 30dcff2
  • test: fill out additional test targets (#97) 路 2ca9edc

v2.1.0

@Atinux

August 2, 2021

馃帀 6鉂わ笍 5

v2.0.10

@Atinux

June 11, 2021

Bug Fixes

  • types compatible with nuxt-property-decorator (#72) (43f5806)

v2.0.4

@Atinux

March 3, 2021

  • fix: don't use window in created (#59) 路 9b47c6e
  • fix(type-defs): make interface ColorModeInstance extend Vue (#62) 路 bac6667

v2.0.3

@Atinux

January 25, 2021

Bug Fixes

  • type-defs: make all options optional (#56) (7d2aaff)

v2.0.2

@Atinux

December 4, 2020

Bug Fixes

  • type-defs: add types reference to package (#52) (82592f4)

v2.0.1

@Atinux

December 2, 2020

Notes

  • 鈿狅笍 聽The breaking change is only if you are using the cookie option in the V1, if you don't use it, you can upgrade easily.
  • 馃摌 聽Read the updated documentation
  • 馃幃 聽Checkout the updated demo

Force a color mode

You can force the color mode at the page level (only parent) by setting the colorMode property:

<template>  <h1>This page is forced with light mode</h1></template><script>export default {  colorMode: 'light',}</script>

This feature is perfect for implementing dark mode to a website incrementally by setting the non-ready pages to colorMode: 'light'.

We recommend to hide or disable the color mode picker on the page since it won't be able to change the current page color mode, using $colorMode.forced value.

See example: https://color-mode.nuxtjs.app/light

Local Storage only

This will also fixes #38

Using a cookie is only worth for doing server-side rendering with no cache, where actually localStorage work in every-case and won't lead to a flash on client-side anyway.

This also simplify the options and reduce the dependency with the cookie package.

To customize the storage key, you now have to use the storageKey property instead of cookie.key.

v2.0.0

@Atinux

October 13, 2020

Bug Fixes

  • types: add new options and include in package (00bb7e8)

v1.1.1

@Atinux

September 15, 2020

Features

v1.1.0

@Atinux

September 15, 2020

Bug Fixes

  • handle spa fallback (regression) (b92d64b), closes #21

v1.0.3

@Atinux

August 4, 2020

v1.0.2

@Atinux

July 28, 2020