CustomizeThemeOptions.jsx 3.6 KB

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