demo-theme.js 1018 B

1234567891011121314151617181920212223242526272829303132
  1. /*!
  2. * Tabler v1.0.0-beta17 (https://tabler.io)
  3. * @version 1.0.0-beta17
  4. * @link https://tabler.io
  5. * Copyright 2018-2023 The Tabler Authors
  6. * Copyright 2018-2023 codecalm.net Paweł Kuna
  7. * Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
  8. */
  9. (function (factory) {
  10. typeof define === 'function' && define.amd ? define(factory) :
  11. factory();
  12. })((function () { 'use strict';
  13. var themeStorageKey = 'tablerTheme';
  14. var defaultTheme = 'light';
  15. var selectedTheme;
  16. var params = new Proxy(new URLSearchParams(window.location.search), {
  17. get: function get(searchParams, prop) {
  18. return searchParams.get(prop);
  19. }
  20. });
  21. if (!!params.theme) {
  22. localStorage.setItem(themeStorageKey, params.theme);
  23. selectedTheme = params.theme;
  24. } else {
  25. var storedTheme = localStorage.getItem(themeStorageKey);
  26. selectedTheme = storedTheme ? storedTheme : defaultTheme;
  27. }
  28. document.body.classList.remove('theme-dark', 'theme-light');
  29. document.body.classList.add("theme-".concat(selectedTheme));
  30. }));