From b02e41c20ad0d672d041896bdc51a2dfbe3b7238 Mon Sep 17 00:00:00 2001 From: Alexey Bondarenko Date: Sat, 7 Apr 2018 17:19:04 +0300 Subject: [PATCH] Revert "Init project" This reverts commit 23f9648a5f589be433fcaf4453a8a46919726300. --- .babelrc | 2 +- .travis.yml | 2 +- LICENSE.md | 2 +- README.md | 46 +- app.json | 40 + app/client/index.js | 6 + app/client/root.js | 65 +- app/common/WithStylesContext.js | 3 +- app/common/components/Button/index.js | 87 + app/common/components/Button/index.spec.js | 87 + app/common/components/Button/styles.scss | 274 +++ app/common/components/Checkbox/index.js | 52 + app/common/components/Checkbox/index.spec.js | 50 + app/common/components/Checkbox/styles.scss | 78 + app/common/components/Container/index.js | 11 + app/common/components/Container/index.spec.js | 14 + app/common/components/Container/styles.scss | 9 + .../components/DatepickerInput/index.js | 29 + .../components/DatepickerInput/index.spec.js | 22 + .../components/DatepickerInput/libStyles.css | 399 ++++ app/common/components/DropDown/index.js | 38 + app/common/components/DropDown/styles.scss | 71 + app/common/components/ErrorMessages/index.js | 25 + app/common/components/FoldingTable/index.js | 107 + .../components/FoldingTable/styles.scss | 64 + app/common/components/Form/index.js | 69 + app/common/components/Form/styles.scss | 140 ++ app/common/components/FullScreen/index.js | 33 + app/common/components/FullScreen/styles.scss | 15 + app/common/components/IFrame/index.js | 23 + app/common/components/Icon/icons.font.js | 12 + app/common/components/Icon/icons/add.svg | 1 + .../components/Icon/icons/arrow-down.svg | 3 + .../Icon/icons/arrow-left-large.svg | 1 + .../components/Icon/icons/arrow-left.svg | 1 + .../components/Icon/icons/arrow-right.svg | 1 + .../components/Icon/icons/arrows-expand.svg | 44 + .../components/Icon/icons/arrows-reduce.svg | 44 + .../components/Icon/icons/check-right.svg | 1 + app/common/components/Icon/icons/doc.svg | 29 + app/common/components/Icon/icons/eye.svg | 12 + app/common/components/Icon/icons/nebo15.svg | 40 + app/common/components/Icon/icons/trash.svg | 1 + app/common/components/Icon/index.js | 29 + app/common/components/Icon/index.spec.js | 29 + app/common/components/Icon/templates/css.hbs | 27 + app/common/components/Input/index.js | 101 + app/common/components/Input/styles.scss | 140 ++ .../components/LanguageSelector/index.js | 58 + .../components/LanguageSelector/styles.scss | 19 + app/common/components/Line/index.js | 8 + app/common/components/Line/styles.scss | 9 + app/common/components/LoadingBar/index.js | 29 + app/common/components/LoadingBar/styles.scss | 28 + app/common/components/MaskedInput/index.js | 7 + app/common/components/NavItem/index.js | 18 + app/common/components/OuterClick/index.js | 41 + .../components/OuterClick/index.spec.js | 29 + app/common/components/Pagination/index.js | 46 + app/common/components/Pagination/styles.scss | 65 + app/common/components/Popup/index.js | 121 + app/common/components/Popup/index.spec.js | 112 + app/common/components/Popup/styles.scss | 113 + app/common/components/RadioInput/index.js | 30 + .../components/RadioInput/index.spec.js | 92 + app/common/components/RadioInput/styles.scss | 42 + app/common/components/Select/index.js | 129 ++ app/common/components/Select/index.spec.js | 45 + app/common/components/Select/styles.scss | 182 ++ app/common/components/StatusCode/index.js | 16 + app/common/components/StatusCode/styles.scss | 12 + app/common/components/Switch/index.js | 42 + app/common/components/Switch/index.spec.js | 34 + app/common/components/Switch/styles.scss | 48 + app/common/components/Table/index.js | 126 + app/common/components/Table/index.spec.js | 183 ++ app/common/components/Table/styles.scss | 154 ++ app/common/components/Tags/index.js | 10 + app/common/components/Tags/styles.scss | 17 + .../components/TemplatePreview/index.js | 174 ++ .../components/TemplatePreview/styles.scss | 110 + app/common/components/Title/index.js | 34 + app/common/components/Title/index.spec.js | 153 ++ app/common/components/Title/styles.scss | 43 + app/common/components/ToggleCheckbox/index.js | 36 + .../components/ToggleCheckbox/index.spec.js | 39 + .../components/ToggleCheckbox/styles.scss | 77 + app/common/components/URLPath/index.js | 10 + app/common/components/URLPath/styles.scss | 5 + app/common/components/__Component__/index.js | 11 - .../components/__Component__/index.spec.js | 15 - .../components/__Component__/styles.scss | 3 - .../components/reduxForm/FieldCheckbox.js | 6 + .../reduxForm/FieldCheckboxGroup.js | 43 + .../components/reduxForm/FieldCode/index.js | 45 + .../reduxForm/FieldCode/styles.scss | 35 + .../reduxForm/FieldDatepicker/index.js | 16 + app/common/components/reduxForm/FieldInput.js | 33 + .../components/reduxForm/FieldSelect.js | 6 + .../components/reduxForm/FieldTextarea.js | 6 + app/common/config.js | 2 +- app/common/containers/blocks/Aside/index.js | 42 + app/common/containers/blocks/Aside/redux.js | 17 + .../containers/blocks/Aside/styles.scss | 85 + .../blocks/ConfirmFormChanges/index.js | 51 + .../containers/blocks/EditLocales/index.js | 191 ++ .../containers/blocks/EditLocales/styles.scss | 187 ++ .../containers/blocks/FieldsList/index.js | 34 + .../containers/blocks/FieldsList/styles.scss | 6 + .../blocks/FormPageWrapper/index.js | 37 + .../blocks/FormPageWrapper/styles.scss | 13 + .../containers/blocks/Gamburger/index.js | 21 + .../containers/blocks/Gamburger/styles.scss | 35 + app/common/containers/blocks/Nav/index.js | 45 + app/common/containers/blocks/Nav/styles.scss | 123 + .../containers/blocks/RequestDetails/index.js | 114 + .../blocks/RequestDetails/styles.scss | 53 + .../containers/forms/AddLanguageForm/index.js | 56 + .../forms/AddLanguageForm/styles.scss | 24 + app/common/containers/forms/ApiForm/index.js | 136 ++ .../containers/forms/ApiForm/styles.scss | 24 + .../containers/forms/TemplateForm/index.js | 197 ++ .../containers/forms/TemplateForm/styles.scss | 24 + app/common/containers/layouts/App/index.js | 35 +- app/common/containers/layouts/App/styles.scss | 83 - app/common/containers/layouts/Main/index.js | 22 +- .../containers/layouts/Main/styles.scss | 201 ++ .../containers/pages/DefaultPage/index.js | 7 - .../containers/pages/DefaultPage/redux.js | 0 .../containers/pages/NotFoundPage/index.js | 15 + .../pages/TemplateCreatePage/index.js | 38 + .../pages/TemplateCreatePage/redux.js | 9 + .../pages/TemplateEditPage/index.js | 44 + .../pages/TemplateEditPage/redux.js | 11 + .../pages/TemplateListPage/index.js | 62 + .../pages/TemplateListPage/redux.js | 18 + .../pages/TemplateListPage/styles.scss | 23 + app/common/reducers/index.js | 35 +- app/common/redux/labels.js | 25 + app/common/redux/templates.js | 91 + app/common/routes/index.js | 16 +- app/common/schemas/index.js | 4 +- app/server/__dev.js | 2 +- assets/fonts/montserratbold.eot | Bin 0 -> 43654 bytes assets/fonts/montserratbold.svg | 1540 +++++++++++++ assets/fonts/montserratbold.ttf | Bin 0 -> 43344 bytes assets/fonts/montserratbold.woff | Bin 0 -> 21936 bytes assets/fonts/montserratbold.woff2 | Bin 0 -> 15652 bytes assets/fonts/montserratlight.eot | Bin 0 -> 44252 bytes assets/fonts/montserratlight.svg | 1558 +++++++++++++ assets/fonts/montserratlight.ttf | Bin 0 -> 43932 bytes assets/fonts/montserratlight.woff | Bin 0 -> 22184 bytes assets/fonts/montserratlight.woff2 | Bin 0 -> 15864 bytes assets/fonts/montserratregular.eot | Bin 0 -> 44252 bytes assets/fonts/montserratregular.svg | 1558 +++++++++++++ assets/fonts/montserratregular.ttf | Bin 0 -> 43940 bytes assets/fonts/montserratregular.woff | Bin 0 -> 22004 bytes assets/fonts/montserratregular.woff2 | Bin 0 -> 15668 bytes assets/fonts/montserratultralight.eot | Bin 0 -> 67678 bytes assets/fonts/montserratultralight.svg | 2025 +++++++++++++++++ assets/fonts/montserratultralight.ttf | Bin 0 -> 67336 bytes assets/fonts/montserratultralight.woff | Bin 0 -> 29992 bytes assets/fonts/montserratultralight.woff2 | Bin 0 -> 20680 bytes .../images/icons/android-chrome-192x192.png | Bin 0 -> 8307 bytes .../images/icons/android-chrome-256x256.png | Bin 0 -> 11526 bytes assets/images/icons/apple-touch-icon.png | Bin 0 -> 7698 bytes assets/images/icons/browserconfig.xml | 9 + assets/images/icons/favicon-16x16.png | Bin 0 -> 1010 bytes assets/images/icons/favicon-32x32.png | Bin 0 -> 1810 bytes assets/images/icons/manifest.json | 18 + assets/images/icons/mstile-150x150.png | Bin 0 -> 5534 bytes assets/images/icons/safari-pinned-tab.svg | 322 +++ assets/images/logo.png | Bin 0 -> 34857 bytes docs/images/ui-animated.gif | Bin 0 -> 1686858 bytes package.json | 37 +- public/favicon.ico | Bin 0 -> 15086 bytes public/images/logo.svg | 17 + webpack/parts.js | 8 +- 178 files changed, 14287 insertions(+), 207 deletions(-) create mode 100644 app.json create mode 100644 app/common/components/Button/index.js create mode 100644 app/common/components/Button/index.spec.js create mode 100644 app/common/components/Button/styles.scss create mode 100644 app/common/components/Checkbox/index.js create mode 100644 app/common/components/Checkbox/index.spec.js create mode 100644 app/common/components/Checkbox/styles.scss create mode 100644 app/common/components/Container/index.js create mode 100644 app/common/components/Container/index.spec.js create mode 100644 app/common/components/Container/styles.scss create mode 100644 app/common/components/DatepickerInput/index.js create mode 100644 app/common/components/DatepickerInput/index.spec.js create mode 100644 app/common/components/DatepickerInput/libStyles.css create mode 100644 app/common/components/DropDown/index.js create mode 100644 app/common/components/DropDown/styles.scss create mode 100644 app/common/components/ErrorMessages/index.js create mode 100644 app/common/components/FoldingTable/index.js create mode 100644 app/common/components/FoldingTable/styles.scss create mode 100644 app/common/components/Form/index.js create mode 100644 app/common/components/Form/styles.scss create mode 100644 app/common/components/FullScreen/index.js create mode 100644 app/common/components/FullScreen/styles.scss create mode 100644 app/common/components/IFrame/index.js create mode 100644 app/common/components/Icon/icons.font.js create mode 100644 app/common/components/Icon/icons/add.svg create mode 100644 app/common/components/Icon/icons/arrow-down.svg create mode 100644 app/common/components/Icon/icons/arrow-left-large.svg create mode 100644 app/common/components/Icon/icons/arrow-left.svg create mode 100644 app/common/components/Icon/icons/arrow-right.svg create mode 100644 app/common/components/Icon/icons/arrows-expand.svg create mode 100644 app/common/components/Icon/icons/arrows-reduce.svg create mode 100644 app/common/components/Icon/icons/check-right.svg create mode 100644 app/common/components/Icon/icons/doc.svg create mode 100644 app/common/components/Icon/icons/eye.svg create mode 100644 app/common/components/Icon/icons/nebo15.svg create mode 100644 app/common/components/Icon/icons/trash.svg create mode 100644 app/common/components/Icon/index.js create mode 100644 app/common/components/Icon/index.spec.js create mode 100644 app/common/components/Icon/templates/css.hbs create mode 100644 app/common/components/Input/index.js create mode 100644 app/common/components/Input/styles.scss create mode 100644 app/common/components/LanguageSelector/index.js create mode 100644 app/common/components/LanguageSelector/styles.scss create mode 100644 app/common/components/Line/index.js create mode 100644 app/common/components/Line/styles.scss create mode 100644 app/common/components/LoadingBar/index.js create mode 100644 app/common/components/LoadingBar/styles.scss create mode 100644 app/common/components/MaskedInput/index.js create mode 100644 app/common/components/NavItem/index.js create mode 100644 app/common/components/OuterClick/index.js create mode 100644 app/common/components/OuterClick/index.spec.js create mode 100644 app/common/components/Pagination/index.js create mode 100644 app/common/components/Pagination/styles.scss create mode 100644 app/common/components/Popup/index.js create mode 100644 app/common/components/Popup/index.spec.js create mode 100644 app/common/components/Popup/styles.scss create mode 100644 app/common/components/RadioInput/index.js create mode 100644 app/common/components/RadioInput/index.spec.js create mode 100644 app/common/components/RadioInput/styles.scss create mode 100644 app/common/components/Select/index.js create mode 100644 app/common/components/Select/index.spec.js create mode 100644 app/common/components/Select/styles.scss create mode 100644 app/common/components/StatusCode/index.js create mode 100644 app/common/components/StatusCode/styles.scss create mode 100644 app/common/components/Switch/index.js create mode 100644 app/common/components/Switch/index.spec.js create mode 100644 app/common/components/Switch/styles.scss create mode 100644 app/common/components/Table/index.js create mode 100644 app/common/components/Table/index.spec.js create mode 100644 app/common/components/Table/styles.scss create mode 100644 app/common/components/Tags/index.js create mode 100644 app/common/components/Tags/styles.scss create mode 100644 app/common/components/TemplatePreview/index.js create mode 100644 app/common/components/TemplatePreview/styles.scss create mode 100644 app/common/components/Title/index.js create mode 100644 app/common/components/Title/index.spec.js create mode 100644 app/common/components/Title/styles.scss create mode 100644 app/common/components/ToggleCheckbox/index.js create mode 100644 app/common/components/ToggleCheckbox/index.spec.js create mode 100644 app/common/components/ToggleCheckbox/styles.scss create mode 100644 app/common/components/URLPath/index.js create mode 100644 app/common/components/URLPath/styles.scss delete mode 100644 app/common/components/__Component__/index.js delete mode 100644 app/common/components/__Component__/index.spec.js delete mode 100644 app/common/components/__Component__/styles.scss create mode 100644 app/common/components/reduxForm/FieldCheckbox.js create mode 100644 app/common/components/reduxForm/FieldCheckboxGroup.js create mode 100644 app/common/components/reduxForm/FieldCode/index.js create mode 100644 app/common/components/reduxForm/FieldCode/styles.scss create mode 100644 app/common/components/reduxForm/FieldDatepicker/index.js create mode 100644 app/common/components/reduxForm/FieldInput.js create mode 100644 app/common/components/reduxForm/FieldSelect.js create mode 100644 app/common/components/reduxForm/FieldTextarea.js create mode 100644 app/common/containers/blocks/Aside/index.js create mode 100644 app/common/containers/blocks/Aside/redux.js create mode 100644 app/common/containers/blocks/Aside/styles.scss create mode 100644 app/common/containers/blocks/ConfirmFormChanges/index.js create mode 100644 app/common/containers/blocks/EditLocales/index.js create mode 100644 app/common/containers/blocks/EditLocales/styles.scss create mode 100644 app/common/containers/blocks/FieldsList/index.js create mode 100644 app/common/containers/blocks/FieldsList/styles.scss create mode 100644 app/common/containers/blocks/FormPageWrapper/index.js create mode 100644 app/common/containers/blocks/FormPageWrapper/styles.scss create mode 100644 app/common/containers/blocks/Gamburger/index.js create mode 100644 app/common/containers/blocks/Gamburger/styles.scss create mode 100644 app/common/containers/blocks/Nav/index.js create mode 100644 app/common/containers/blocks/Nav/styles.scss create mode 100644 app/common/containers/blocks/RequestDetails/index.js create mode 100644 app/common/containers/blocks/RequestDetails/styles.scss create mode 100644 app/common/containers/forms/AddLanguageForm/index.js create mode 100644 app/common/containers/forms/AddLanguageForm/styles.scss create mode 100644 app/common/containers/forms/ApiForm/index.js create mode 100644 app/common/containers/forms/ApiForm/styles.scss create mode 100644 app/common/containers/forms/TemplateForm/index.js create mode 100644 app/common/containers/forms/TemplateForm/styles.scss delete mode 100644 app/common/containers/layouts/App/styles.scss create mode 100644 app/common/containers/layouts/Main/styles.scss delete mode 100644 app/common/containers/pages/DefaultPage/index.js delete mode 100644 app/common/containers/pages/DefaultPage/redux.js create mode 100644 app/common/containers/pages/NotFoundPage/index.js create mode 100644 app/common/containers/pages/TemplateCreatePage/index.js create mode 100644 app/common/containers/pages/TemplateCreatePage/redux.js create mode 100644 app/common/containers/pages/TemplateEditPage/index.js create mode 100644 app/common/containers/pages/TemplateEditPage/redux.js create mode 100644 app/common/containers/pages/TemplateListPage/index.js create mode 100644 app/common/containers/pages/TemplateListPage/redux.js create mode 100644 app/common/containers/pages/TemplateListPage/styles.scss create mode 100644 app/common/redux/labels.js create mode 100644 app/common/redux/templates.js create mode 100755 assets/fonts/montserratbold.eot create mode 100755 assets/fonts/montserratbold.svg create mode 100755 assets/fonts/montserratbold.ttf create mode 100755 assets/fonts/montserratbold.woff create mode 100755 assets/fonts/montserratbold.woff2 create mode 100755 assets/fonts/montserratlight.eot create mode 100755 assets/fonts/montserratlight.svg create mode 100755 assets/fonts/montserratlight.ttf create mode 100755 assets/fonts/montserratlight.woff create mode 100755 assets/fonts/montserratlight.woff2 create mode 100755 assets/fonts/montserratregular.eot create mode 100755 assets/fonts/montserratregular.svg create mode 100755 assets/fonts/montserratregular.ttf create mode 100755 assets/fonts/montserratregular.woff create mode 100755 assets/fonts/montserratregular.woff2 create mode 100755 assets/fonts/montserratultralight.eot create mode 100755 assets/fonts/montserratultralight.svg create mode 100755 assets/fonts/montserratultralight.ttf create mode 100755 assets/fonts/montserratultralight.woff create mode 100755 assets/fonts/montserratultralight.woff2 create mode 100644 assets/images/icons/android-chrome-192x192.png create mode 100644 assets/images/icons/android-chrome-256x256.png create mode 100644 assets/images/icons/apple-touch-icon.png create mode 100644 assets/images/icons/browserconfig.xml create mode 100644 assets/images/icons/favicon-16x16.png create mode 100644 assets/images/icons/favicon-32x32.png create mode 100644 assets/images/icons/manifest.json create mode 100644 assets/images/icons/mstile-150x150.png create mode 100644 assets/images/icons/safari-pinned-tab.svg create mode 100644 assets/images/logo.png create mode 100644 docs/images/ui-animated.gif create mode 100644 public/favicon.ico create mode 100644 public/images/logo.svg diff --git a/.babelrc b/.babelrc index 81dcedf..33fde9c 100644 --- a/.babelrc +++ b/.babelrc @@ -13,7 +13,7 @@ "root": ["./app/common"], "alias": { "tests": "./tests", - "withStyles": "isomorphic-style-loader/lib/withStyles", + "withStyles": "nebo15-isomorphic-style-loader/lib/withStyles", "public": "./public" } } diff --git a/.travis.yml b/.travis.yml index 6d84427..a56bf89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ script: - sleep 5 - docker ps - RUNNING_CONTAINERS=`docker ps | wc -l`; if [ "${RUNNING_CONTAINERS//[[:space:]]/}" - == "1" ]; then echo "[E] Container is not started\!"; docker logs cryptograph --details + == "1" ]; then echo "[E] Container is not started\!"; docker logs man.web --details --since 5h; exit 1; fi; - npm run nightwatch -- -e travis - sleep 5 diff --git a/LICENSE.md b/LICENSE.md index 8055e9e..68f564f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Front.band +Copyright (c) 2017 Nebo #15 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d0a434e..db9b809 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,48 @@ -# Cryptograph +# Mán Dashboard + +[![Greenkeeper badge](https://badges.greenkeeper.io/Nebo15/man.web.svg)](https://greenkeeper.io/) +[![Build Status](https://travis-ci.org/Nebo15/man.web.svg?branch=master)](https://travis-ci.org/Nebo15/man.web) + +[![Build history](https://buildstats.info/travisci/chart/Nebo15/man.web)](https://travis-ci.org/Nebo15/man.web) + +![Man Logo](https://github.com/Nebo15/man.api/raw/master/docs/images/logo.png) + +Mán stores templates (in `iex`, `mustache`) or `markdown` documents, renders it over HTTP API with dispatch in PDF, JSON or HTML formats. + +> "Mán" translates from the Sindarin as "Spirit". Sindarin is one of the many languages spoken by the immortal Elves. + +API: https://github.com/Nebo15/man.api + +## Demo + +![UI Demo](https://github.com/Nebo15/man.web/raw/master/docs/images/ui-animated.gif) + +Try it here: http://man-web.herokuapp.com/ + +## Installation + +### Heroku One-Click Deployment + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/nebo15/man.web) + +### Docker + +Dashboard can be deployed as a single container from [nebo15/man.web](https://hub.docker.com/r/nebo15/man.web/) Docker Hub. + +## Configurations + +Application supports these environment variables: + +| Environment Variable | Default Value | Description | +| --------------------- | ----------------------- | ----------- | +| `PORT` | `8080` | Node.js server port. | +| `API_ENDPOINT` | `https://man-api.herokuapp.com` | Mán API endpoint. | +| `SITEMAP_HOSTNAME` | `http://localhost:8080` | URL will be used in sitemap generated urls | +| `LANG_COOKIE_NAME` | `lang` | Name of the cookie, where storing language variable | + +## Docs + +Dashboard works on top of [Man management API](http://docs.man2.apiary.io). ## Technologies diff --git a/app.json b/app.json new file mode 100644 index 0000000..4079253 --- /dev/null +++ b/app.json @@ -0,0 +1,40 @@ +{ + "name": "man.web", + "logo": "https://raw.githubusercontent.com/Nebo15/man.web/master/assets/images/logo.png", + "scripts": { + }, + "env": { + "PREBUILD": { + "description": "RUN postinstall script. MUST be `true`", + "required": true, + "value": "true" + }, + "API_ENDPOINT": { + "description": "Mán API host", + "required": true, + "value": "https://man-api.herokuapp.com" + }, + "SITEMAP_HOSTNAME": { + "description": "SITEMAP_HOSTNAME will be used as hostname in sitemap URLs", + "required": false, + "value": "" + }, + "LANG_COOKIE_NAME": { + "description": "Name of the cookie, where storing language variable", + "value": "lang" + } + }, + "formation": { + "web": { + "quantity": 1 + } + }, + "addons": [ + + ], + "buildpacks": [ + { + "url": "heroku/nodejs" + } + ] +} diff --git a/app/client/index.js b/app/client/index.js index a6115ca..3708ee2 100644 --- a/app/client/index.js +++ b/app/client/index.js @@ -1,6 +1,12 @@ import React from 'react'; import ReactDOM from 'react-dom'; +import 'codemirror/addon/display/placeholder'; +import 'codemirror/mode/handlebars/handlebars'; +import 'codemirror/mode/xml/xml'; +import 'codemirror/mode/markdown/markdown'; +import 'codemirror/mode/javascript/javascript'; + import { AppContainer } from 'react-hot-loader'; import CookieDough from 'cookie-dough'; diff --git a/app/client/root.js b/app/client/root.js index f216ba0..dbe9030 100644 --- a/app/client/root.js +++ b/app/client/root.js @@ -7,7 +7,6 @@ import { useRedial } from 'react-router-redial'; import { I18nextProvider } from 'react-i18next'; import { showLoading, hideLoading } from 'redux/loading'; -import WithStylesContext from 'WithStylesContext'; const trackPage = (route) => {}; // eslint-disable-line @@ -37,39 +36,37 @@ export default class RootComponent extends React.Component { return ( - {}}> -
Loading...
), - onStarted: () => { - store.dispatch(showLoading()); - }, - onCompleted: (transition) => { - store.dispatch([ - hideLoading(), - ]); - if (transition === 'beforeTransition') { - window.scrollTo(0, 0); - } - }, - onAborted: () => { - store.dispatch(hideLoading()); - }, - onError: () => { - store.dispatch(hideLoading()); - }, - }) - )} - /> -
+
Loading...
), + onStarted: () => { + store.dispatch(showLoading()); + }, + onCompleted: (transition) => { + store.dispatch([ + hideLoading(), + ]); + if (transition === 'beforeTransition') { + window.scrollTo(0, 0); + } + }, + onAborted: () => { + store.dispatch(hideLoading()); + }, + onError: () => { + store.dispatch(hideLoading()); + }, + }) + )} + />
); diff --git a/app/common/WithStylesContext.js b/app/common/WithStylesContext.js index d232e69..499d90a 100644 --- a/app/common/WithStylesContext.js +++ b/app/common/WithStylesContext.js @@ -1,6 +1,5 @@ -import { Component, Children } from 'react'; -import PropTypes from 'prop-types'; +import { Component, PropTypes, Children } from 'react'; export default class WithStylesContext extends Component { static propTypes = { diff --git a/app/common/components/Button/index.js b/app/common/components/Button/index.js new file mode 100644 index 0000000..8fb0461 --- /dev/null +++ b/app/common/components/Button/index.js @@ -0,0 +1,87 @@ +import React from 'react'; +import { Link } from 'react-router'; +import classnames from 'classnames'; +import withStyles from 'nebo15-isomorphic-style-loader/lib/withStyles'; + +import Icon, { icons } from 'components/Icon'; + +import styles from './styles.scss'; + +const URL_TEST_REG_EXP = /^((?:[a-z]+:)?\/\/)|mailto:/i; + +const Button = (props) => { + const { + theme = 'fill', + size = 'middle', + color = 'orange', + active = false, + disabled = false, + block = false, + inheritColor = false, + type = 'button', + to, children, onClick, id, icon, name, + } = props; + + const className = classnames( + styles.button, + styles[`theme-${theme}`], + styles[`color-${color}`], + styles[`size-${size}`], + active && styles.active, + disabled && styles.disabled, + block && styles.block, + inheritColor && styles['inherit-color'], + ); + + const content = ( +
+ {icon && } + {children} +
+ ); + + if (to === undefined) { + return ( + + ); + } + if (URL_TEST_REG_EXP.test(to)) { + return ( + + {content} + + ); + } + + return ( + {content} + ); +}; + +Button.propTypes = { + theme: React.PropTypes.oneOf(['fill', 'border', 'link']), + size: React.PropTypes.oneOf(['small', 'middle']), + color: React.PropTypes.oneOf(['orange', 'blue', 'green', 'red']), + type: React.PropTypes.string, + active: React.PropTypes.bool, + disabled: React.PropTypes.bool, + block: React.PropTypes.bool, + inheritColor: React.PropTypes.bool, + to: React.PropTypes.string, + id: React.PropTypes.string, + icon: React.PropTypes.oneOf(icons), + onClick: React.PropTypes.func, +}; + +export default withStyles(styles)(Button); +export const ButtonsGroup = withStyles(styles)( + ({ children, ...props }) => (
+ { + React.Children.toArray(children).map((i, key) => +
{i}
+ ) + } +
) +); diff --git a/app/common/components/Button/index.spec.js b/app/common/components/Button/index.spec.js new file mode 100644 index 0000000..6d22fee --- /dev/null +++ b/app/common/components/Button/index.spec.js @@ -0,0 +1,87 @@ +import React from 'react'; +import chai, { expect } from 'chai'; +import { shallow, mount } from 'enzyme'; +import spies from 'chai-spies'; + +import Button from './index'; +import styles from './styles.scss'; + +chai.use(spies); + +describe('Button', () => { + it('children', () => { + const elem = shallow(); + expect(elem.contains(My button)).to.equal(true); + }); + + describe('props', () => { + const elem = shallow(