From f8201da28390d1076cf85d1244b9be25e3f6e138 Mon Sep 17 00:00:00 2001
From: Tom Russell
Date: Mon, 1 Oct 2018 00:32:24 +0100
Subject: [PATCH] Create component for section in building-view
---
app/src/frontend/building-view.js | 97 +++++++++++++++----------------
app/src/frontend/styles/forms.css | 3 +
2 files changed, 49 insertions(+), 51 deletions(-)
diff --git a/app/src/frontend/building-view.js b/app/src/frontend/building-view.js
index 8dbeebd1..e06c1d1b 100644
--- a/app/src/frontend/building-view.js
+++ b/app/src/frontend/building-view.js
@@ -1,10 +1,24 @@
-import React, { Fragment } from 'react';
+import React from 'react';
import { Link, NavLink } from 'react-router-dom';
import Sidebar from './sidebar';
import Tooltip from './tooltip';
import InfoBox from './info-box';
+
+const DataSection = function(props){
+ const match = props.hash && props.slug.match(props.hash);
+ return (
+
+ match}>
+ {props.title}
+
+ { (match)? props.children : null }
+
+ );
+}
+
const BuildingView = function(props){
if (!props.building_id){
return (
@@ -16,49 +30,36 @@ const BuildingView = function(props){
);
}
- const hash = (props.location && props.location.hash)? props.location.hash: undefined;
+ const hash = (props.location && props.location.hash)? props.location.hash.replace('#', ''): undefined;
return (
-
-
- Location
-
- {
- ( hash.match('location') )
- ? (
-
-
+
+
- Section introduction of up to roughly 100 characters will take
- approximately this much space.
+ Section introduction of up to roughly 100 characters will take
+ approximately this much space.
- Read more .
-
-
-
- Building Name
-
-
- {props.location_name ? props.location_name : '-'}
- Building Number
- {props.location_number ? props.location_number : '-'}
- Street
- {props.location_street ? props.location_street : '-'}
- Address line 2
- {props.location_line_two ? props.location_line_two : '-'}
- Town
- {props.location_town ? props.location_town : '-'}
- Postcode
- {props.location_postcode ? props.location_postcode : '-'}
-
-
- ) : null
- }
-
-
+
+
+ Building Name
+
+
+ {props.location_name ? props.location_name : '-'}
+ Building Number
+ {props.location_number ? props.location_number : '-'}
+ Street
+ {props.location_street ? props.location_street : '-'}
+ Address line 2
+ {props.location_line_two ? props.location_line_two : '-'}
+ Town
+ {props.location_town ? props.location_town : '-'}
+ Postcode
+ {props.location_postcode ? props.location_postcode : '-'}
+
+
+
Year built (best estimate)
{props.date_year? props.date_year : '-'}
@@ -71,11 +72,8 @@ const BuildingView = function(props){
Facade date
{props.date_facade? props.date_facade : '-'}
-
-
+
Attic storeys
{props.size_storeys_attic? props.size_storeys_attic : '-'}
@@ -84,16 +82,13 @@ const BuildingView = function(props){
Basement storeys
{props.size_storeys_basement? props.size_storeys_basement : '-'}
-
-
+
Likes
{props.likes ? props.likes.length : 0}
-
+
Back to maps
Edit data
diff --git a/app/src/frontend/styles/forms.css b/app/src/frontend/styles/forms.css
index 53e2d2c8..e010a481 100644
--- a/app/src/frontend/styles/forms.css
+++ b/app/src/frontend/styles/forms.css
@@ -21,6 +21,9 @@ label {
.buttons-container {
margin-bottom: 0.75rem;
}
+.info-container .buttons-container {
+ padding: 0 0.75rem;
+}
.buttons-container .btn {
margin-bottom: 0.25rem;
margin-right: 0.25rem;