Skip to content

v5.5.0

Choose a tag to compare

@LouisMazel LouisMazel released this 07 Nov 21:40
· 390 commits to develop since this release

compare changes

🚀 Features

  • themes: Themes now render on the server and follow the theme cookies. getThemeHead() returns the <html> class, the CSS, the color-scheme meta and a blocking script for any SSR or SSG server, resolving the preset and color mode from cookies and the Sec-CH-Prefers-Color-Scheme hint (see server rendering). With the Cookie Store API, a change of the maz-color-mode or maz-preset cookie applies without a reload. The color mode now lives in a single maz-color-mode cookie, so the saved color mode is reset once. Also fixes the color mode when a host toggles the classes (VitePress) with the buildtime and media strategies, and useTheme() no longer shares its state between SSR requests (c26bc8cfd)

  • translations: English is now bundled, so the first render and server rendering never show translation keys. Each createMazUiTranslations() has its own locale and messages, so a MazUiProvider or a server request no longer changes the locale of the whole app. The instance exposes a ready promise to wait for the locale's messages. setLocaleMessage no longer prevents a locale's default messages from loading, the last setLocale call wins, and a failed load is retried on the next explicit call (27b3cc503)

  • nuxt: The translations.messages option accepts a file path per locale, with aliases allowed so it works from a layer. Files load on demand, messages no longer go into the payload of every page, and the server renders the page in the right language (92a536b60)

    export default defineNuxtConfig({
      mazUi: {
        translations: {
          locale: 'fr',
          messages: { fr: '~/locales/fr.ts' },
        },
      },
    })

🩹 Fixes

  • utils: Handle the equal sign and invalid encodings in getCookie (f5e680306)
  • nuxt: Keep the preset and the color mode of the user across reloads: a preset switched with updateTheme() no longer reverts to the configured one on the second reload, the first paint follows the live system preference, and deleting the maz-color-mode cookie restores the configured colorMode (892e52640)
  • maz-ui: Tint shadow-xs with the shadow color of the preset (5a8bb955e)
  • maz-ui: Apply the new messages of MazUiProvider after the mount (5ed3c94fd)
  • maz-ui: Render the panel of MazPopover in the browser only, which fixes Nuxt hydration mismatches (including MazSelect, MazSelectCountry, MazDropdown, MazDatePicker and v-tooltip), and a popover open by default now opens right after hydration. Nested popovers are fixed too: a click in the inner one keeps the outer one open, Escape closes the last opened one first, open and close are emitted once, the focus trap handles every field and skips disabled ones, hover tooltips also show on keyboard focus, and a disabled popover never shows its panel (638fc7a86)

📖 Documentation

  • docs: Document the theme cookies and the server rendering (726b5fa15)
  • docs: Follow the active preset in the VitePress theme and fix the dead links (3d52c2ed9)
  • docs: Document the loading of the translations, the server rendering and the nested popovers (be54bd708)

❤️ Contributors