Skip to content

Commit

Permalink
feat: improve mobile support for forest type description
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Sep 14, 2020
1 parent fe8c70f commit 34f05f1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/ForestTypeDescription/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getStyle } from './utils';
function Site({ altitude, aspect, slope }) {
const { t } = useTranslation();
return (
<svg viewBox="0 0 400 400" style={{ margin: '20px 200px 0px' }}>
<svg viewBox="0 0 800 400" style={{ marginTop: '20px' }}>
<path
className={getStyle(aspect, '15')}
d="M303.1 312.4L282 265.6c6-2.9 13.1-4.5 21.2-4.5v51.3z"
Expand Down
4 changes: 3 additions & 1 deletion src/components/ForestTypeDescription/TerrainTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { Table } from 'semantic-ui-react';
import AltitudinalZone from './AltitudinalZoneForestEcoregion';
import Legend from './Legend';
import Site from './Site';
import useIsMobile from '../../hooks/useIsMobile';

function TerrainTab({ data }) {
const isMobile = useIsMobile();
const { t } = useTranslation();

return (
<>
<Legend />
<AltitudinalZone data={data.altitudinalZoneForestEcoregion} />
<Site altitude={data.altitude} aspect={data.aspect} slope={data.slope} />
<Table basic padded structured unstackable>
<Table basic padded={isMobile === false} structured unstackable>
<Table.Body>
<Table.Row>
<Table.HeaderCell rowSpan="2">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ForestTypeDescription/VegetationTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function VegetationTab({ data }) {
};

return (
<Table basic padded structured unstackable>
<Table basic padded structured>
<Table.Body>
<Table.Row>
<Table.HeaderCell>{t('forestType.naturalForest')}</Table.HeaderCell>
Expand Down
16 changes: 10 additions & 6 deletions src/components/ForestTypeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Modal } from 'semantic-ui-react';
import Button from './Button';
import ForestTypeDescription from './ForestTypeDescription';

function ForestTypeModal({ compact, data, setIsForestTypeModalOpen }) {
function ForestTypeModal({ data, setIsForestTypeModalOpen }) {
const { i18n } = useTranslation();

return (
Expand All @@ -22,21 +22,25 @@ function ForestTypeModal({ compact, data, setIsForestTypeModalOpen }) {
{data.code} - {data[i18n.language]} (<i>{data.la}</i>)
</Modal.Header>
}
onClose={() => setIsForestTypeModalOpen(false)}
onOpen={() => setIsForestTypeModalOpen(true)}
trigger={<Button active compact={compact} icon="info" />}
onClose={(e) => {
e.stopPropagation();
setIsForestTypeModalOpen(false);
}}
onOpen={(e) => {
e.stopPropagation();
setIsForestTypeModalOpen(true);
}}
trigger={<Button active icon="info" />}
/>
);
}

ForestTypeModal.propTypes = {
compact: PropTypes.bool,
data: PropTypes.arrayOf().isRequired,
setIsForestTypeModalOpen: PropTypes.func,
};

ForestTypeModal.defaultProps = {
compact: false,
setIsForestTypeModalOpen: () => null,
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/LocationResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function LocationResult() {
<Dropdown.Item
content={
<>
<ForestTypeModal compact data={ftInfo} />
<ForestTypeModal data={ftInfo} />
{key} - {ftInfo[i18n.language]}
</>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getDropdownOptions = (type, lng, includeKey = false) => (key) => ({
key,
content: includeKey ? (
<>
<ForestTypeModal compact data={info(type, key)} />
<ForestTypeModal data={info(type, key)} />
{key} - {info(type, key)[lng]}
</>
) : (
Expand Down

0 comments on commit 34f05f1

Please sign in to comment.