@neko-os/ui 0.0.8 → 0.0.9

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 (102) hide show
  1. package/dist/NekoUI.js +1 -1
  2. package/dist/abstractions/ActivityIndicator.native.js +1 -1
  3. package/dist/abstractions/ActivityIndicator.web.js +1 -0
  4. package/dist/abstractions/BlurView.web.js +1 -0
  5. package/dist/abstractions/FlatList.js +1 -0
  6. package/dist/abstractions/FlatList.native.js +1 -0
  7. package/dist/abstractions/FlatList.web.js +1 -0
  8. package/dist/abstractions/ScrollView.web.js +1 -0
  9. package/dist/abstractions/helpers/storage.js +1 -0
  10. package/dist/abstractions/helpers/storage.native.js +1 -0
  11. package/dist/components/actions/Button.js +1 -1
  12. package/dist/components/actions/Dropdown.js +1 -1
  13. package/dist/components/actions/menu/VerticalMenu.js +1 -1
  14. package/dist/components/index.js +1 -1
  15. package/dist/components/layout/Layout.js +1 -1
  16. package/dist/components/list/FlatList.js +1 -0
  17. package/dist/components/list/index.js +1 -1
  18. package/dist/components/state/LoadingView.js +1 -1
  19. package/dist/components/structure/View.js +1 -1
  20. package/dist/components/structure/bottomDrawer/native/BottomDrawer.js +1 -1
  21. package/dist/components/structure/popover/Popover.js +1 -1
  22. package/dist/components/structure/popover/Popover.native.js +1 -1
  23. package/dist/components/theme/ThemePicker.js +1 -0
  24. package/dist/components/theme/ThemePickerDrawer.js +1 -0
  25. package/dist/components/theme/ThemeStatusBar.js +1 -0
  26. package/dist/components/theme/ThemeStatusBar.native.js +1 -0
  27. package/dist/components/theme/ThemeThumb.js +1 -0
  28. package/dist/components/theme/index.js +1 -0
  29. package/dist/helpers/index.js +1 -1
  30. package/dist/helpers/storage.js +1 -0
  31. package/dist/modifiers/fullColor.js +1 -1
  32. package/dist/theme/ThemeHandler.js +1 -1
  33. package/dist/theme/default/base.js +1 -1
  34. package/dist/theme/default/blackTheme.js +1 -1
  35. package/dist/theme/default/cyberpunkTheme.js +1 -1
  36. package/dist/theme/default/darkTheme.js +1 -1
  37. package/dist/theme/default/deepWoodsTheme.js +1 -1
  38. package/dist/theme/default/forestTheme.js +1 -1
  39. package/dist/theme/default/hackerTheme.js +1 -1
  40. package/dist/theme/default/lightTheme.js +1 -1
  41. package/dist/theme/default/midnightTheme.js +1 -1
  42. package/dist/theme/default/msdosTheme.js +1 -1
  43. package/dist/theme/default/oceanTheme.js +1 -1
  44. package/dist/theme/default/paperTheme.js +1 -0
  45. package/dist/theme/default/pastelTheme.js +1 -1
  46. package/dist/theme/default/sunsetTheme.js +1 -1
  47. package/dist/theme/default/themes.js +1 -1
  48. package/dist/theme/format/formatTheme.js +1 -1
  49. package/dist/theme/helpers/contrastColor.js +1 -1
  50. package/package.json +1 -1
  51. package/src/NekoUI.js +13 -1
  52. package/src/abstractions/ActivityIndicator.native.js +3 -4
  53. package/src/abstractions/ActivityIndicator.web.js +43 -0
  54. package/src/abstractions/BlurView.web.js +39 -0
  55. package/src/abstractions/FlatList.js +39 -0
  56. package/src/abstractions/FlatList.native.js +32 -0
  57. package/src/abstractions/FlatList.web.js +3 -0
  58. package/src/abstractions/ScrollView.web.js +3 -0
  59. package/src/abstractions/Text.web.js +15 -0
  60. package/src/abstractions/helpers/storage.js +32 -0
  61. package/src/abstractions/helpers/storage.native.js +34 -0
  62. package/src/components/actions/Button.js +1 -0
  63. package/src/components/actions/Dropdown.js +17 -2
  64. package/src/components/actions/menu/VerticalMenu.js +1 -1
  65. package/src/components/index.js +1 -0
  66. package/src/components/layout/Layout.js +1 -1
  67. package/src/components/list/FlatList.js +54 -0
  68. package/src/components/list/index.js +1 -0
  69. package/src/components/state/LoadingView.js +10 -1
  70. package/src/components/structure/View.js +2 -0
  71. package/src/components/structure/bottomDrawer/native/BottomDrawer.js +15 -2
  72. package/src/components/structure/popover/Popover.js +11 -2
  73. package/src/components/structure/popover/Popover.native.js +3 -2
  74. package/src/components/theme/ThemePicker.js +49 -0
  75. package/src/components/theme/ThemePickerDrawer.js +13 -0
  76. package/src/components/theme/ThemeStatusBar.js +3 -0
  77. package/src/components/theme/ThemeStatusBar.native.js +9 -0
  78. package/src/components/theme/ThemeThumb.js +98 -0
  79. package/src/components/theme/index.js +3 -0
  80. package/src/helpers/index.js +1 -0
  81. package/src/helpers/storage.js +54 -0
  82. package/src/modifiers/fullColor.js +2 -2
  83. package/src/theme/ThemeHandler.js +18 -2
  84. package/src/theme/default/base.js +6 -6
  85. package/src/theme/default/blackTheme.js +4 -1
  86. package/src/theme/default/cyberpunkTheme.js +3 -1
  87. package/src/theme/default/darkTheme.js +3 -1
  88. package/src/theme/default/deepWoodsTheme.js +4 -2
  89. package/src/theme/default/forestTheme.js +3 -1
  90. package/src/theme/default/hackerTheme.js +3 -1
  91. package/src/theme/default/lightTheme.js +3 -1
  92. package/src/theme/default/midnightTheme.js +3 -1
  93. package/src/theme/default/msdosTheme.js +18 -4
  94. package/src/theme/default/oceanTheme.js +4 -2
  95. package/src/theme/default/paperTheme.js +35 -0
  96. package/src/theme/default/pastelTheme.js +3 -1
  97. package/src/theme/default/sunsetTheme.js +5 -3
  98. package/src/theme/default/themes.js +7 -10
  99. package/src/theme/format/formatTheme.js +9 -3
  100. package/src/theme/helpers/contrastColor.js +49 -11
  101. package/dist/abstractions/TouchableOpacity.web.js +0 -1
  102. package/src/abstractions/TouchableOpacity.web.js +0 -3
@@ -0,0 +1,54 @@
1
+ import React from 'react'
2
+
3
+ import { AbsStorage } from '../abstractions/helpers/storage'
4
+
5
+ function set(key, value) {
6
+ return AbsStorage.set(key, JSON.stringify(value))
7
+ }
8
+
9
+ function setAsync(key, value) {
10
+ return AbsStorage.setAsync(key, JSON.stringify(value))
11
+ }
12
+
13
+ function get(key) {
14
+ const value = AbsStorage.get(key)
15
+ return formatStoragedValue(value)
16
+ }
17
+
18
+ function getAsync(key) {
19
+ return AbsStorage.setAsync(key).then((value) => {
20
+ return formatStoragedValue(value)
21
+ })
22
+ }
23
+
24
+ function formatStoragedValue(value) {
25
+ try {
26
+ if (!value) return value
27
+ value = JSON.parse(value)
28
+ if (value === 'undefined') return undefined
29
+ if (value === 'null') return undefined
30
+ return value
31
+ } catch (e) {
32
+ return value
33
+ }
34
+ }
35
+
36
+ function useState(key, defaultValue) {
37
+ const [value, setValue] = React.useState(get(key) || defaultValue)
38
+
39
+ const handleChange = (newValue) => {
40
+ set(key, newValue)
41
+ setValue(newValue)
42
+ }
43
+
44
+ return [value, handleChange]
45
+ }
46
+
47
+ export const Storage = {
48
+ ...AbsStorage,
49
+ set,
50
+ setAsync,
51
+ get,
52
+ getAsync,
53
+ useState,
54
+ }
@@ -3,7 +3,7 @@ import tinycolor from 'tinycolor2'
3
3
  import { getContrastColor } from '../theme/helpers/contrastColor'
4
4
  import { useGetColor } from '../theme/ThemeHandler'
5
5
 
6
- export function useFullColorModifier([{ color, ...values }, { outline, fill, ...props }]) {
6
+ export function useFullColorModifier([{ color, ...values }, { outline, contrastTolerance, fill, ...props }]) {
7
7
  const getColor = useGetColor()
8
8
 
9
9
  let bg = color
@@ -15,7 +15,7 @@ export function useFullColorModifier([{ color, ...values }, { outline, fill, ...
15
15
  bg = 'transparent'
16
16
  fontColor = color
17
17
  } else {
18
- fontColor = getContrastColor(bgObj, [getColor('text'), getColor('overlayBG')])
18
+ fontColor = getContrastColor(bgObj, [getColor('overlayBG'), getColor('text')], contrastTolerance)
19
19
  }
20
20
 
21
21
  return [
@@ -53,10 +53,26 @@ export function useMergeThemeComponent(name, props) {
53
53
  return mergeDeepRight(themeProps, props)
54
54
  }
55
55
 
56
- export function ThemeHandler({ breakpoints, themes, initTheme, children }) {
56
+ export function ThemeHandler({ breakpoints, themes, initTheme, onChangeTheme, children }) {
57
+ const [themePickerOpen, setThemePickerOpen] = React.useState(false)
58
+ const openThemePicker = () => setThemePickerOpen(true)
57
59
  const [activeThemeKey, setActiveThemeKey] = React.useState(initTheme || 'light')
60
+ const toggleTheme = () => setActiveThemeKey(activeThemeKey === 'light' ? 'dark' : 'light')
58
61
  const theme = useFormattedTheme(themes, activeThemeKey)
59
- const value = { theme, themes, activeThemeKey, setActiveThemeKey, breakpoints: breakpoints || DEFAULT_BREAKPOINTS }
62
+
63
+ const value = {
64
+ theme,
65
+ themes,
66
+ activeThemeKey,
67
+ setActiveThemeKey,
68
+ toggleTheme,
69
+ themePickerOpen,
70
+ setThemePickerOpen,
71
+ onChangeTheme,
72
+ openThemePicker,
73
+ toggleTheme,
74
+ breakpoints: breakpoints || DEFAULT_BREAKPOINTS,
75
+ }
60
76
 
61
77
  return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
62
78
  }
@@ -46,27 +46,27 @@ export const BASE_THEME = {
46
46
 
47
47
  texts: {
48
48
  h1: {
49
- fontSize: 32,
49
+ fontSize: 35,
50
50
  strong: true,
51
51
  },
52
52
  h2: {
53
- fontSize: 26,
53
+ fontSize: 28,
54
54
  strong: true,
55
55
  },
56
56
  h3: {
57
- fontSize: 22,
57
+ fontSize: 26,
58
58
  strong: true,
59
59
  },
60
60
  h4: {
61
- fontSize: 18,
61
+ fontSize: 22,
62
62
  strong: true,
63
63
  },
64
64
  h5: {
65
- fontSize: 16,
65
+ fontSize: 18,
66
66
  strong: true,
67
67
  },
68
68
  h6: {
69
- fontSize: 14,
69
+ fontSize: 16,
70
70
  strong: true,
71
71
  },
72
72
  p: { fontSize: 14 },
@@ -1,7 +1,10 @@
1
1
  import { mergeDeepRight } from 'ramda'
2
+
2
3
  import { BASE_THEME } from './base'
3
4
 
4
5
  export const DEFAULT_BLACK_THEME = mergeDeepRight(BASE_THEME, {
6
+ label: 'Pitch Black',
7
+
5
8
  colors: {
6
9
  primary: '#818DF9',
7
10
  text: '#FFFFFF',
@@ -9,7 +12,7 @@ export const DEFAULT_BLACK_THEME = mergeDeepRight(BASE_THEME, {
9
12
  text3: '#B0B0B0',
10
13
  text4: '#8A8A8A',
11
14
 
12
- bg: '#0f0f0f',
15
+ mainBG: '#0f0f0f',
13
16
  overlayBG: '#000000',
14
17
  backdrop: '#1f1f1f',
15
18
  shadow: 'rgba(216, 210, 203, 0.1)',
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const CYBERPUNK_DARK_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Cyberpunk',
6
+
5
7
  colors: {
6
8
  primary: '#FCEE09',
7
9
  text: '#FFFFFF',
@@ -9,7 +11,7 @@ export const CYBERPUNK_DARK_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#8C8C8C',
10
12
  text4: '#666666',
11
13
 
12
- bg: '#0A0A0F',
14
+ mainBG: '#14141F',
13
15
  overlayBG: '#14141F',
14
16
  backdrop: '#0A0A0F',
15
17
  shadow: 'rgba(39, 45, 52, 0.6)',
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const DEFAULT_DARK_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Dark',
6
+
5
7
  colors: {
6
8
  primary: '#818DF9',
7
9
  text: '#FFFFFF',
@@ -9,7 +11,7 @@ export const DEFAULT_DARK_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#B0B0B0',
10
12
  text4: '#8A8A8A',
11
13
 
12
- bg: '#383E44',
14
+ mainBG: '#383E44',
13
15
  overlayBG: '#272D34',
14
16
  backdrop: '#383E44',
15
17
  shadow: 'rgba(216, 210, 203, 0.1)',
@@ -2,14 +2,16 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const DEEP_WOODS_DARK_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Deep Woods',
6
+
5
7
  colors: {
6
8
  primary: '#4CAF50',
7
- text: '#F0F8F2',
9
+ text: '#C8E6C9',
8
10
  text2: '#C8E6C9',
9
11
  text3: '#A5D6A7',
10
12
  text4: '#81C784',
11
13
 
12
- bg: '#0D1B14',
14
+ mainBG: '#0D1B14',
13
15
  overlayBG: '#16281F',
14
16
  backdrop: '#0D1B14',
15
17
  shadow: 'rgba(39, 45, 52, 0.6)',
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const FOREST_MIST_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Forest Mist',
6
+
5
7
  colors: {
6
8
  primary: '#4CAF50',
7
9
  text: '#0B2414',
@@ -9,7 +11,7 @@ export const FOREST_MIST_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#1B5E20',
10
12
  text4: '#388E3C',
11
13
 
12
- bg: '#E9F5EC',
14
+ mainBG: '#E9F5EC',
13
15
  overlayBG: '#FFFFFF',
14
16
  backdrop: '#E9F5EC',
15
17
  shadow: 'rgba(39, 45, 52, 0.15)',
@@ -3,6 +3,8 @@ import { mergeDeepRight } from 'ramda'
3
3
  import { BASE_THEME } from './base'
4
4
 
5
5
  export const DEFAULT_MATRIX_THEME = mergeDeepRight(BASE_THEME, {
6
+ label: 'Hacker',
7
+
6
8
  colors: {
7
9
  primary: '#00FF41',
8
10
  text: '#00FF41',
@@ -10,7 +12,7 @@ export const DEFAULT_MATRIX_THEME = mergeDeepRight(BASE_THEME, {
10
12
  text3: '#009926',
11
13
  text4: '#00661A',
12
14
 
13
- bg: '#000000',
15
+ mainBG: '#000000',
14
16
  overlayBG: '#0A0A0A',
15
17
  backdrop: '#000000',
16
18
  shadow: 'rgba(0, 255, 65, 0.2)',
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const DEFAULT_LIGHT_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Light',
6
+
5
7
  colors: {
6
8
  primary: '#818DF9',
7
9
  text: '#272D34',
@@ -9,7 +11,7 @@ export const DEFAULT_LIGHT_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#6E7680',
10
12
  text4: '#9AA1AC',
11
13
 
12
- bg: '#F4F5FE',
14
+ mainBG: '#F4F5FE',
13
15
  overlayBG: '#FFFFFF',
14
16
  backdrop: '#383E44',
15
17
  shadow: 'rgba(39, 45, 52, 0.15)',
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const MIDNIGHT_NEON_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Midnight',
6
+
5
7
  colors: {
6
8
  primary: '#FF00FF',
7
9
  text: '#F0F0F0',
@@ -9,7 +11,7 @@ export const MIDNIGHT_NEON_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#A3A3A3',
10
12
  text4: '#7A7A7A',
11
13
 
12
- bg: '#0D0D0D',
14
+ mainBG: '#0D0D0D',
13
15
  overlayBG: '#1A1A1A',
14
16
  backdrop: '#0D0D0D',
15
17
  shadow: 'rgba(39, 45, 52, 0.6)',
@@ -3,14 +3,16 @@ import { mergeDeepRight } from 'ramda'
3
3
  import { BASE_THEME } from './base'
4
4
 
5
5
  export const DEFAULT_MSDOS_THEME = mergeDeepRight(BASE_THEME, {
6
+ label: 'MSDOS',
7
+
6
8
  colors: {
7
9
  primary: '#FFFF00',
8
10
  text: '#FFFFFF',
9
- text2: '#FFD700',
10
- text3: '#CCCCCC',
11
- text4: '#999999',
11
+ text2: '#E0E0E0',
12
+ text3: '#B0B0B0',
13
+ text4: '#8A8A8A',
12
14
 
13
- bg: '#0000AA',
15
+ mainBG: '#0000AA',
14
16
  overlayBG: '#000088',
15
17
  backdrop: '#0000AA',
16
18
  shadow: 'rgba(0, 0, 0, 0.6)',
@@ -31,6 +33,18 @@ export const DEFAULT_MSDOS_THEME = mergeDeepRight(BASE_THEME, {
31
33
  pink: '#FF69B4',
32
34
  },
33
35
 
36
+ radius: {
37
+ xxxs: 1,
38
+ xxs: 2,
39
+ xs: 3,
40
+ sm: 4,
41
+ md: 6,
42
+ lg: 8,
43
+ xl: 10,
44
+ xxl: 12,
45
+ xxxl: 14,
46
+ },
47
+
34
48
  components: {
35
49
  Card: {
36
50
  border: 1,
@@ -2,14 +2,16 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const OCEAN_BREEZE_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Ocean Breeze',
6
+
5
7
  colors: {
6
8
  primary: '#2B90D9',
7
- text: '#04364A',
9
+ text: '#065277',
8
10
  text2: '#065A82',
9
11
  text3: '#0B84B4',
10
12
  text4: '#3ABEFF',
11
13
 
12
- bg: '#E6F7FF',
14
+ mainBG: '#E6F7FF',
13
15
  overlayBG: '#FFFFFF',
14
16
  backdrop: '#04364A',
15
17
  shadow: 'rgba(39, 45, 52, 0.15)',
@@ -0,0 +1,35 @@
1
+ import { mergeDeepRight } from 'ramda'
2
+
3
+ import { BASE_THEME } from './base'
4
+
5
+ export const DEFAULT_PAPER_THEME = mergeDeepRight(BASE_THEME, {
6
+ label: 'Paper',
7
+
8
+ colors: {
9
+ primary: '#5A5A5A',
10
+ text: '#000000',
11
+ text2: '#333333',
12
+ text3: '#555555',
13
+ text4: '#777777',
14
+
15
+ mainBG: '#F8F1E3',
16
+ overlayBG: '#F8F1E3',
17
+ backdrop: '#383E44',
18
+ shadow: 'rgba(0, 0, 0, 0.04)',
19
+ divider: '#E3D9C9',
20
+
21
+ blue: '#6B8EAE',
22
+ yellow: '#EADCA6',
23
+ green: '#88A288',
24
+ purple: '#A391B8',
25
+ orange: '#D9A066',
26
+ cyan: '#9CC9C2',
27
+ red: '#B85C5C',
28
+ navy: '#4A4A4A',
29
+ indigo: '#70788C',
30
+ gray: '#B8B8B8',
31
+ brown: '#8B7355',
32
+ lylac: '#C7B7D4',
33
+ pink: '#E4A1B2',
34
+ },
35
+ })
@@ -2,6 +2,8 @@ import { mergeDeepRight } from 'ramda'
2
2
  import { BASE_THEME } from './base'
3
3
 
4
4
  export const PASTEL_DREAM_THEME = mergeDeepRight(BASE_THEME, {
5
+ label: 'Pastel Dream',
6
+
5
7
  colors: {
6
8
  primary: '#FFB6C1',
7
9
  text: '#4B4453',
@@ -9,7 +11,7 @@ export const PASTEL_DREAM_THEME = mergeDeepRight(BASE_THEME, {
9
11
  text3: '#A093A6',
10
12
  text4: '#C9BBCF',
11
13
 
12
- bg: '#FFF7FA',
14
+ mainBG: '#FFF7FA',
13
15
  overlayBG: '#FFFFFF',
14
16
  backdrop: '#4B4453',
15
17
  shadow: 'rgba(39, 45, 52, 0.15)',
@@ -3,15 +3,17 @@ import { mergeDeepRight } from 'ramda'
3
3
  import { BASE_THEME } from './base'
4
4
 
5
5
  export const SUNSET_GLOW_THEME = mergeDeepRight(BASE_THEME, {
6
+ label: 'Sunset',
7
+
6
8
  colors: {
7
9
  primary: '#FF6B6B',
8
- text: '#331E0A',
10
+ text: '#4B372E',
9
11
  text2: '#5C4033',
10
12
  text3: '#8C5A43',
11
13
  text4: '#B97A57',
12
14
 
13
- bg: '#FFF5E6',
14
- overlayBG: '#FFFFFF',
15
+ mainBG: '#FFF5E6',
16
+ overlayBG: '#FFFAF1',
15
17
  backdrop: '#331E0A',
16
18
  shadow: 'rgba(39, 45, 52, 0.15)',
17
19
  divider: '#f0f0f0',
@@ -1,27 +1,24 @@
1
1
  import { CYBERPUNK_DARK_THEME } from './cyberpunkTheme'
2
- import { DEEP_WOODS_DARK_THEME } from './deepWoodsTheme'
3
2
  import { DEFAULT_BLACK_THEME } from './blackTheme'
4
3
  import { DEFAULT_DARK_THEME } from './darkTheme'
5
4
  import { DEFAULT_LIGHT_THEME } from './lightTheme'
6
5
  import { DEFAULT_MATRIX_THEME } from './hackerTheme'
7
6
  import { DEFAULT_MSDOS_THEME } from './msdosTheme'
8
- import { FOREST_MIST_THEME } from './forestTheme'
7
+ import { DEFAULT_PAPER_THEME } from './paperTheme'
9
8
  import { MIDNIGHT_NEON_THEME } from './midnightTheme'
10
- import { OCEAN_BREEZE_THEME } from './oceanTheme'
11
- import { PASTEL_DREAM_THEME } from './pastelTheme'
12
- import { SUNSET_GLOW_THEME } from './sunsetTheme'
13
9
 
14
10
  export const DEFAULT_THEMES = {
15
11
  light: DEFAULT_LIGHT_THEME,
16
12
  dark: DEFAULT_DARK_THEME,
13
+ paper: DEFAULT_PAPER_THEME,
17
14
  black: DEFAULT_BLACK_THEME,
18
- pastel: PASTEL_DREAM_THEME,
15
+ // pastel: PASTEL_DREAM_THEME,
19
16
  midnight: MIDNIGHT_NEON_THEME,
20
- sunset: SUNSET_GLOW_THEME,
21
- ocean: OCEAN_BREEZE_THEME,
22
- forest: FOREST_MIST_THEME,
17
+ // sunset: SUNSET_GLOW_THEME,
18
+ // ocean: OCEAN_BREEZE_THEME,
19
+ // forest: FOREST_MIST_THEME,
23
20
  cyberpunk: CYBERPUNK_DARK_THEME,
24
- deepWoods: DEEP_WOODS_DARK_THEME,
21
+ // deepWoods: DEEP_WOODS_DARK_THEME,
25
22
  hacker: DEFAULT_MATRIX_THEME,
26
23
  msdos: DEFAULT_MSDOS_THEME,
27
24
  }
@@ -1,5 +1,6 @@
1
- import { mergeDeepRight, pipe } from 'ramda'
1
+ import { mergeDeepRight, mergeDeepLeft, pipe } from 'ramda'
2
2
  import React from 'react'
3
+ import tinycolor from 'tinycolor2'
3
4
 
4
5
  import { DEFAULT_LIGHT_THEME } from '../default/lightTheme'
5
6
  import { DEFAULT_THEMES } from '../default/themes'
@@ -15,8 +16,13 @@ export function formatTheme(themes, key) {
15
16
  const theme = themes[key] || DEFAULT_THEMES[key] || DEFAULT_LIGHT_THEME
16
17
  const baseDefaultTheme = DEFAULT_THEMES[theme.base] || DEFAULT_THEMES[key] || DEFAULT_LIGHT_THEME
17
18
 
18
- return pipe(
19
+ const formattedTheme = pipe(
19
20
  mergeDeepRight(baseDefaultTheme), //
20
- applyColorVariantsOnTheme
21
+ applyColorVariantsOnTheme,
22
+ mergeDeepLeft(themes._all || {}) //
21
23
  )({ ...theme })
24
+
25
+ const isDark = tinycolor(formattedTheme?.colors?.overlayBG || formattedTheme?.colors?.bg).isDark()
26
+
27
+ return { ...formattedTheme, isDark, isLight: !isDark }
22
28
  }
@@ -3,18 +3,56 @@ import tinycolor from 'tinycolor2'
3
3
  export function getContrastColor(bg, options = ['#FFFFFF', '#666666'], tolerance = 2.5) {
4
4
  if (!options.length) return '#666666'
5
5
 
6
- return tinycolor.mostReadable(bg, options).toHexString()
6
+ const contrasts = options.map((color) => ({
7
+ color,
8
+ contrast: tinycolor.readability(bg, color),
9
+ }))
7
10
 
8
- // const contrasts = options.map((color) => ({
9
- // color,
10
- // contrast: tinycolor.readability(bg, color),
11
- // }))
11
+ contrasts.sort((a, b) => b.contrast - a.contrast)
12
12
 
13
- // contrasts.sort((a, b) => b.contrast - a.contrast)
13
+ if (contrasts.length > 1 && Math.abs(contrasts[0].contrast - contrasts[1].contrast) < tolerance) {
14
+ return options[0]
15
+ }
14
16
 
15
- // if (contrasts.length > 1 && Math.abs(contrasts[0].contrast - contrasts[1].contrast) < tolerance) {
16
- // return options[0]
17
- // }
18
-
19
- // return contrasts[0].color
17
+ return contrasts[0].color
20
18
  }
19
+
20
+ // export function getContrastColor(bg, options = ['#FFFFFF', '#666666'], tolerance = 2.5) {
21
+ // if (!options.length) return '#666666'
22
+
23
+ // return tinycolor.mostReadable(bg, options).toHexString()
24
+ // }
25
+
26
+ // export function getContrastColor(bg, options = ['#FFFFFF', '#666666'], tolerance = 2.5) {
27
+ // const background = tinycolor(bg)
28
+
29
+ // function scoreColor(color) {
30
+ // const c = tinycolor(color)
31
+ // const contrast = tinycolor.readability(background, c)
32
+ // const { h: bh, s: bs, l: bl } = background.toHsl()
33
+ // const { h, s, l } = c.toHsl()
34
+
35
+ // const hueDiff = Math.abs(bh - h)
36
+ // const harmony = hueDiff > 180 ? 360 - hueDiff : hueDiff
37
+
38
+ // return (
39
+ // (contrast > tolerance ? contrast * 2 : contrast) +
40
+ // (100 - harmony) / 10 +
41
+ // (s > 0.1 && s < 0.8 ? 2 : 0) +
42
+ // (l > 0.2 && l < 0.8 ? 1 : 0)
43
+ // )
44
+ // }
45
+
46
+ // let bestColor = options[0]
47
+ // let bestScore = scoreColor(bestColor)
48
+
49
+ // for (let i = 1; i < options.length; i++) {
50
+ // const score = scoreColor(options[i])
51
+ // if (score > bestScore) {
52
+ // bestColor = options[i]
53
+ // bestScore = score
54
+ // }
55
+ // }
56
+
57
+ // return bestColor
58
+ // }
@@ -1 +0,0 @@
1
- import{TouchableOpacity as RNTouchableOpacity}from"react-native-web";export var AbsTouchableOpacity=RNTouchableOpacity;
@@ -1,3 +0,0 @@
1
- import { TouchableOpacity as RNTouchableOpacity } from 'react-native'
2
-
3
- export const AbsTouchableOpacity = RNTouchableOpacity