CustomizeThemeOptions.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import PropTypes from 'prop-types';
  4. import AdminCustomizeContainer from '~/client/services/AdminCustomizeContainer';
  5. import { GrowiThemes } from '~/interfaces/theme';
  6. import { useGrowiTheme } from '~/stores/context';
  7. import { withUnstatedContainers } from '../../UnstatedUtils';
  8. import ThemeColorBox from './ThemeColorBox';
  9. /* eslint-disable no-multi-spaces */
  10. const lightNDarkTheme = [{
  11. name: GrowiThemes.DEFAULT, bg: '#ffffff', topbar: '#2a2929', sidebar: '#122c55', theme: '#209fd8',
  12. }, {
  13. name: GrowiThemes.MONO_BLUE, bg: '#F7FBFD', topbar: '#2a2929', sidebar: '#00587A', theme: '#00587A',
  14. }, {
  15. name: GrowiThemes.HUFFLEPUFF, bg: '#EFE2CF', topbar: '#2a2929', sidebar: '#EAAB20', theme: '#993439',
  16. }, {
  17. name: GrowiThemes.FIRE_RED, bg: '#FDFDFD', topbar: '#2c2c2c', sidebar: '#BFBFBF', theme: '#EA5532',
  18. }, {
  19. name: GrowiThemes.JADE_GREEN, bg: '#FDFDFD', topbar: '#2c2c2c', sidebar: '#BFBFBF', theme: '#38B48B',
  20. }];
  21. const uniqueTheme = [{
  22. name: GrowiThemes.NATURE, bg: '#f9fff3', topbar: '#234136', sidebar: '#118050', theme: '#460039',
  23. }, {
  24. name: GrowiThemes.WOOD, bg: '#fffefb', topbar: '#2a2929', sidebar: '#aaa45f', theme: '#aaa45f',
  25. }, {
  26. name: GrowiThemes.ISLAND, bg: '#cef2ef', topbar: '#2a2929', sidebar: '#0c2a44', theme: 'rgba(183, 226, 219, 1)',
  27. }, {
  28. name: GrowiThemes.CHRISTMAS, bg: '#fffefb', topbar: '#b3000c', sidebar: '#30882c', theme: '#d3c665',
  29. }, {
  30. name: GrowiThemes.ANTARCTIC, bg: '#ffffff', topbar: '#2a2929', sidebar: '#000080', theme: '#fa9913',
  31. }, {
  32. name: GrowiThemes.SPRING, bg: '#ffffff', topbar: '#d3687c', sidebar: '#ffb8c6', theme: '#67a856',
  33. }, {
  34. name: GrowiThemes.FUTURE, bg: '#16282d', topbar: '#2a2929', sidebar: '#00b5b7', theme: '#00b5b7',
  35. }, {
  36. name: GrowiThemes.HALLOWEEN, bg: '#030003', topbar: '#aa4a04', sidebar: '#162b33', theme: '#e9af2b',
  37. }, {
  38. name: GrowiThemes.KIBELA, bg: '#f4f5f6', topbar: '#1256a3', sidebar: '#5882fa', theme: '#b5cbf79c',
  39. }, {
  40. name: GrowiThemes.BLACKBOARD, bg: '#223729', topbar: '#563E23', sidebar: '#7B5932', theme: '#DA8506',
  41. }];
  42. const CustomizeThemeOptions = (props) => {
  43. const { adminCustomizeContainer } = props;
  44. const { t } = useTranslation();
  45. const { mutate: mutateGrowiTheme } = useGrowiTheme();
  46. const { currentLayout, currentTheme } = adminCustomizeContainer.state;
  47. return (
  48. <div id="themeOptions" className={`${currentLayout === 'kibela' && 'disabled'}`}>
  49. {/* Light and Dark Themes */}
  50. <div>
  51. <h3>{t('admin:customize_setting.theme_desc.light_and_dark')}</h3>
  52. <div className="d-flex flex-wrap">
  53. {lightNDarkTheme.map((theme) => {
  54. return (
  55. <ThemeColorBox
  56. key={theme.name}
  57. isSelected={currentTheme === theme.name}
  58. onSelected={() => mutateGrowiTheme(theme.name)}
  59. {...theme}
  60. />
  61. );
  62. })}
  63. </div>
  64. </div>
  65. {/* Unique Theme */}
  66. <div className="mt-3">
  67. <h3>{t('admin:customize_setting.theme_desc.unique')}</h3>
  68. <div className="d-flex flex-wrap">
  69. {uniqueTheme.map((theme) => {
  70. return (
  71. <ThemeColorBox
  72. key={theme.name}
  73. isSelected={currentTheme === theme.name}
  74. onSelected={() => mutateGrowiTheme(theme.name)}
  75. {...theme}
  76. />
  77. );
  78. })}
  79. </div>
  80. </div>
  81. </div>
  82. );
  83. };
  84. const CustomizeThemeOptionsWrapper = withUnstatedContainers(CustomizeThemeOptions, [AdminCustomizeContainer]);
  85. CustomizeThemeOptions.propTypes = {
  86. adminCustomizeContainer: PropTypes.instanceOf(AdminCustomizeContainer).isRequired,
  87. };
  88. export default CustomizeThemeOptionsWrapper;