CustomizeThemeOptions.jsx 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. const uniqueTheme = [{
  19. name: 'nature', bg: '#f9fff3', topbar: '#234136', sidebar: '#118050', theme: '#460039',
  20. }, {
  21. name: 'wood', bg: '#fffefb', topbar: '#2a2929', sidebar: '#aaa45f', theme: '#aaa45f',
  22. }, {
  23. name: 'island', bg: '#cef2ef', topbar: '#2a2929', sidebar: '#0c2a44', theme: 'rgba(183, 226, 219, 1)',
  24. }, {
  25. name: 'christmas', bg: '#fffefb', topbar: '#b3000c', sidebar: '#30882c', theme: '#d3c665',
  26. }, {
  27. name: 'antarctic', bg: '#ffffff', topbar: '#2a2929', sidebar: '#000080', theme: '#fa9913',
  28. }, {
  29. name: 'spring', bg: '#ffffff', topbar: '#d3687c', sidebar: '#ffb8c6', theme: '#67a856',
  30. }, {
  31. name: 'future', bg: '#16282d', topbar: '#2a2929', sidebar: '#00b5b7', theme: '#00b5b7',
  32. }, {
  33. name: 'halloween', bg: '#030003', topbar: '#aa4a04', sidebar: '#162b33', theme: '#e9af2b',
  34. }, {
  35. name: 'kibela', bg: '#f4f5f6', topbar: '#1256a3', sidebar: '#5882fa', theme: '#b5cbf79c',
  36. }];
  37. /* eslint-enable no-multi-spaces */
  38. return (
  39. <div id="themeOptions" className={`${currentLayout === 'kibela' && 'disabled'}`}>
  40. {/* Light and Dark Themes */}
  41. <div>
  42. <h3>{t('admin:customize_setting.theme_desc.light_and_dark')}</h3>
  43. <div className="d-flex flex-wrap">
  44. {lightNDarkTheme.map((theme) => {
  45. return (
  46. <ThemeColorBox
  47. key={theme.name}
  48. isSelected={currentTheme === theme.name}
  49. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  50. {...theme}
  51. />
  52. );
  53. })}
  54. </div>
  55. </div>
  56. {/* Unique Theme */}
  57. <div className="mt-3">
  58. <h3>{t('admin:customize_setting.theme_desc.unique')}</h3>
  59. <div className="d-flex flex-wrap">
  60. {uniqueTheme.map((theme) => {
  61. return (
  62. <ThemeColorBox
  63. key={theme.name}
  64. isSelected={currentTheme === theme.name}
  65. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  66. {...theme}
  67. />
  68. );
  69. })}
  70. </div>
  71. </div>
  72. </div>
  73. );
  74. }
  75. }
  76. const CustomizeThemeOptionsWrapper = withUnstatedContainers(CustomizeThemeOptions, [AppContainer, AdminCustomizeContainer]);
  77. CustomizeThemeOptions.propTypes = {
  78. t: PropTypes.func.isRequired, // i18next
  79. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  80. adminCustomizeContainer: PropTypes.instanceOf(AdminCustomizeContainer).isRequired,
  81. };
  82. export default withTranslation()(CustomizeThemeOptionsWrapper);