CustomizeThemeOptions.jsx 3.9 KB

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