Restyle legend

This commit is contained in:
Maciej Ziarkowski 2019-09-04 20:47:29 +01:00
parent 05238b5963
commit fce0987c3d
3 changed files with 72 additions and 32 deletions

View File

@ -5,7 +5,7 @@ import React from 'react'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faQuestionCircle, faPaintBrush, faInfoCircle, faTimes, faCheck, faCheckDouble, 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( library.add(
faQuestionCircle, faQuestionCircle,
@ -16,6 +16,7 @@ library.add(
faCheckDouble, faCheckDouble,
faAngleLeft, faAngleLeft,
faCaretDown, faCaretDown,
faCaretUp,
faSearch, faSearch,
faEye faEye
); );
@ -56,6 +57,10 @@ const DownIcon = () => (
<FontAwesomeIcon icon="caret-down" /> <FontAwesomeIcon icon="caret-down" />
); );
const UpIcon = () => (
<FontAwesomeIcon icon="caret-up" />
);
const SearchIcon = () => ( const SearchIcon = () => (
<FontAwesomeIcon icon="search" /> <FontAwesomeIcon icon="search" />
); );
@ -70,5 +75,6 @@ export {
SaveDoneIcon, SaveDoneIcon,
BackIcon, BackIcon,
DownIcon, DownIcon,
UpIcon,
SearchIcon SearchIcon
}; };

View File

@ -2,28 +2,53 @@
* Map legend * Map legend
*/ */
.map-legend { .map-legend {
z-index: 1000;
position: absolute; position: absolute;
bottom: 50%; bottom: 2.5rem;
right: 10px; right: 10px;
z-index: 1000;
min-width: 12rem; min-width: 12rem;
float: right; max-height: 50%;
display: flex;
flex-direction: column;
background: white; background: white;
border-radius: 4px; border-radius: 4px;
padding: 0.5rem 0rem 0.25rem; padding: 0.5rem 0rem 0.25rem;
border: 1px solid #fff; border: 1px solid #fff;
box-shadow: 0px 0px 1px 1px #222222; box-shadow: 0px 0px 1px 1px #222222;
} }
@media (min-width: 768px){
.map-legend { .map-legend * {
bottom: 40px; 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 { .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 .h4,
.map-legend p, .map-legend p,
.data-legend { .data-legend {
@ -33,30 +58,12 @@
margin: 0.25rem 0 0.5rem; margin: 0.25rem 0 0.5rem;
} }
.data-legend { .data-legend {
max-height: 80px; overflow: scroll;
max-height: 20vh;
overflow-y: auto;
list-style: none; list-style: none;
margin-bottom: 0; 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 { .data-legend .key {
display: inline-block; display: inline-block;
width: 1.3rem; width: 1.3rem;
@ -71,7 +78,20 @@
opacity: 0.5; opacity: 0.5;
} }
.expander-button { .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) { @media (min-height: 670px) and (min-width: 768px) {
.expander-button { .expander-button {

View File

@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import './legend.css'; import './legend.css';
import { MinorLogo } from '../components/logo'; import { MinorLogo } from '../components/logo';
import { DownIcon, UpIcon, BackIcon } from '../components/icons';
const LEGEND_CONFIG = { const LEGEND_CONFIG = {
location: { location: {
@ -147,7 +148,20 @@ class Legend extends React.Component<any, any> { // TODO: add proper types
return ( return (
<div className="map-legend"> <div className="map-legend">
<MinorLogo /> <MinorLogo />
<h4 className="h4">{ title } {elements.length?<button className="expander-button btn btn-outline-secondary btn-sm" type="button" onClick={this.handleClick} >^</button>:null}</h4> <h4 className="h4">
{ title }
</h4>
{
elements.length > 0 ?
<button className="expander-button btn btn-outline-secondary btn-sm" type="button" onClick={this.handleClick} >
{
this.state.collapseList ?
<UpIcon /> :
<DownIcon />
}
</button> :
null
}
{ {
details.description? details.description?
<p>{details.description} </p> <p>{details.description} </p>