diff --git a/package.json b/package.json index 18fe01d3f21..3655811e148 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "lodash.clone": "3.0.3", "lodash.defaultsdeep": "3.10.0", "lodash.omit": "3.1.0", + "lodash.range": "3.0.1", "minilog": "2.0.8", "node-sass": "3.3.3", "po2icu": "git://github.com/LLK/po2icu.git#develop", diff --git a/src/components/login/login.jsx b/src/components/login/login.jsx index 65860fc65dd..4dac048db03 100644 --- a/src/components/login/login.jsx +++ b/src/components/login/login.jsx @@ -2,8 +2,11 @@ var React = require('react'); var ReactDOM = require('react-dom'); var FormattedMessage = require('react-intl').FormattedMessage; +var log = require('../../lib/log.js'); + var Input = require('../forms/input.jsx'); var Button = require('../forms/button.jsx'); +var Spinner = require('../spinner/spinner.jsx'); require('./login.scss'); @@ -13,12 +16,21 @@ var Login = React.createClass({ onLogIn: React.PropTypes.func, error: React.PropTypes.string }, + getInitialState: function () { + return { + waiting: false + }; + }, handleSubmit: function (event) { event.preventDefault(); + this.setState({waiting: true}); this.props.onLogIn({ 'username': ReactDOM.findDOMNode(this.refs.username).value, 'password': ReactDOM.findDOMNode(this.refs.password).value - }); + }, function (err) { + if (err) log.error(err); + this.setState({waiting: false}); + }.bind(this)); }, render: function () { var error; @@ -40,11 +52,17 @@ var Login = React.createClass({ defaultMessage={'Password'} /> - + {this.state.waiting ? [ + + ] : [ + + ]} + {range(1,13).map(function (id) { + return
; + })} + + ); + } +}); + +module.exports = Spinner; diff --git a/src/components/spinner/spinner.scss b/src/components/spinner/spinner.scss new file mode 100644 index 00000000000..f021901d663 --- /dev/null +++ b/src/components/spinner/spinner.scss @@ -0,0 +1,47 @@ +@import "../../colors"; + +.spinner { + position: relative; + width: 20px; + height: 20px; + + .circle { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + + &:before { + display: block; + animation: circleFadeDelay 1.2s infinite ease-in-out both; + margin: 0 auto; + border-radius: 100%; + background-color: darken($ui-blue, 8%); + width: 15%; + height: 15%; + content: ""; + -webkit-animation: circleFadeDelay 1.2s infinite ease-in-out both; + } + } + + @for $i from 1 through 12 { + $rotation: 30deg * ($i - 1); + $delay: -1.3s + $i * .1; + .circle#{$i} { + transform: rotate($rotation); + -ms-transform: rotate($rotation); + -webkit-transform: rotate($rotation); + } + .circle#{$i}:before { + animation-delay: $delay; + -webkit-animation-delay: $delay; + } + } + +} + +@keyframes circleFadeDelay { + 0%, 39%, 100% { opacity: 0; } + 40% { opacity: 1; } +} diff --git a/src/views/components/components.jsx b/src/views/components/components.jsx index e00415db34c..bf075de8b0a 100644 --- a/src/views/components/components.jsx +++ b/src/views/components/components.jsx @@ -6,6 +6,7 @@ var Box = require('../../components/box/box.jsx'); var Button = require('../../components/forms/button.jsx'); var Carousel = require('../../components/carousel/carousel.jsx'); var Input = require('../../components/forms/input.jsx'); +var Spinner = require('../../components/spinner/spinner.jsx'); require('./components.scss'); @@ -37,6 +38,8 @@ var Components = React.createClass({

{'Nothing!!!'}

+

This is a Spinner

+ ); }