From bc922deb23a72d6ca1bf4c39efd1d7366baa9a84 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Tue, 7 Feb 2017 17:39:09 -0200 Subject: [#922] Refactoring react folder structure with @anikarni --- web-ui/.jshintignore | 5 +- web-ui/app/account_recovery.html | 12 -- web-ui/app/js/account_recovery.js | 18 --- web-ui/app/js/account_recovery/i18n.js | 39 ----- web-ui/app/js/account_recovery/page.js | 28 ---- web-ui/app/scss/account_recovery/page.scss | 176 ---------------------- web-ui/config/alias-webpack.js | 1 + web-ui/config/copy-webpack.js | 2 +- web-ui/karma.conf.js | 2 +- web-ui/package.json | 3 +- web-ui/src/account_recovery/account_recovery.html | 12 ++ web-ui/src/account_recovery/account_recovery.js | 18 +++ web-ui/src/account_recovery/page.js | 28 ++++ web-ui/src/account_recovery/page.scss | 176 ++++++++++++++++++++++ web-ui/src/i18n.js | 39 +++++ web-ui/test/jasmine.json | 9 -- web-ui/test/spec/account_recovery/page.spec.js | 12 -- web-ui/test/test-main.js | 2 +- web-ui/test/unit/account_recovery/page.spec.js | 12 ++ web-ui/webpack.config.js | 2 +- web-ui/webpack.production.config.js | 2 +- 21 files changed, 295 insertions(+), 303 deletions(-) delete mode 100644 web-ui/app/account_recovery.html delete mode 100644 web-ui/app/js/account_recovery.js delete mode 100644 web-ui/app/js/account_recovery/i18n.js delete mode 100644 web-ui/app/js/account_recovery/page.js delete mode 100644 web-ui/app/scss/account_recovery/page.scss create mode 100644 web-ui/src/account_recovery/account_recovery.html create mode 100644 web-ui/src/account_recovery/account_recovery.js create mode 100644 web-ui/src/account_recovery/page.js create mode 100644 web-ui/src/account_recovery/page.scss create mode 100644 web-ui/src/i18n.js delete mode 100644 web-ui/test/jasmine.json delete mode 100644 web-ui/test/spec/account_recovery/page.spec.js create mode 100644 web-ui/test/unit/account_recovery/page.spec.js (limited to 'web-ui') diff --git a/web-ui/.jshintignore b/web-ui/.jshintignore index df04d870..b28da15f 100644 --- a/web-ui/.jshintignore +++ b/web-ui/.jshintignore @@ -2,6 +2,5 @@ app/node_modules app/bower_components app/js/lib app/js/generated -app/js/account_recovery.js -app/js/account_recovery -test/spec/account_recovery +src/ +test/unit diff --git a/web-ui/app/account_recovery.html b/web-ui/app/account_recovery.html deleted file mode 100644 index bd451ebc..00000000 --- a/web-ui/app/account_recovery.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Pixelated Account Recovery - - -
- - - diff --git a/web-ui/app/js/account_recovery.js b/web-ui/app/js/account_recovery.js deleted file mode 100644 index cd01378d..00000000 --- a/web-ui/app/js/account_recovery.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react' -import { render } from 'react-dom' -import a11y from 'react-a11y' -import { I18nextProvider } from 'react-i18next' - -import Page from 'js/account_recovery/page' -import i18n from 'js/account_recovery/i18n' - -import 'font-awesome/scss/font-awesome.scss' - -if(process.env.NODE_ENV === 'development') a11y(React); - -render( - - - , - document.getElementById('root') -); diff --git a/web-ui/app/js/account_recovery/i18n.js b/web-ui/app/js/account_recovery/i18n.js deleted file mode 100644 index 9c6ad550..00000000 --- a/web-ui/app/js/account_recovery/i18n.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017 ThoughtWorks, Inc. - * - * Pixelated is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Pixelated is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Pixelated. If not, see . - */ -import i18n from 'i18next' -import i18nBackend from 'i18nextXHRBackend' -import i18nDetector from 'i18nextBrowserLanguageDetector' - -const detector = new i18nDetector(); -const detect = detector.detect.bind(detector); - -detector.detect = function(detectionOrder) { - let result = detect(detectionOrder); - return result.replace('-', '_'); -}; - -i18n - .use(i18nBackend) - .use(detector) - .init({ - fallbackLng: 'en_US', - backend: { - loadPath: 'assets/locales/{{lng}}/{{ns}}.json' - } - }); - -export default i18n; diff --git a/web-ui/app/js/account_recovery/page.js b/web-ui/app/js/account_recovery/page.js deleted file mode 100644 index a94c2c45..00000000 --- a/web-ui/app/js/account_recovery/page.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' -import { translate } from 'react-i18next' - -import 'scss/account_recovery/page.scss' - -export const Page = ({ t }) => ( -
- {t('backup-account.image-description')}/ -
-

{t('backup-account.title')}

-

{t('backup-account.paragraph1')}

-

{t('backup-account.paragraph2')}

-
- - -
- - -
-
-) - -export default translate('', { wait: true })(Page) diff --git a/web-ui/app/scss/account_recovery/page.scss b/web-ui/app/scss/account_recovery/page.scss deleted file mode 100644 index 8bba1b5a..00000000 --- a/web-ui/app/scss/account_recovery/page.scss +++ /dev/null @@ -1,176 +0,0 @@ -@import "../vendor/reset"; -@import "../base/colors"; -@import "../base/fonts"; - -html { - min-height: 100%; -} - -body { - font-family: "Open Sans", "Microsoft YaHei", "Hiragino Sans GB", "Hiragino Sans GB W3", "微软雅黑", "Helvetica Neue", Arial, sans-serif; - background: $dark_blue; /* For browsers that do not support gradients */ - background: -webkit-linear-gradient(left top, $dark_blue, $middle_blue); /* For Safari 5.1 to 6.0 */ - background: -o-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Opera 11.1 to 12.0 */ - background: -moz-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Firefox 3.6 to 15 */ - background: linear-gradient(to bottom right, $dark_blue, $middle_blue); /* Standard syntax */ - color: $dark_grey_text; - min-height: 100%; -} - -h1 { - font-size: 1.3em; - font-weight: 600; -} - -p { - -webkit-margin-before: 0.5em; - -webkit-margin-after: 0.5em; - margin-before: 0.5em; - margin-after: 0.5em; -} - -a { - text-decoration: none; - color: $dark_blue; - font-style: italic; - - .fa { - font-size: 1.6em; - position: relative; - top: 3px; - margin-right: 0.3em; - } - -} - -.field-group { - position:relative; - margin: 1.5em 0; - width: 100%; - - label { - font-size: 0.9em; - margin-bottom: 10px; - display: inline-block; - } - - input { - display: block; - border: none; - border-bottom: solid 1px #4da3b6; - width: 100%; - height: auto; - padding: 0.3em 0px; - } - - input:focus { - outline:none; - border-width: 2px; - } - - input:focus ~ .animated-label, input:valid ~ .animated-label { - top:-12px; - left: 0; - font-size:0.7em; - color:#4da3b6; - } - - .animated-label { - color:#999; - position:absolute; - pointer-events:none; - left: 6px; - top:10px; - transition:0.2s ease all; - -moz-transition:0.2s ease all; - -webkit-transition:0.2s ease all; - } -} - - -button { - background: $dark_blue; - padding: 0.8em; - color: $white; - text-align: center; - border: none; - border-radius: 2px; - font-weight: 300; - width: 100%; - margin-bottom: 1em; -} - -.container { - background: $white; - width: 84%; - margin: 3% auto; - padding: 6% 5%; - - -webkit-display: flex; - display: flex; - -webkit-align-items: flex-start; - align-items: flex-start; - -webkit-flex-direction: column; - flex-direction: column; -} - -img { - width: 50%; - -webkit-align-self: center; - align-self: center; -} - -@media only screen and (min-width : 500px) { - body { - font-size: 1.3em; - } - - form { - display: flex; - -webkit-display: flex; - -webkit-flex-direction: column; - flex-direction: column; - - .field-group, button, div { - width: 70%; - -webkit-align-self: center; - align-self: center; - } - } -} - -@media only screen and (min-width : 960px) { - .container{ - width: 60%; - padding: 3%; - -webkit-align-items: flex-start; - align-items: flex-start; - -webkit-flex-direction: row; - flex-direction: row; - max-width: 700px; - } - - form { - margin-left: 2.5em; - - .field-group, button, div { - width: 300px; - -webkit-align-self: flex-start; - align-self: flex-start; - } - - .field-group { - margin-top: 3em; - font-size: 1em; - } - } - - img { - width: 300px; - } - - button { - font-size: 0.8em; - margin-bottom: 1em; - } -} diff --git a/web-ui/config/alias-webpack.js b/web-ui/config/alias-webpack.js index 43b23836..d316bb2d 100644 --- a/web-ui/config/alias-webpack.js +++ b/web-ui/config/alias-webpack.js @@ -7,6 +7,7 @@ module.exports = { 'flight': path.join(__dirname, '../app/bower_components/flight'), 'found': path.join(__dirname, '../app/bower_components/foundation'), 'js': path.join(__dirname, '../app/js'), + 'src': path.join(__dirname, '../src'), 'scss': path.join(__dirname, '../app/scss'), 'mail_list': path.join(__dirname, '../app/js/mail_list'), 'page': path.join(__dirname, '../app/js/page'), diff --git a/web-ui/config/copy-webpack.js b/web-ui/config/copy-webpack.js index a2567be6..8e9f9dd3 100644 --- a/web-ui/config/copy-webpack.js +++ b/web-ui/config/copy-webpack.js @@ -4,7 +4,7 @@ module.exports = new CopyWebpackPlugin([ { context: 'app/', from: '404.html' }, { context: 'app/', from: 'index.html' }, { context: 'app/', from: 'sandbox.html' }, - { context: 'app/', from: 'account_recovery.html' }, + { context: 'src/account_recovery/', from: 'account_recovery.html' }, { context: 'app/', from: 'css/*' }, { context: 'app/', from: 'fonts/*' }, { context: 'app/', from: 'locales/**/*' }, diff --git a/web-ui/karma.conf.js b/web-ui/karma.conf.js index d10667e9..2895dc42 100644 --- a/web-ui/karma.conf.js +++ b/web-ui/karma.conf.js @@ -68,7 +68,7 @@ module.exports = function (config) { reporters: ['dots', 'junit', 'coverage'], preprocessors: { - 'app/js/!(lib|account_recovery)/**/*.js': ['coverage'] + 'app/js/!(lib)/**/*.js': ['coverage'] }, // enable / disable watching file and executing tests whenever any file changes diff --git a/web-ui/package.json b/web-ui/package.json index ff4201c0..dba34e97 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -65,7 +65,8 @@ }, "scripts": { "test": "npm run jshint --silent && npm run build-statics --silent && npm run mocha-test && npm run karma-test", - "mocha-test": "mocha-webpack --webpack-config webpack.test.config.js \"test/spec/account_recovery/**/*.spec.js\"", + "mocha-test": "mocha-webpack --webpack-config webpack.test.config.js \"test/unit/**/*.spec.js\"", + "mocha-watch": "mocha-webpack --watch --webpack-config webpack.test.config.js \"test/unit/**/*.spec.js\"", "karma-test": "karma start --single-run $GRUNT_OPTS", "debug": "npm run build && karma start --browsers Chrome $GRUNT_OPTS", "watch": "npm run compass-watch & npm run handlebars-watch & npm run build-js-watch", diff --git a/web-ui/src/account_recovery/account_recovery.html b/web-ui/src/account_recovery/account_recovery.html new file mode 100644 index 00000000..bd451ebc --- /dev/null +++ b/web-ui/src/account_recovery/account_recovery.html @@ -0,0 +1,12 @@ + + + + + + Pixelated Account Recovery + + +
+ + + diff --git a/web-ui/src/account_recovery/account_recovery.js b/web-ui/src/account_recovery/account_recovery.js new file mode 100644 index 00000000..f2421bfc --- /dev/null +++ b/web-ui/src/account_recovery/account_recovery.js @@ -0,0 +1,18 @@ +import React from 'react' +import { render } from 'react-dom' +import a11y from 'react-a11y' +import { I18nextProvider } from 'react-i18next' + +import Page from './page' +import i18n from '../i18n' + +import 'font-awesome/scss/font-awesome.scss' + +if(process.env.NODE_ENV === 'development') a11y(React); + +render( + + + , + document.getElementById('root') +); diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js new file mode 100644 index 00000000..a02d307c --- /dev/null +++ b/web-ui/src/account_recovery/page.js @@ -0,0 +1,28 @@ +import React from 'react' +import { translate } from 'react-i18next' + +import './page.scss' + +export const Page = ({ t }) => ( +
+ {t('backup-account.image-description')}/ +
+

{t('backup-account.title')}

+

{t('backup-account.paragraph1')}

+

{t('backup-account.paragraph2')}

+
+ + +
+ + +
+
+) + +export default translate('', { wait: true })(Page) diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss new file mode 100644 index 00000000..e7b1504e --- /dev/null +++ b/web-ui/src/account_recovery/page.scss @@ -0,0 +1,176 @@ +@import "~scss/vendor/reset"; +@import "~scss/base/colors"; +@import "~scss/base/fonts"; + +html { + min-height: 100%; +} + +body { + font-family: "Open Sans", "Microsoft YaHei", "Hiragino Sans GB", "Hiragino Sans GB W3", "微软雅黑", "Helvetica Neue", Arial, sans-serif; + background: $dark_blue; /* For browsers that do not support gradients */ + background: -webkit-linear-gradient(left top, $dark_blue, $middle_blue); /* For Safari 5.1 to 6.0 */ + background: -o-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Opera 11.1 to 12.0 */ + background: -moz-linear-gradient(bottom right, $dark_blue, $middle_blue); /* For Firefox 3.6 to 15 */ + background: linear-gradient(to bottom right, $dark_blue, $middle_blue); /* Standard syntax */ + color: $dark_grey_text; + min-height: 100%; +} + +h1 { + font-size: 1.3em; + font-weight: 600; +} + +p { + -webkit-margin-before: 0.5em; + -webkit-margin-after: 0.5em; + margin-before: 0.5em; + margin-after: 0.5em; +} + +a { + text-decoration: none; + color: $dark_blue; + font-style: italic; + + .fa { + font-size: 1.6em; + position: relative; + top: 3px; + margin-right: 0.3em; + } + +} + +.field-group { + position:relative; + margin: 1.5em 0; + width: 100%; + + label { + font-size: 0.9em; + margin-bottom: 10px; + display: inline-block; + } + + input { + display: block; + border: none; + border-bottom: solid 1px #4da3b6; + width: 100%; + height: auto; + padding: 0.3em 0px; + } + + input:focus { + outline:none; + border-width: 2px; + } + + input:focus ~ .animated-label, input:valid ~ .animated-label { + top:-12px; + left: 0; + font-size:0.7em; + color:#4da3b6; + } + + .animated-label { + color:#999; + position:absolute; + pointer-events:none; + left: 6px; + top:10px; + transition:0.2s ease all; + -moz-transition:0.2s ease all; + -webkit-transition:0.2s ease all; + } +} + + +button { + background: $dark_blue; + padding: 0.8em; + color: $white; + text-align: center; + border: none; + border-radius: 2px; + font-weight: 300; + width: 100%; + margin-bottom: 1em; +} + +.container { + background: $white; + width: 84%; + // margin: 3% auto; + padding: 6% 5%; + + -webkit-display: flex; + display: flex; + -webkit-align-items: flex-start; + align-items: flex-start; + -webkit-flex-direction: column; + flex-direction: column; +} + +img { + width: 50%; + -webkit-align-self: center; + align-self: center; +} + +@media only screen and (min-width : 500px) { + body { + font-size: 1.3em; + } + + form { + display: flex; + -webkit-display: flex; + -webkit-flex-direction: column; + flex-direction: column; + + .field-group, button, div { + flex-basis: 70%; + -webkit-align-self: center; + align-self: center; + } + } +} + +@media only screen and (min-width : 960px) { + .container{ + width: 60%; + padding: 3%; + -webkit-align-items: flex-start; + align-items: flex-start; + -webkit-flex-direction: row; + flex-direction: row; + max-width: 700px; + } + + form { + margin-left: 2.5em; + + .field-group, button, div { + width: 300px; + -webkit-align-self: flex-start; + align-self: flex-start; + } + + .field-group { + margin-top: 3em; + font-size: 1em; + } + } + + img { + width: 300px; + } + + button { + font-size: 0.8em; + margin-bottom: 1em; + } +} diff --git a/web-ui/src/i18n.js b/web-ui/src/i18n.js new file mode 100644 index 00000000..9c6ad550 --- /dev/null +++ b/web-ui/src/i18n.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ +import i18n from 'i18next' +import i18nBackend from 'i18nextXHRBackend' +import i18nDetector from 'i18nextBrowserLanguageDetector' + +const detector = new i18nDetector(); +const detect = detector.detect.bind(detector); + +detector.detect = function(detectionOrder) { + let result = detect(detectionOrder); + return result.replace('-', '_'); +}; + +i18n + .use(i18nBackend) + .use(detector) + .init({ + fallbackLng: 'en_US', + backend: { + loadPath: 'assets/locales/{{lng}}/{{ns}}.json' + } + }); + +export default i18n; diff --git a/web-ui/test/jasmine.json b/web-ui/test/jasmine.json deleted file mode 100644 index 969304b6..00000000 --- a/web-ui/test/jasmine.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "test/spec/account_recovery/", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ] -} diff --git a/web-ui/test/spec/account_recovery/page.spec.js b/web-ui/test/spec/account_recovery/page.spec.js deleted file mode 100644 index 3e19f244..00000000 --- a/web-ui/test/spec/account_recovery/page.spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import {shallow} from 'enzyme' -import expect from 'expect' -import React from 'react' -import { Page } from '../../../app/js/account_recovery/page' - -describe('Page', () => { - it('renders backup email page title', () => { - const mockT = key => key; - const page = shallow(); - expect(page.find('h1').text()).toEqual('backup-account.title'); - }); -}); diff --git a/web-ui/test/test-main.js b/web-ui/test/test-main.js index b7dc430f..4396993f 100644 --- a/web-ui/test/test-main.js +++ b/web-ui/test/test-main.js @@ -1,7 +1,7 @@ var tests = Object.keys(window.__karma__.files).filter(function (file) { 'use strict'; - return !(/account_recovery/.test(file)) && (/\.spec\.js$/.test(file)); + return (/\.spec\.js$/.test(file)); }); beforeEach(function() { diff --git a/web-ui/test/unit/account_recovery/page.spec.js b/web-ui/test/unit/account_recovery/page.spec.js new file mode 100644 index 00000000..151f09e1 --- /dev/null +++ b/web-ui/test/unit/account_recovery/page.spec.js @@ -0,0 +1,12 @@ +import { shallow } from 'enzyme' +import expect from 'expect' +import React from 'react' +import { Page } from 'src/account_recovery/page' + +describe('Page', () => { + it('renders backup email page title', () => { + const mockT = key => key; + const page = shallow(); + expect(page.find('h1').text()).toEqual('backup-account.title'); + }); +}); diff --git a/web-ui/webpack.config.js b/web-ui/webpack.config.js index 5886154a..9171b8f5 100644 --- a/web-ui/webpack.config.js +++ b/web-ui/webpack.config.js @@ -7,7 +7,7 @@ var aliases = require('./config/alias-webpack'); module.exports = { entry: { app: './app/js/index.js', - account_recovery: './app/js/account_recovery.js', + account_recovery: './src/account_recovery/account_recovery.js', sandbox: './app/js/sandbox.js' }, node: { fs: 'empty' }, diff --git a/web-ui/webpack.production.config.js b/web-ui/webpack.production.config.js index cf8ab8ff..6948d78e 100644 --- a/web-ui/webpack.production.config.js +++ b/web-ui/webpack.production.config.js @@ -7,7 +7,7 @@ var aliases = require('./config/alias-webpack'); module.exports = { entry: { app: './app/js/index.js', - account_recovery: './app/js/account_recovery.js', + account_recovery: './src/account_recovery/index.js', sandbox: './app/js/sandbox.js' }, node: { fs: 'empty' }, -- cgit v1.2.3 From 1204842f3eb792b6f12445edf1a79532493a3d55 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Tue, 7 Feb 2017 17:47:49 -0200 Subject: [#922] Add copyright with @anikarni --- web-ui/src/account_recovery/account_recovery.js | 17 +++++++++++++++++ web-ui/src/account_recovery/page.js | 17 +++++++++++++++++ web-ui/src/account_recovery/page.scss | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) (limited to 'web-ui') diff --git a/web-ui/src/account_recovery/account_recovery.js b/web-ui/src/account_recovery/account_recovery.js index f2421bfc..6c12e326 100644 --- a/web-ui/src/account_recovery/account_recovery.js +++ b/web-ui/src/account_recovery/account_recovery.js @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + import React from 'react' import { render } from 'react-dom' import a11y from 'react-a11y' diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js index a02d307c..79eca8a7 100644 --- a/web-ui/src/account_recovery/page.js +++ b/web-ui/src/account_recovery/page.js @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + import React from 'react' import { translate } from 'react-i18next' diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss index e7b1504e..6cd8c5aa 100644 --- a/web-ui/src/account_recovery/page.scss +++ b/web-ui/src/account_recovery/page.scss @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + @import "~scss/vendor/reset"; @import "~scss/base/colors"; @import "~scss/base/fonts"; -- cgit v1.2.3 From a47f32a7b0728c402787ebe914a0953638734820 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Tue, 7 Feb 2017 18:09:20 -0200 Subject: [#922] Extract the submit button to a component with @anikarni --- web-ui/src/account_recovery/page.js | 7 ++--- web-ui/src/account_recovery/page.scss | 24 +++--------------- web-ui/src/common/submit-button.scss | 48 +++++++++++++++++++++++++++++++++++ web-ui/src/common/submit_button.js | 26 +++++++++++++++++++ 4 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 web-ui/src/common/submit-button.scss create mode 100644 web-ui/src/common/submit_button.js (limited to 'web-ui') diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js index 79eca8a7..90a1faa4 100644 --- a/web-ui/src/account_recovery/page.js +++ b/web-ui/src/account_recovery/page.js @@ -17,21 +17,22 @@ import React from 'react' import { translate } from 'react-i18next' +import SubmitButton from 'src/common/submit_button' import './page.scss' export const Page = ({ t }) => (
- {t('backup-account.image-description')}/ + {t('backup-account.image-description')}

{t('backup-account.title')}

{t('backup-account.paragraph1')}

{t('backup-account.paragraph2')}

- +
- +
diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss index 6cd8c5aa..2ddb366c 100644 --- a/web-ui/src/account_recovery/page.scss +++ b/web-ui/src/account_recovery/page.scss @@ -104,23 +104,10 @@ a { } } - -button { - background: $dark_blue; - padding: 0.8em; - color: $white; - text-align: center; - border: none; - border-radius: 2px; - font-weight: 300; - width: 100%; - margin-bottom: 1em; -} - .container { background: $white; width: 84%; - // margin: 3% auto; + margin: 3% auto; padding: 6% 5%; -webkit-display: flex; @@ -148,7 +135,7 @@ img { -webkit-flex-direction: column; flex-direction: column; - .field-group, button, div { + .field-group, div { flex-basis: 70%; -webkit-align-self: center; align-self: center; @@ -170,7 +157,7 @@ img { form { margin-left: 2.5em; - .field-group, button, div { + .field-group, div { width: 300px; -webkit-align-self: flex-start; align-self: flex-start; @@ -185,9 +172,4 @@ img { img { width: 300px; } - - button { - font-size: 0.8em; - margin-bottom: 1em; - } } diff --git a/web-ui/src/common/submit-button.scss b/web-ui/src/common/submit-button.scss new file mode 100644 index 00000000..86a24e5a --- /dev/null +++ b/web-ui/src/common/submit-button.scss @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +@import "~scss/base/colors"; + +.submit-button { + background: $dark_blue; + padding: 0.8em; + color: $white; + text-align: center; + border: none; + border-radius: 2px; + font-weight: 300; + width: 100%; + margin-bottom: 1em; +} + +@media only screen and (min-width : 500px) { + .submit-button { + flex-basis: 70%; + -webkit-align-self: center; + align-self: center; + } +} + +@media only screen and (min-width : 960px) { + .submit-button { + width: 300px; + -webkit-align-self: flex-start; + align-self: flex-start; + font-size: 0.8em; + margin-bottom: 1em; + } +} diff --git a/web-ui/src/common/submit_button.js b/web-ui/src/common/submit_button.js new file mode 100644 index 00000000..89cfc55b --- /dev/null +++ b/web-ui/src/common/submit_button.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +import React from 'react' + +import './submit-button.scss' + +const SubmitButton = ({ buttonText }) => ( + +) + +export default SubmitButton -- cgit v1.2.3 From 31b0bcaa673794024a71065be76681150ad4b9d6 Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Tue, 7 Feb 2017 18:51:08 -0200 Subject: [#922] Extract input field to a component with @anikarni --- web-ui/src/account_recovery/page.js | 8 +-- web-ui/src/account_recovery/page.scss | 53 +-------------- web-ui/src/common/input_field/input-field.scss | 77 ++++++++++++++++++++++ web-ui/src/common/input_field/input_field.js | 29 ++++++++ web-ui/src/common/submit-button.scss | 48 -------------- web-ui/src/common/submit_button.js | 26 -------- web-ui/src/common/submit_button/submit-button.scss | 48 ++++++++++++++ web-ui/src/common/submit_button/submit_button.js | 26 ++++++++ web-ui/test/unit/account_recovery/page.spec.js | 23 +++++-- 9 files changed, 203 insertions(+), 135 deletions(-) create mode 100644 web-ui/src/common/input_field/input-field.scss create mode 100644 web-ui/src/common/input_field/input_field.js delete mode 100644 web-ui/src/common/submit-button.scss delete mode 100644 web-ui/src/common/submit_button.js create mode 100644 web-ui/src/common/submit_button/submit-button.scss create mode 100644 web-ui/src/common/submit_button/submit_button.js (limited to 'web-ui') diff --git a/web-ui/src/account_recovery/page.js b/web-ui/src/account_recovery/page.js index 90a1faa4..d1bcb464 100644 --- a/web-ui/src/account_recovery/page.js +++ b/web-ui/src/account_recovery/page.js @@ -17,7 +17,8 @@ import React from 'react' import { translate } from 'react-i18next' -import SubmitButton from 'src/common/submit_button' +import SubmitButton from 'src/common/submit_button/submit_button' +import InputField from 'src/common/input_field/input_field' import './page.scss' @@ -28,10 +29,7 @@ export const Page = ({ t }) => (

{t('backup-account.title')}

{t('backup-account.paragraph1')}

{t('backup-account.paragraph2')}

-
- - -
+
diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss index 2ddb366c..c23fe569 100644 --- a/web-ui/src/account_recovery/page.scss +++ b/web-ui/src/account_recovery/page.scss @@ -60,50 +60,6 @@ a { } -.field-group { - position:relative; - margin: 1.5em 0; - width: 100%; - - label { - font-size: 0.9em; - margin-bottom: 10px; - display: inline-block; - } - - input { - display: block; - border: none; - border-bottom: solid 1px #4da3b6; - width: 100%; - height: auto; - padding: 0.3em 0px; - } - - input:focus { - outline:none; - border-width: 2px; - } - - input:focus ~ .animated-label, input:valid ~ .animated-label { - top:-12px; - left: 0; - font-size:0.7em; - color:#4da3b6; - } - - .animated-label { - color:#999; - position:absolute; - pointer-events:none; - left: 6px; - top:10px; - transition:0.2s ease all; - -moz-transition:0.2s ease all; - -webkit-transition:0.2s ease all; - } -} - .container { background: $white; width: 84%; @@ -135,7 +91,7 @@ img { -webkit-flex-direction: column; flex-direction: column; - .field-group, div { + div { flex-basis: 70%; -webkit-align-self: center; align-self: center; @@ -157,16 +113,11 @@ img { form { margin-left: 2.5em; - .field-group, div { + div { width: 300px; -webkit-align-self: flex-start; align-self: flex-start; } - - .field-group { - margin-top: 3em; - font-size: 1em; - } } img { diff --git a/web-ui/src/common/input_field/input-field.scss b/web-ui/src/common/input_field/input-field.scss new file mode 100644 index 00000000..ad5dda13 --- /dev/null +++ b/web-ui/src/common/input_field/input-field.scss @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +@import "~scss/base/colors"; + +.input-field-group { + position:relative; + margin: 1.5em 0; + width: 100%; +} + +.input-field-label { + font-size: 0.9em; + margin-bottom: 10px; + display: inline-block; + color:#999; + position:absolute; + pointer-events:none; + left: 6px; + top:10px; + transition:0.2s ease all; + -moz-transition:0.2s ease all; + -webkit-transition:0.2s ease all; +} + +.input-field { + display: block; + border: none; + border-bottom: solid 1px $dark_blue; + width: 100%; + height: auto; + padding: 0.3em 0px; + + &:focus { + outline:none; + border-width: 2px; + } +} + +.input-field:focus ~ .input-field-label, .input-field:valid ~ .input-field-label { + top:-12px; + left: 0; + font-size:0.7em; + color: $dark_blue; +} + +@media only screen and (min-width : 500px) { + .input-field-group { + flex-basis: 70%; + -webkit-align-self: center; + align-self: center; + } +} + +@media only screen and (min-width : 960px) { + .input-field-group { + width: 300px; + -webkit-align-self: flex-start; + align-self: flex-start; + margin-top: 3em; + font-size: 1em; + } +} diff --git a/web-ui/src/common/input_field/input_field.js b/web-ui/src/common/input_field/input_field.js new file mode 100644 index 00000000..43899419 --- /dev/null +++ b/web-ui/src/common/input_field/input_field.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +import React from 'react' + +import './input-field.scss' + +const InputField = ({ label, name }) => ( +
+ + +
+) + +export default InputField diff --git a/web-ui/src/common/submit-button.scss b/web-ui/src/common/submit-button.scss deleted file mode 100644 index 86a24e5a..00000000 --- a/web-ui/src/common/submit-button.scss +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 ThoughtWorks, Inc. - * - * Pixelated is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Pixelated is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Pixelated. If not, see . - */ - -@import "~scss/base/colors"; - -.submit-button { - background: $dark_blue; - padding: 0.8em; - color: $white; - text-align: center; - border: none; - border-radius: 2px; - font-weight: 300; - width: 100%; - margin-bottom: 1em; -} - -@media only screen and (min-width : 500px) { - .submit-button { - flex-basis: 70%; - -webkit-align-self: center; - align-self: center; - } -} - -@media only screen and (min-width : 960px) { - .submit-button { - width: 300px; - -webkit-align-self: flex-start; - align-self: flex-start; - font-size: 0.8em; - margin-bottom: 1em; - } -} diff --git a/web-ui/src/common/submit_button.js b/web-ui/src/common/submit_button.js deleted file mode 100644 index 89cfc55b..00000000 --- a/web-ui/src/common/submit_button.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017 ThoughtWorks, Inc. - * - * Pixelated is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Pixelated is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Pixelated. If not, see . - */ - -import React from 'react' - -import './submit-button.scss' - -const SubmitButton = ({ buttonText }) => ( - -) - -export default SubmitButton diff --git a/web-ui/src/common/submit_button/submit-button.scss b/web-ui/src/common/submit_button/submit-button.scss new file mode 100644 index 00000000..86a24e5a --- /dev/null +++ b/web-ui/src/common/submit_button/submit-button.scss @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +@import "~scss/base/colors"; + +.submit-button { + background: $dark_blue; + padding: 0.8em; + color: $white; + text-align: center; + border: none; + border-radius: 2px; + font-weight: 300; + width: 100%; + margin-bottom: 1em; +} + +@media only screen and (min-width : 500px) { + .submit-button { + flex-basis: 70%; + -webkit-align-self: center; + align-self: center; + } +} + +@media only screen and (min-width : 960px) { + .submit-button { + width: 300px; + -webkit-align-self: flex-start; + align-self: flex-start; + font-size: 0.8em; + margin-bottom: 1em; + } +} diff --git a/web-ui/src/common/submit_button/submit_button.js b/web-ui/src/common/submit_button/submit_button.js new file mode 100644 index 00000000..89cfc55b --- /dev/null +++ b/web-ui/src/common/submit_button/submit_button.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +import React from 'react' + +import './submit-button.scss' + +const SubmitButton = ({ buttonText }) => ( + +) + +export default SubmitButton diff --git a/web-ui/test/unit/account_recovery/page.spec.js b/web-ui/test/unit/account_recovery/page.spec.js index 151f09e1..590d1de8 100644 --- a/web-ui/test/unit/account_recovery/page.spec.js +++ b/web-ui/test/unit/account_recovery/page.spec.js @@ -4,9 +4,22 @@ import React from 'react' import { Page } from 'src/account_recovery/page' describe('Page', () => { + let mockT, page + + beforeEach(() => { + mockT = (key) => (key) + page = shallow() + }) + it('renders backup email page title', () => { - const mockT = key => key; - const page = shallow(); - expect(page.find('h1').text()).toEqual('backup-account.title'); - }); -}); + expect(page.find('h1').text()).toEqual('backup-account.title') + }) + + it('renders backup account email input field', () => { + expect(page.find('InputField').props().name).toEqual('email') + }) + + it('renders backup account submit button', () => { + expect(page.find('SubmitButton').props().buttonText).toEqual('backup-account.button') + }) +}) -- cgit v1.2.3 From aa26a47abac48d817a04a4f2375f1378767fa83c Mon Sep 17 00:00:00 2001 From: Tayane Fernandes Date: Tue, 7 Feb 2017 19:02:47 -0200 Subject: [#922] Fix button and input width with @anikarni --- web-ui/src/account_recovery/page.scss | 2 +- web-ui/src/common/input_field/input-field.scss | 2 +- web-ui/src/common/submit_button/submit-button.scss | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'web-ui') diff --git a/web-ui/src/account_recovery/page.scss b/web-ui/src/account_recovery/page.scss index c23fe569..c928d815 100644 --- a/web-ui/src/account_recovery/page.scss +++ b/web-ui/src/account_recovery/page.scss @@ -92,7 +92,7 @@ img { flex-direction: column; div { - flex-basis: 70%; + width: 70%; -webkit-align-self: center; align-self: center; } diff --git a/web-ui/src/common/input_field/input-field.scss b/web-ui/src/common/input_field/input-field.scss index ad5dda13..6ec827ab 100644 --- a/web-ui/src/common/input_field/input-field.scss +++ b/web-ui/src/common/input_field/input-field.scss @@ -60,7 +60,7 @@ @media only screen and (min-width : 500px) { .input-field-group { - flex-basis: 70%; + width: 70%; -webkit-align-self: center; align-self: center; } diff --git a/web-ui/src/common/submit_button/submit-button.scss b/web-ui/src/common/submit_button/submit-button.scss index 86a24e5a..ccd0bef4 100644 --- a/web-ui/src/common/submit_button/submit-button.scss +++ b/web-ui/src/common/submit_button/submit-button.scss @@ -31,7 +31,7 @@ @media only screen and (min-width : 500px) { .submit-button { - flex-basis: 70%; + width: 70%; -webkit-align-self: center; align-self: center; } -- cgit v1.2.3