CustomizeThemeOptions.jsx 3.1 KB

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