itizawa 6 лет назад
Родитель
Сommit
fedbb7e463

+ 22 - 22
src/client/js/components/Admin/Customize/CustomizeLayoutOption.jsx

@@ -1,34 +1,28 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
-import CustomizeGrowiLayout from './layout/CustomizeGrowiLayout';
-import CustomizeKibelaLayout from './layout/CustomizeKibelaLayout';
-import CustomizeCrowiLayout from './layout/CustomizeCrowiLayout';
 
 
 class CustomizeLayoutOption extends React.Component {
 class CustomizeLayoutOption extends React.Component {
 
 
-  constructor(props) {
-    super(props);
-    this.state = {
-      // TODO GW-477 save setting at customizeContainer
-      currentLayout: 'growi',
-    };
-
-    this.onChangeLayout = this.onChangeLayout.bind(this);
-  }
-
-  onChangeLayout(lauoutName) {
-    this.setState({ currentLayout: lauoutName });
-  }
-
   render() {
   render() {
 
 
     return (
     return (
-      <React.Fragment>
-        <CustomizeGrowiLayout currentLayout={this.state.currentLayout} onChangeLayout={this.onChangeLayout} />
-        <CustomizeKibelaLayout currentLayout={this.state.currentLayout} onChangeLayout={this.onChangeLayout} />
-        <CustomizeCrowiLayout currentLayout={this.state.currentLayout} onChangeLayout={this.onChangeLayout} />
-      </React.Fragment>
+      <div className="col-sm-4">
+        <h4>
+          <div className="radio radio-primary">
+            <input type="radio" id={`radio-layout-${this.props.layoutType}`} checked={this.props.isSelected} onChange={this.props.onSelected} />
+            <label htmlFor={`radio-layout-${this.props.layoutType}`}>
+              {/* eslint-disable-next-line react/no-danger */}
+              <span dangerouslySetInnerHTML={{ __html: this.props.labelHtml }} />
+            </label>
+          </div>
+        </h4>
+        <a href={`/images/admin/customize/layout-${this.props.layoutType}.gif`} className="ss-container">
+          <img src={`/images/admin/customize/layout-${this.props.layoutType}-thumb.gif`} width="240px" />
+        </a>
+        {/* render layout description */}
+        {this.props.children}
+      </div>
     );
     );
   }
   }
 
 
@@ -36,6 +30,12 @@ class CustomizeLayoutOption extends React.Component {
 
 
 CustomizeLayoutOption.propTypes = {
 CustomizeLayoutOption.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   t: PropTypes.func.isRequired, // i18next
+
+  layoutType: PropTypes.string.isRequired,
+  labelHtml: PropTypes.string.isRequired,
+  isSelected: PropTypes.bool.isRequired,
+  onSelected: PropTypes.func.isRequired,
+  children: PropTypes.func.isRequired,
 };
 };
 
 
 export default withTranslation()(CustomizeLayoutOption);
 export default withTranslation()(CustomizeLayoutOption);

+ 80 - 0
src/client/js/components/Admin/Customize/CustomizeLayoutOptions.jsx

@@ -0,0 +1,80 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { withTranslation } from 'react-i18next';
+import CustomizeLayoutOption from './CustomizeLayoutOption';
+
+class CustomizeLayoutOptions extends React.Component {
+
+  constructor(props) {
+    super(props);
+    this.state = {
+      // TODO GW-477 save setting at customizeContainer
+      currentLayout: 'growi',
+    };
+
+    this.selectLayout = this.selectLayout.bind(this);
+  }
+
+  selectLayout(lauoutName) {
+    this.setState({ currentLayout: lauoutName });
+  }
+
+  render() {
+    return (
+      <React.Fragment>
+        <CustomizeLayoutOption
+          layoutType="crowi-plus"
+          isSelected={this.state.currentLayout === 'growi'}
+          onSelected={() => this.selectLayout('growi')}
+          labelHtml={'GROWI Enhanced Layout <small className="text-success">(Recommended)</small>'}
+        >
+          {/* TODO i18n */}
+          <h4>Simple and Clear</h4>
+          <ul>
+            <li>Full screen layout and thin margins/paddings</li>
+            <li>Show and post comments at the bottom of the page</li>
+            <li>Affix Table-of-contents</li>
+          </ul>
+        </CustomizeLayoutOption>
+
+        <CustomizeLayoutOption
+          layoutType="kibela"
+          isSelected={this.state.currentLayout === 'kibela'}
+          onSelected={() => this.selectLayout('kibela')}
+          labelHtml=" Kibela Like Layout"
+        >
+          {/* TODO i18n */}
+          <h4>Easy Viewing Structure</h4>
+          <ul>
+            <li>Center aligned contents</li>
+            <li>Show and post comments at the bottom of the page</li>
+            <li>Affix Table-of-contents</li>
+          </ul>
+        </CustomizeLayoutOption>
+
+        <CustomizeLayoutOption
+          layoutType="classic"
+          isSelected={this.state.currentLayout === 'crowi'}
+          onSelected={() => this.selectLayout('crowi')}
+          labelHtml="Crowi Classic Layout"
+        >
+          {/* TODO i18n */}
+          <h4>Separated Functions</h4>
+          <ul>
+            <li>Collapsible Sidebar</li>
+            <li>Show and post comments in Sidebar</li>
+            <li>Collapsible Table-of-contents</li>
+          </ul>
+        </CustomizeLayoutOption>
+      </React.Fragment>
+    );
+  }
+
+}
+
+CustomizeLayoutOptions.propTypes = {
+  t: PropTypes.func.isRequired, // i18next
+
+};
+
+export default withTranslation()(CustomizeLayoutOptions);

+ 2 - 2
src/client/js/components/Admin/Customize/CustomizeLayoutSetting.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import React from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 import { withTranslation } from 'react-i18next';
-import CustomizeLayoutOption from './CustomizeLayoutOption';
+import CustomizeLayoutOptions from './CustomizeLayoutOptions';
 
 
 class CustomizeLayoutSetting extends React.Component {
 class CustomizeLayoutSetting extends React.Component {
 
 
@@ -10,7 +10,7 @@ class CustomizeLayoutSetting extends React.Component {
 
 
     return (
     return (
       <form>
       <form>
-        <CustomizeLayoutOption />
+        <CustomizeLayoutOptions />
         {/* TODO GW-245 create themeForm Component */}
         {/* TODO GW-245 create themeForm Component */}
         <div className="form-group my-3">
         <div className="form-group my-3">
           <div className="col-xs-offset-4 col-xs-5">
           <div className="col-xs-offset-4 col-xs-5">

+ 0 - 41
src/client/js/components/Admin/Customize/layout/CustomizeCrowiLayout.jsx

@@ -1,41 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { withTranslation } from 'react-i18next';
-
-class CustomizeCrowiLayout extends React.Component {
-
-  render() {
-    return (
-      <div className="col-sm-4">
-        <h4>
-          <div className="radio radio-primary">
-            <input type="radio" id="radioLayoutCrowi" checked={this.props.currentLayout === 'crowi'} onChange={() => this.props.onChangeLayout('crowi')} />
-            <label htmlFor="radioLayoutCrowi">
-                Crowi Classic Layout
-            </label>
-          </div>
-        </h4>
-        <a href="/images/admin/customize/layout-classic.gif" className="ss-container">
-          <img src="/images/admin/customize/layout-classic-thumb.gif" width="240px" />
-        </a>
-        <h4>Separated Functions</h4>
-        <ul>
-          {/* TODO i18n */}
-          <li>Collapsible Sidebar</li>
-          <li>Show and post comments in Sidebar</li>
-          <li>Collapsible Table-of-contents</li>
-        </ul>
-      </div>
-    );
-  }
-
-}
-
-CustomizeCrowiLayout.propTypes = {
-  t: PropTypes.func.isRequired, // i18next
-
-  currentLayout: PropTypes.string.isRequired,
-  onChangeLayout: PropTypes.func.isRequired,
-};
-
-export default withTranslation()(CustomizeCrowiLayout);

+ 0 - 41
src/client/js/components/Admin/Customize/layout/CustomizeGrowiLayout.jsx

@@ -1,41 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { withTranslation } from 'react-i18next';
-
-class CustomizeGrowiLayout extends React.Component {
-
-  render() {
-    return (
-      <div className="col-sm-4">
-        <h4>
-          <div className="radio radio-primary">
-            <input type="radio" id="radioLayoutGrowi" checked={this.props.currentLayout === 'growi'} onChange={() => this.props.onChangeLayout('growi')} />
-            <label htmlFor="radioLayoutGrowi">
-              GROWI Enhanced Layout <small className="text-success">(Recommended)</small>
-            </label>
-          </div>
-        </h4>
-        <a href="/images/admin/customize/layout-crowi-plus.gif" className="ss-container">
-          <img src="/images/admin/customize/layout-crowi-plus-thumb.gif" width="240px" />
-        </a>
-        <h4>Simple and Clear</h4>
-        <ul>
-          {/* TODO i18n */}
-          <li>Full screen layout and thin margins/paddings</li>
-          <li>Show and post comments at the bottom of the page</li>
-          <li>Affix Table-of-contents</li>
-        </ul>
-      </div>
-    );
-  }
-
-}
-
-CustomizeGrowiLayout.propTypes = {
-  t: PropTypes.func.isRequired, // i18next
-
-  currentLayout: PropTypes.string.isRequired,
-  onChangeLayout: PropTypes.func.isRequired,
-};
-
-export default withTranslation()(CustomizeGrowiLayout);

+ 0 - 41
src/client/js/components/Admin/Customize/layout/CustomizeKibelaLayout.jsx

@@ -1,41 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { withTranslation } from 'react-i18next';
-
-class CustomizeKibelaLayout extends React.Component {
-
-  render() {
-    return (
-      <div className="col-sm-4">
-        <h4>
-          <div className="radio radio-primary">
-            <input type="radio" id="radioLayoutKibela" checked={this.props.currentLayout === 'kibela'} onChange={() => this.props.onChangeLayout('kibela')} />
-            <label htmlFor="radioLayoutKibela">
-              Kibela Like Layout
-            </label>
-          </div>
-        </h4>
-        <a href="/images/admin/customize/layout-kibela.gif" className="ss-container">
-          <img src="/images/admin/customize/layout-kibela-thumb.gif" width="240px" />
-        </a>
-        <h4>Easy Viewing Structure</h4>
-        <ul>
-          {/* TODO i18n */}
-          <li>Center aligned contents</li>
-          <li>Show and post comments at the bottom of the page</li>
-          <li>Affix Table-of-contents</li>
-        </ul>
-      </div>
-    );
-  }
-
-}
-
-CustomizeKibelaLayout.propTypes = {
-  t: PropTypes.func.isRequired, // i18next
-
-  currentLayout: PropTypes.string.isRequired,
-  onChangeLayout: PropTypes.func.isRequired,
-};
-
-export default withTranslation()(CustomizeKibelaLayout);