@castlabs/ui 7.17.0 → 7.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/select-disabled.svg +1 -1
  3. package/dist/castlabs-ui-editor.css +1 -1
  4. package/dist/castlabs-ui-editor.umd.js +1 -1
  5. package/dist/castlabs-ui.common.js +3 -3
  6. package/dist/castlabs-ui.common.js.map +1 -1
  7. package/dist/castlabs-ui.core.js +49 -1
  8. package/dist/castlabs-ui.css +1 -1
  9. package/dist/castlabs-ui.module.d.ts +4 -0
  10. package/dist/castlabs-ui.module.js +49 -1
  11. package/dist/castlabs-ui.umd.js +4 -4
  12. package/dist/castlabs-ui.umd.js.map +1 -1
  13. package/dist/{select-disabled.c5e07724.svg → select-disabled.1065ea4c.svg} +1 -1
  14. package/dist/select-disabled.dark.1065ea4c.svg +1 -0
  15. package/dist/select.dark.efd5244b.svg +1 -0
  16. package/package.json +9 -9
  17. package/src/components/ClBadge/style.variables.scss +1 -1
  18. package/src/components/ClButton/style.scss +18 -0
  19. package/src/components/ClDropdown/style.scss +1 -1
  20. package/src/components/ClDropzone/style.scss +1 -1
  21. package/src/components/ClHighlight/style.scss +2 -4
  22. package/src/components/ClList/style.variables.scss +5 -0
  23. package/src/components/ClPagination/style.scss +2 -3
  24. package/src/components/ClToggle/style.scss +1 -1
  25. package/src/components/ClWizard/style.scss +4 -4
  26. package/src/components/form/ClField/style.scss +1 -1
  27. package/src/components/form/ClFieldCheck/style.scss +23 -8
  28. package/src/components/form/ClFieldGroup/style.scss +1 -1
  29. package/src/components/form/ClFieldInput/style.scss +3 -2
  30. package/src/components/modal/ClModal/style.scss +3 -1
  31. package/src/components/navigation/ClNavSide/ClNavDrawer/style.scss +3 -5
  32. package/src/components/navigation/ClNavSide/ClNavItemDarkMode/style.scss +44 -0
  33. package/src/components/navigation/ClNavTop/style.scss +5 -1
  34. package/src/components/widget/ClPage/style.scss +1 -1
  35. package/src/styles/_global.scss +1 -0
  36. package/src/styles/abstracts/button.scss +10 -1
  37. package/src/styles/abstracts/color.scss +50 -13
  38. package/src/styles/abstracts/typography.scss +3 -1
  39. package/src/styles/layout/color.scss +0 -38
  40. package/src/styles/layout/grid.scss +4 -3
  41. package/src/styles/layout/meta.scss +1 -1
  42. package/src/styles/layout/typography.scss +1 -1
  43. package/src/styles/themes/dark.scss +160 -0
  44. package/src/styles/themes/dark.variables.scss +33 -0
  45. package/src/styles/ui.scss +6 -0
  46. package/types/castlabs-ui.module.d.ts +4 -0
  47. package/types/index.d.ts +5 -0
@@ -73,6 +73,10 @@ declare module '@castlabs/ui/dist/castlabs-ui.module.js' {
73
73
  ): Promise<any>
74
74
  export function clReloadStore (component: any, forced?: any[], optional?: any[], loading?: boolean): Promise<any>
75
75
 
76
+ // theme utils
77
+ export function clThemeSetup (): boolean
78
+ export function clThemeSetDark (dark: boolean): void
79
+
76
80
  // search utils
77
81
  export function clMatch (string: string, expression?: string, caseSensitive?: boolean): boolean
78
82
 
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.17.0 */
1
+ /* @castlabs/ui v7.18.0 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -324,6 +324,7 @@ export const CONST = {
324
324
  CLAY: '#cfc8c8',
325
325
  EGGSHELL: '#fbf9f2',
326
326
  HAZE: '#eeece6',
327
+ HAZEDARK: '#333947',
327
328
  HONEY: '#dc9404',
328
329
  LEAF: '#53965d',
329
330
  NIGHT: '#262a35',
@@ -1709,3 +1710,50 @@ export function clReload (component, forced = [], optional = [], loading = true)
1709
1710
  export function clSleep (ms) {
1710
1711
  return new Promise(resolve => setTimeout(resolve, ms))
1711
1712
  }
1713
+
1714
+ // -----------------------------------------------------------------------------
1715
+ // --- themes ------------------------------------------------------------------
1716
+ // -----------------------------------------------------------------------------
1717
+
1718
+ export function clThemeSetup () {
1719
+ let dark = null
1720
+
1721
+ // try to load settings
1722
+ try {
1723
+ switch (localStorage.getItem('themeDark')) {
1724
+ case 'true':
1725
+ dark = true
1726
+ break
1727
+ case 'false':
1728
+ dark = false
1729
+ break
1730
+ default:
1731
+ dark = null
1732
+ }
1733
+ } catch (e) {
1734
+ e.ignore?.()
1735
+ } // catch & ignore private mode
1736
+
1737
+ // use OS default if unknown
1738
+ if (dark === null) {
1739
+ const darkModeMql = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)')
1740
+ if (darkModeMql?.matches) {
1741
+ dark = true
1742
+ } else {
1743
+ dark = false
1744
+ }
1745
+ }
1746
+
1747
+ // persist value
1748
+ clThemeSetDark(dark)
1749
+
1750
+ return dark
1751
+ }
1752
+
1753
+ export function clThemeSetDark (dark) {
1754
+ try {
1755
+ localStorage.setItem('themeDark', dark)
1756
+ } catch (e) {
1757
+ e.ignore?.()
1758
+ } // catch & ignore private mode
1759
+ }