From fce0987c3de8014e6df46297963a14b08439bcf9 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Wed, 4 Sep 2019 20:47:29 +0100 Subject: [PATCH] Restyle legend --- app/src/frontend/components/icons.tsx | 8 ++- app/src/frontend/map/legend.css | 80 +++++++++++++++++---------- app/src/frontend/map/legend.tsx | 16 +++++- 3 files changed, 72 insertions(+), 32 deletions(-) diff --git a/app/src/frontend/components/icons.tsx b/app/src/frontend/components/icons.tsx index ee439af2..b660c13c 100644 --- a/app/src/frontend/components/icons.tsx +++ b/app/src/frontend/components/icons.tsx @@ -5,7 +5,7 @@ import React from 'react' import { library } from '@fortawesome/fontawesome-svg-core' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faQuestionCircle, faPaintBrush, faInfoCircle, faTimes, faCheck, faCheckDouble, - faAngleLeft, faCaretDown, faSearch, faEye } from '@fortawesome/free-solid-svg-icons' + faAngleLeft, faCaretDown, faSearch, faEye, faCaretUp } from '@fortawesome/free-solid-svg-icons' library.add( faQuestionCircle, @@ -16,6 +16,7 @@ library.add( faCheckDouble, faAngleLeft, faCaretDown, + faCaretUp, faSearch, faEye ); @@ -56,6 +57,10 @@ const DownIcon = () => ( ); +const UpIcon = () => ( + +); + const SearchIcon = () => ( ); @@ -70,5 +75,6 @@ export { SaveDoneIcon, BackIcon, DownIcon, + UpIcon, SearchIcon }; diff --git a/app/src/frontend/map/legend.css b/app/src/frontend/map/legend.css index 01f5dedd..c21b1a31 100644 --- a/app/src/frontend/map/legend.css +++ b/app/src/frontend/map/legend.css @@ -2,28 +2,53 @@ * Map legend */ .map-legend { - z-index: 1000; position: absolute; - bottom: 50%; + bottom: 2.5rem; right: 10px; + z-index: 1000; + min-width: 12rem; - float: right; + max-height: 50%; + display: flex; + flex-direction: column; + background: white; border-radius: 4px; padding: 0.5rem 0rem 0.25rem; border: 1px solid #fff; box-shadow: 0px 0px 1px 1px #222222; } -@media (min-width: 768px){ - .map-legend { - bottom: 40px; + +.map-legend * { + flex: 0; +} + +.map-legend .logo { + display: none; +} +@media (min-width: 768px) { + .map-legend .logo { + display: block; } } -@media (min-width: 1020px){ + +/* Prevent legend from overlapping with attribution */ +@media (min-width: 706px){ .map-legend { - bottom: 24px; + bottom: 1.5rem; } } +@media (min-width: 768px) { + .map-legend { + bottom: 2.5rem; + } +} +@media (min-width: 1072px){ + .map-legend { + bottom: 1.5rem; + } +} + .map-legend .h4, .map-legend p, .data-legend { @@ -33,30 +58,12 @@ margin: 0.25rem 0 0.5rem; } .data-legend { - max-height: 80px; - max-height: 20vh; - overflow-y: auto; + overflow: scroll; list-style: none; margin-bottom: 0; + flex: 1; } -@media (min-height: 470px) { - .data-legend { - max-height: 150px; - max-height: 30vh; - } -} -@media (min-height: 550px) { - .data-legend { - max-height: 220px; - max-height: 40vh; - } -} -@media (min-height: 670px) { - .data-legend { - max-height: 330px; - max-height: 50vh; - } -} + .data-legend .key { display: inline-block; width: 1.3rem; @@ -71,7 +78,20 @@ opacity: 0.5; } .expander-button { - float: right; + display: inline-block; + position: absolute; + bottom: 1rem; + right: 1rem; + + height: 1rem; + width: 1rem; + line-height: 0.5; + padding: 0; +} +.expander-button:focus, +.expander-button:active, +.expander-button:hover { + box-shadow: none; } @media (min-height: 670px) and (min-width: 768px) { .expander-button { diff --git a/app/src/frontend/map/legend.tsx b/app/src/frontend/map/legend.tsx index eb2016fb..6fc41e40 100644 --- a/app/src/frontend/map/legend.tsx +++ b/app/src/frontend/map/legend.tsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import './legend.css'; import { MinorLogo } from '../components/logo'; +import { DownIcon, UpIcon, BackIcon } from '../components/icons'; const LEGEND_CONFIG = { location: { @@ -147,7 +148,20 @@ class Legend extends React.Component { // TODO: add proper types return (
-

{ title } {elements.length?:null}

+

+ { title } +

+ { + elements.length > 0 ? + : + null + } { details.description?

{details.description}