CustomizeThemeOptions.jsx 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. const lightNDarkTheme = [{
  13. name: 'default', bg: '#ffffff', topbar: '#334455', theme: '#112744',
  14. }, {
  15. name: 'mono-blue', bg: '#F7FBFD', topbar: '#00587A', theme: '#00587A',
  16. }];
  17. const uniqueTheme = [{
  18. name: 'nature', bg: '#f9fff3', topbar: '#118050', theme: '#460039',
  19. }, {
  20. name: 'wood', bg: '#fffefb', topbar: '#aaa45f', theme: '#dddebf',
  21. }, {
  22. name: 'island', bg: '#8ecac0', topbar: '#0c2a44', theme: '#cef2ef',
  23. }, {
  24. name: 'christmas', bg: '#fffefb', topbar: '#b3000c', theme: '#017e20',
  25. }, {
  26. name: 'antarctic', bg: '#ffffff', topbar: '#000080', theme: '#99cccc',
  27. }, {
  28. name: 'spring', bg: '#fff5ee', topbar: '#ff69b4', theme: '#ffb6c1',
  29. }, {
  30. name: 'future', bg: '#16282D', topbar: '#011414', theme: '#04B4AE',
  31. }, {
  32. name: 'halloween', bg: '#030003', topbar: '#cc5d1f', theme: '#e9af2b',
  33. }];
  34. return (
  35. <div id="themeOptions" className={`${currentLayout === 'kibela' && 'disabled'}`}>
  36. {/* Light and Dark Themes */}
  37. <div>
  38. <h3>{t('admin:customize_setting.theme_desc.light_and_dark')}</h3>
  39. <div className="d-flex flex-wrap">
  40. {lightNDarkTheme.map((theme) => {
  41. return (
  42. <ThemeColorBox
  43. key={theme.name}
  44. isSelected={currentTheme === theme.name}
  45. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  46. name={theme.name}
  47. bg={theme.bg}
  48. topbar={theme.topbar}
  49. theme={theme.theme}
  50. />
  51. );
  52. })}
  53. </div>
  54. </div>
  55. {/* Unique Theme */}
  56. <div>
  57. <h3>{t('admin:customize_setting.theme_desc.unique')}</h3>
  58. <div className="d-flex flex-wrap">
  59. {uniqueTheme.map((theme) => {
  60. return (
  61. <ThemeColorBox
  62. key={theme.name}
  63. isSelected={currentTheme === theme.name}
  64. onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
  65. name={theme.name}
  66. bg={theme.bg}
  67. topbar={theme.topbar}
  68. theme={theme.theme}
  69. />
  70. );
  71. })}
  72. </div>
  73. </div>
  74. </div>
  75. );
  76. }
  77. }
  78. const CustomizeThemeOptionsWrapper = (props) => {
  79. return createSubscribedElement(CustomizeThemeOptions, props, [AppContainer, AdminCustomizeContainer]);
  80. };
  81. CustomizeThemeOptions.propTypes = {
  82. t: PropTypes.func.isRequired, // i18next
  83. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  84. adminCustomizeContainer: PropTypes.instanceOf(AdminCustomizeContainer).isRequired,
  85. };
  86. export default withTranslation()(CustomizeThemeOptionsWrapper);