From fe621443b72f6a2432345d3f424371f03c2214e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 16 Jul 2018 14:10:04 +0200 Subject: [PATCH] feat(ui): add tabs to the modal --- ui/src/Components/MainModal/Help.js | 2 +- ui/src/Components/MainModal/index.css | 3 ++ ui/src/Components/MainModal/index.js | 56 ++++++++++++++++++++++----- 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 ui/src/Components/MainModal/index.css diff --git a/ui/src/Components/MainModal/Help.js b/ui/src/Components/MainModal/Help.js index ceabe6d56..55a5150be 100644 --- a/ui/src/Components/MainModal/Help.js +++ b/ui/src/Components/MainModal/Help.js @@ -53,7 +53,7 @@ const FilterExample = ({ example, children }) => ( ); FilterExample.propTypes = { example: PropTypes.string.isRequired, - children: PropTypes.array + children: PropTypes.node }; const Help = () => ( diff --git a/ui/src/Components/MainModal/index.css b/ui/src/Components/MainModal/index.css new file mode 100644 index 000000000..cf0d60061 --- /dev/null +++ b/ui/src/Components/MainModal/index.css @@ -0,0 +1,3 @@ +.modal-header .close { + line-height: 1.6; +} diff --git a/ui/src/Components/MainModal/index.js b/ui/src/Components/MainModal/index.js index 46e0fcf7b..876f214cc 100644 --- a/ui/src/Components/MainModal/index.js +++ b/ui/src/Components/MainModal/index.js @@ -1,4 +1,5 @@ import React, { Component } from "react"; +import PropTypes from "prop-types"; import { observer } from "mobx-react"; import { observable, action } from "mobx"; @@ -8,6 +9,27 @@ import { faCog } from "@fortawesome/free-solid-svg-icons/faCog"; import { Help } from "./Help"; +import "./index.css"; + +const Tab = ({ title, active, onClick }) => ( + + {title} + +); +Tab.propTypes = { + title: PropTypes.string.isRequired, + active: PropTypes.bool, + onClick: PropTypes.func.isRequired +}; + +const TabNames = Object.freeze({ + Settings: "settings", + Help: "help" +}); + const MainModal = observer( class MainModal extends Component { toggle = observable( @@ -23,6 +45,16 @@ const MainModal = observer( { toggle: action.bound, hide: action.bound } ); + tab = observable( + { + current: TabNames.Settings, + setTab(newTab) { + this.current = newTab; + } + }, + { setTab: action.bound } + ); + componentDidUpdate() { document.body.classList.toggle("modal-open", this.toggle.show); } @@ -39,8 +71,6 @@ const MainModal = observer( @@ -50,25 +80,33 @@ const MainModal = observer( {this.toggle.show ? (
-
-
Help
+
+
- + {this.tab.current === TabNames.Help ? : null}