CustomizeThemeOptions.jsx 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } 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. /* eslint-enable no-multi-spaces */
  36. return (
  37. <div id="themeOptions" className={`${currentLayout === 'kibela' && 'disabled'}`}>
  38. {/* Light and Dark Themes */}
  39. <div>
  40. <h3>{t('admin:customize_setting.theme_desc.light_and_dark')}</h3>
  41. <div className="d-flex flex-wrap">
  42. {lightNDarkTheme.map((theme) => {
  43. return (
  44. <ThemeColorBox
  45. key={theme.name}
  46. isSelected={currentTheme === theme.name}
  47. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  48. {...theme}
  49. />
  50. );
  51. })}
  52. </div>
  53. </div>
  54. {/* Unique Theme */}
  55. <div className="mt-3">
  56. <h3>{t('admin:customize_setting.theme_desc.unique')}</h3>
  57. <div className="d-flex flex-wrap">
  58. {uniqueTheme.map((theme) => {
  59. return (
  60. <ThemeColorBox
  61. key={theme.name}
  62. isSelected={currentTheme === theme.name}
  63. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  64. {...theme}
  65. />
  66. );
  67. })}
  68. </div>
  69. </div>
  70. </div>
  71. );
  72. }
  73. }
  74. const CustomizeThemeOptionsWrapper = (props) => {
  75. return createSubscribedElement(CustomizeThemeOptions, props, [AppContainer, AdminCustomizeContainer]);
  76. };
  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);