From 506bab56edfcd7fa28d0df95f6340cabf6b3b8c4 Mon Sep 17 00:00:00 2001 From: Friedjoff Trautwein Date: Thu, 19 Mar 2020 10:00:41 +0100 Subject: [PATCH] feat: improve styling for ecogram --- src/components/Ecogram.js | 72 ++++++++++++++++++------------- src/components/Ecogram.module.css | 33 ++++++++++++++ 2 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 src/components/Ecogram.module.css diff --git a/src/components/Ecogram.js b/src/components/Ecogram.js index 2e09df24..407ae2e2 100644 --- a/src/components/Ecogram.js +++ b/src/components/Ecogram.js @@ -4,6 +4,8 @@ import { useDispatch, useSelector } from 'react-redux'; import { setForestTypes } from '../store/actions'; +import styles from './Ecogram.module.css'; + function Ecogram() { const dispatch = useDispatch(); const { ecogram } = useSelector(state => state.locateResult); @@ -16,50 +18,59 @@ function Ecogram() { return ( - - - - - - - + + + + + + {ecogram .sort((a, b) => a.z - b.z) - .map(({ x, y, w, h, f }) => ( + .map(({ x, y, w, h, f, r }) => ( <> dispatch(setForestTypes(f))} /> - - {f.join(' ')} - + {r ? ( + [...new Array(r)].map((_, i) => ( + + {f + .slice( + Math.floor(f.length / r) * i, + Math.floor(f.length / r) * (i + 1), + ) + .join(' ')} + + )) + ) : ( + + {f.join(' ')} + + )} ))} + {t('ecogram.dry')} @@ -67,15 +78,14 @@ function Ecogram() { x="-820" y="80" transform="rotate(270,100,100)" - fontSize="2em" - textAnchor="middle" + className={styles.label} > {t('ecogram.wet')} - + {t('ecogram.acid')} - + {t('ecogram.alkaline')} diff --git a/src/components/Ecogram.module.css b/src/components/Ecogram.module.css new file mode 100644 index 00000000..cfa44a57 --- /dev/null +++ b/src/components/Ecogram.module.css @@ -0,0 +1,33 @@ +.box { + cursor: pointer; + fill: var(--primary-color-500); + stroke: white; + stroke-width: 2; +} +.box:hover { + fill: var(--primary-color-200); +} + +.boxText { + pointer-events: none; + fill: white; + font-size: 2em; + text-anchor: middle; +} + +.frame { + pointer-events: none; + fill: transparent; + stroke: #999999; + stroke-width: 2; +} + +.grid { + stroke: var(--primary-color-100); +} + +.label { + fill: #999999; + font-size: 2em; + text-anchor: middle; +}