colouring-montreal/app/src/frontend/legend.js

121 lines
3.2 KiB
JavaScript
Raw Normal View History

2018-11-29 17:00:53 -05:00
import React from 'react';
2018-09-10 07:41:00 -04:00
2018-10-02 16:47:59 -04:00
import './legend.css';
2018-09-11 15:59:37 -04:00
2018-10-04 17:50:33 -04:00
const LEGEND_CONFIG = {
2018-12-03 04:35:14 -05:00
location: {
title: "Location",
elements: [
2018-11-29 17:00:53 -05:00
{ color: '#f0f9e8', text: '>5' },
{ color: '#bae4bc', text: '4' },
{ color: '#7bccc4', text: '3' },
{ color: '#43a2ca', text: '2' },
{ color: '#0868ac', text: '1' }
2018-12-03 04:35:14 -05:00
]
},
age: {
title: "Age",
elements: [
2018-11-29 17:00:53 -05:00
{ color: '#f0eaba', text: '≥2000' },
{ color: '#fae269', text: '19802000' },
{ color: '#fbaf27', text: '19601980' },
{ color: '#e6711d', text: '19401960' },
{ color: '#d73d3a', text: '19201940' },
{ color: '#ba221c', text: '19001920' },
{ color: '#bb859b', text: '18801900' },
{ color: '#8b3654', text: '18601880' },
{ color: '#8f5385', text: '18401860' },
{ color: '#56619b', text: '18201840' },
{ color: '#6793b2', text: '18001820' },
{ color: '#83c3b3', text: '17801800' },
{ color: '#adc88f', text: '17601780' },
{ color: '#83a663', text: '17401760' },
{ color: '#77852d', text: '17201740' },
{ color: '#69814e', text: '17001720' },
{ color: '#d0c291', text: '16801700' },
{ color: '#918158', text: '16601680' },
{ color: '#7a5732', text: '<1660' },
2018-12-03 04:35:14 -05:00
]
},
size: {
title: "Size & Shape",
elements: [
2018-11-29 17:00:53 -05:00
{ color: '#ffffcc', text: '≥20' },
{ color: '#ffeda0', text: '15-20' },
{ color: '#fed976', text: '1015' },
{ color: '#feb24c', text: '610' },
{ color: '#fd8d3c', text: '5' },
{ color: '#fc4e2a', text: '4' },
{ color: '#e31a1c', text: '3' },
{ color: '#bd0026', text: '2' },
{ color: '#800026', text: '1' },
2018-12-03 04:35:14 -05:00
]
},
like: {
title: "Like Me",
elements: [
2018-11-29 17:00:53 -05:00
{ color: '#f65400', text: 'We like these buildings 👍 🎉 +1' },
2018-12-03 04:35:14 -05:00
]
},
use: {
title: "Use",
elements: []
},
type: {
title: "Type",
elements: []
},
construction: {
title: "Construction",
elements: []
},
team: {
title: "Team",
elements: []
},
sustainability: {
title: "Sustainability",
elements: []
},
greenery: {
title: "Greenery",
elements: []
},
planning: {
title: "Planning",
elements: []
},
demolition: {
title: "Demolition",
elements: []
}
2018-10-04 17:50:33 -04:00
};
const Legend = (props) => {
2018-12-03 04:35:14 -05:00
const details = LEGEND_CONFIG[props.slug];
const title = details.title;
const elements = details.elements;
2018-10-04 17:50:33 -04:00
return (
2018-12-03 04:35:14 -05:00
<div className="map-legend">
<h4 className="h4">{ title }</h4>
<ul className="data-legend">
{
elements.map((data_item) => (
<LegendItem {...data_item} key={data_item.color} />
))
}
</ul>
</div>
2018-10-04 17:50:33 -04:00
);
}
const LegendItem = (props) => (
<li>
<span className="key" style={ { background: props.color } }>-</span>
{ props.text }
</li>
2018-09-10 16:49:58 -04:00
);
2018-09-10 07:41:00 -04:00
export default Legend;