CustomizeThemeOptions.jsx 3.5 KB

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