浏览代码

add settings ui

Johannes Zellner 11 年之前
父节点
当前提交
4a2cdf2995
共有 4 个文件被更改,包括 126 次插入 和 35 次删除
  1. 53 5
      src/js/Settings.js
  2. 2 30
      src/scss/index.scss
  3. 48 0
      src/scss/settings.scss
  4. 23 0
      src/scss/spinner.scss

+ 53 - 5
src/js/Settings.js

@@ -1,13 +1,61 @@
 var React = require('react'),
-    ReactDOM = require('react-dom'),
-    classNames = require('classnames');
+    ReactDOM = require('react-dom');
 
 var Settings = React.createClass({
+  getInitialState: function () {
+    return { open: false };
+  },
+  toggleSettings: function () {
+    this.setState({ open: !this.state.open });
+  },
+  hideSettings: function () {
+    if (this.state.open) this.toggleSettings();
+  },
+  saveSettings: function () {
+    if (this.state.open) this.toggleSettings();
+  },
   render: function () {
+    var containerClassName = 'container ' + (this.state.open ? 'open' : '');
+    var settingsClassName = 'settings ' + (this.state.open ? 'open' : '');
+    var actionClassName = 'action ' + (this.state.open ? 'open' : '');
+    var backdropClassName = 'backdrop ' + (this.state.open ? 'open' : '');
+
     return (
-      <div className="settings">
-        <div className="settings-action">
-          <button className="btn btn-default btn-fab" data-toggle="modal" data-target="#modalSettings"><i className="material-icons">settings</i></button>
+      <div className={settingsClassName}>
+        <div className={backdropClassName} onClick={this.hideSettings}></div>
+        <div className={actionClassName}>
+          <button className="btn btn-default" onClick={this.toggleSettings}><i className="material-icons">settings</i></button>
+        </div>
+        <div className={containerClassName}>
+          <div className="row">
+            <div className="col-md-12">
+              <h4>Settings</h4>
+            </div>
+          </div>
+          <div className="row">
+            <form className="form-horizontal">
+              <div className="form-group">
+                <label for="inputTitle" className="col-sm-4 control-label">Title</label>
+                <div className="col-sm-7">
+                  <input type="text" className="form-control" id="inputTitle" placeholder="Title" />
+                </div>
+              </div>
+              <div className="form-group">
+                <label for="inputBackgroundImage" className="col-sm-4 control-label">Background</label>
+                <div className="col-sm-7">
+                  <input type="text" className="form-control" id="inputBackgroundImage" placeholder="url" />
+                </div>
+              </div>
+            </form>
+          </div>
+          <div className="row">
+            <div className="col-md-offset-1 col-md-5">
+              <button className="btn btn-default" onClick={this.hideSettings}>Cancel</button>
+            </div>
+            <div className="col-md-5">
+              <button className="btn btn-success" onClick={this.saveSettings}>Save</button>
+            </div>
+          </div>
         </div>
       </div>
     );

+ 2 - 30
src/scss/index.scss

@@ -29,33 +29,5 @@
     overflow-x: auto;
 }
 
-.settings-action {
-    display: inline-block;
-    position: absolute;
-    top: 20px;
-    right: 20px;
-}
-
-.spinner {
-    background-color: transparent;
-    border: 3px dashed #03a9f4;
-    border-radius: 50%;
-    border-top-color: transparent;
-    border-right-color: transparent;
-    width: 1em;
-    height: 1em;
-    display: inline-block;
-    vertical-align: middle;
-    box-sizing: border-box;
-    animation: spinner-animation 0.65s infinite linear;
-    font-size: 35px;
-}
-
-@keyframes spinner-animation {
-    0% {
-        transform:rotate(0deg)
-    }
-    100% {
-        transform:rotate(360deg)
-    }
-}
+@import 'settings';
+@import 'spinner';

+ 48 - 0
src/scss/settings.scss

@@ -0,0 +1,48 @@
+.settings {
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    top: 0;
+    left: 0;
+    overflow: hidden;
+
+    &.open {
+        z-index: 1000;
+    }
+
+    .action {
+        display: inline-block;
+        position: absolute;
+        top: 20px;
+        right: 20px;
+    }
+
+    .container {
+        position: absolute;
+        top: 0;
+        width: 400px;
+        height: 100%;
+        right: -400px;
+        background-color: white;
+        transition: right 250ms;
+        box-shadow: 0 8px 17px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);
+        z-index: 2000;
+
+        &.open {
+            right: 0;
+        }
+    }
+
+    .backdrop {
+        width: 100%;
+        height: 100%;
+        position: fixed;
+        top: 0;
+        left: 0;
+        transition: background-color 400ms;
+
+        &.open {
+            background-color: rgba(0,0,0,0.3);
+        }
+    }
+}

+ 23 - 0
src/scss/spinner.scss

@@ -0,0 +1,23 @@
+.spinner {
+    background-color: transparent;
+    border: 3px dashed #03a9f4;
+    border-radius: 50%;
+    border-top-color: transparent;
+    border-right-color: transparent;
+    width: 1em;
+    height: 1em;
+    display: inline-block;
+    vertical-align: middle;
+    box-sizing: border-box;
+    animation: spinner-animation 0.65s infinite linear;
+    font-size: 35px;
+}
+
+@keyframes spinner-animation {
+    0% {
+        transform:rotate(0deg)
+    }
+    100% {
+        transform:rotate(360deg)
+    }
+}