CustomizeThemeOptions.jsx 3.7 KB

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