index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { useMemo } from 'react'
  2. const myTheme = {
  3. '--sys-color-1': ['#FFFFFF'],
  4. '--sys-color-2': ['linear-gradient(180deg, #233251 0%, #0B1C3E 100%)'],
  5. '--sys-color-3': ['#F7F8FA'],
  6. '--sys-color-4': ['#1F232B'],
  7. '--sys-color-5': ['rgba(0,0,0,0.05)'],
  8. '--sys-color-6': ['#EAF1FE'],
  9. '--sys-color-7': ['#E5E6EA'],
  10. '--sys-color-8': ['#848E9B'],
  11. '--sys-color-9': ['#2A6FF6'],
  12. '--sys-color-10': ['rgba(0,0,0,0.1)'],
  13. '--sys-color-11': ['#F2F3F5'],
  14. '--text-color-1': ['rgba(31, 35, 43, 1)'],
  15. '--text-color-2': ['rgba(77, 89, 106, 1)'],
  16. '--text-color-3': ['rgba(132, 142, 155, 1)']
  17. }
  18. const changeTheme = theme => {
  19. const nextTheme = theme
  20. Object.keys(nextTheme).forEach(key => {
  21. document.documentElement.style.setProperty(key, nextTheme[key][0])
  22. })
  23. }
  24. changeTheme(myTheme)
  25. const fetchThemeColorKeyValue = () => {
  26. return Object.keys(myTheme ?? {}).map(key => ({
  27. [key]: myTheme?.[key]?.[0] ?? ''
  28. }))
  29. }
  30. const useThemeColorKeyValue = () => {
  31. const kVals = useMemo(() => {
  32. return fetchThemeColorKeyValue()
  33. }, [])
  34. return [kVals]
  35. }
  36. export { useThemeColorKeyValue, fetchThemeColorKeyValue }