From a012b24bd1f424a7ce7e5b1157a8b3d073cebf65 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Mon, 1 Oct 2018 16:59:39 +0100 Subject: [PATCH] Use icon buttons for edit/info/tooltip --- app/src/frontend/building-view.js | 89 ++++++++++++++++++++----------- app/src/frontend/icons.js | 3 +- app/src/frontend/main.css | 45 ++++++++++++++++ app/src/frontend/tooltip.css | 40 ++++++-------- app/src/frontend/tooltip.js | 49 +++++++++++++---- 5 files changed, 161 insertions(+), 65 deletions(-) diff --git a/app/src/frontend/building-view.js b/app/src/frontend/building-view.js index f57bd150..2e2eb45c 100644 --- a/app/src/frontend/building-view.js +++ b/app/src/frontend/building-view.js @@ -4,25 +4,40 @@ import { Link, NavLink } from 'react-router-dom'; import Sidebar from './sidebar'; import Tooltip from './tooltip'; import InfoBox from './info-box'; +import { InfoIcon, EditIcon } from './icons'; const DataSection = function(props){ const match = props.hash && props.slug.match(props.hash); return (
- match}> -

{props.title}

-
+
match}> + +

{props.title}

+
+ { + props.helpLink? + + + + : null + } + { + !props.inactive? + + + + : null + } +
{ (match)? props.children : null } - { + { (match && !props.inactive)?
- Back to maps - Edit data + Edit data
: null - }
+ }
); } @@ -41,13 +56,13 @@ const BuildingView = function(props){ const hash = (props.location && props.location.hash)? props.location.hash.replace('#', ''): undefined; return ( - +

Section introduction of up to roughly 100 characters will take approx­imately this much space. - Read more.

@@ -67,13 +82,16 @@ const BuildingView = function(props){
{props.location_postcode ? props.location_postcode : '-'}
- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- +
Year built (best estimate)
{props.date_year? props.date_year : '-'}
@@ -87,7 +105,8 @@ const BuildingView = function(props){
{props.date_facade? props.date_facade : '-'}
- +
Total storeys
{(props.size_storeys_attic + props.size_storeys_basement + props.size_storeys_core)}
@@ -107,28 +126,36 @@ const BuildingView = function(props){
{props.size_width_frontage? props.size_width_frontage : '-'}
- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- -

Coming soon…

+ +

Coming soon… Click the ? for more info.

- +
Likes
{props.likes ? props.likes.length : 0}
diff --git a/app/src/frontend/icons.js b/app/src/frontend/icons.js index 2f7d3cd1..c608f58c 100644 --- a/app/src/frontend/icons.js +++ b/app/src/frontend/icons.js @@ -4,7 +4,8 @@ import React from 'react' import { library } from '@fortawesome/fontawesome-svg-core' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faQuestionCircle, faPaintBrush, faInfoCircle, faTimes, faCheck, faAngleLeft, faCaretDown } from '@fortawesome/free-solid-svg-icons' +import { faQuestionCircle, faPaintBrush, faInfoCircle, faTimes, faCheck, faCheckDouble, + faAngleLeft, faCaretDown } from '@fortawesome/free-solid-svg-icons' library.add( faQuestionCircle, diff --git a/app/src/frontend/main.css b/app/src/frontend/main.css index eb7911bf..4a6adbe1 100755 --- a/app/src/frontend/main.css +++ b/app/src/frontend/main.css @@ -53,6 +53,50 @@ .bullet-prefix.active:hover::before { content: '\25A0'; } + +.icon-button { + display: inline-block; + width: 1.8rem; + height: 1.8rem; + padding: 0; + outline: none; + border: none; + border-radius: 0.9rem; + margin: 0 0.05rem; + + background-color: transparent; + transition: background-color 0.2s; + + color: #222; + vertical-align: top; + text-align: center; +} +.icon-button svg { + transition: color 0.2s; + color: #222; + margin-top: 2px; + width: 1rem; + height: 1rem; + display: inline-block; + vertical-align: middle; +} +.icon-button:hover { + background-color: #fff; +} +.icon-button.edit:hover svg { + color: rgb(11, 247, 255); +} +.icon-button.help:hover svg { + color: rgb(255, 11, 222); +} +.icon-button.tooltip-hint:hover svg { + color: rgb(11, 255, 72); +} +.section-header .icon-button { + float: right; + margin-top: -2px; +} + .data-section { border-top: 1px solid #ffffff; } @@ -73,6 +117,7 @@ .data-list { margin: 0; padding-left: 0.75rem; + padding-right: 0.5rem; } .legend .data-list { padding-left: 2.25rem; diff --git a/app/src/frontend/tooltip.css b/app/src/frontend/tooltip.css index 77a01b22..5dbb347e 100644 --- a/app/src/frontend/tooltip.css +++ b/app/src/frontend/tooltip.css @@ -1,30 +1,24 @@ -.tooltip-hook { - display: inline-block; - position: relative; +.tooltip-hint { cursor: pointer; - color: #222; - background: #fff; - border: 1px solid #222; - width: 22px; - height: 22px; - border-radius: 11px; - padding: 0 0 0 1px; - font-size: 0.8rem; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; - text-align: center; +} +.tooltip-wrap { + float: right; + position: relative; + top: -5px; +} +.tooltip-wrap .icon-button svg { + width: 1rem; + height: 1rem; + margin-top: -2px; } .tooltip { - display: none; + text-transform: none; + text-align: left; + width: 11em; + right: 0; + top: 27px; opacity: 1; - min-width: 11em; - left: -3px; - top: 25px; } .tooltip .arrow { - left: 5px; -} -.tooltip-hook:hover .tooltip, -.tooltip-hook:hover + .tooltip { - display: block; - opacity: 1; + right: 7px; } diff --git a/app/src/frontend/tooltip.js b/app/src/frontend/tooltip.js index 8de7c925..b9b99949 100644 --- a/app/src/frontend/tooltip.js +++ b/app/src/frontend/tooltip.js @@ -1,15 +1,44 @@ -import React from 'react'; +import React, { Component, Fragment } from 'react'; import './tooltip.css'; +import { HelpIcon } from './icons'; -const Tooltip = (props) => ( - - ? -
-
-
{props.text}
-
-
-); +class Tooltip extends Component { + constructor(props) { + super(props); + this.state = { + active: false + }; + this.handleClick = this.handleClick.bind(this); + } + handleClick(event) { + event.preventDefault(); + this.setState({ + active: !this.state.active + }); + } + + render() { + console.log(this.state, this.props) + return ( +
+ + { + this.state.active? + ( +
+
+
{this.props.text}
+
+ ) + : null + } +
+ ); + } +} export default Tooltip;