Skip to content

Commit

Permalink
feat: replace forest type button with forest type modal
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Sep 9, 2020
1 parent f7e8acb commit 347150a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
28 changes: 0 additions & 28 deletions src/components/ForestTypeButton.js

This file was deleted.

13 changes: 9 additions & 4 deletions src/components/ForestTypeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { Modal } from 'semantic-ui-react';
import Button from './Button';
import ForestTypeDescription from './ForestTypeDescription';

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

return (
<Modal
open
actions={[{ key: 'done', content: 'Ok' }]}
content={
<Modal.Content>
Expand All @@ -21,14 +20,20 @@ function ForestTypeModal({ data, setIsForestTypeModalOpen }) {
header={`${data.code} - ${data[i18n.language]} (${data.la})`}
onClose={() => setIsForestTypeModalOpen(false)}
onOpen={() => setIsForestTypeModalOpen(true)}
trigger={<Button active icon="info" />}
trigger={<Button active compact={compact} icon="info" />}
/>
);
}

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

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

export default ForestTypeModal;
7 changes: 4 additions & 3 deletions src/components/LocationResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { info } from 'lib/src';

import Dropdown from './Dropdown';
import Ecogram from './Ecogram';
import ForestTypeButton from './ForestTypeButton';
import ForestTypeModal from './ForestTypeModal';
import HelpModal from './HelpModal';
import { setFormLocation } from '../store/actions';
import styles from './LocationResult.module.css';
Expand Down Expand Up @@ -71,12 +71,13 @@ function LocationResult() {
<>
<Dropdown.Header content={t(`forestType.group.${group}`)} />
{forestTypes[group].map((key) => {
const ftInfo = info('forestType', key);
return (
<Dropdown.Item
content={
<>
<ForestTypeButton code={key} compact />
{key} - {info('forestType', key)[i18n.language]}
<ForestTypeModal compact data={ftInfo} />
{key} - {ftInfo[i18n.language]}
</>
}
value={key}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProjectionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { info } from 'lib/src';

import ChoiceButton from './ChoiceButton';
import Dropdown from './Dropdown';
import ForestTypeButton from './ForestTypeButton';
import ForestTypeModal from './ForestTypeModal';
import { setFormLocation } from '../store/actions';
import styles from './ProjectionForm.module.css';

Expand All @@ -22,7 +22,7 @@ const getDropdownOptions = (type, lng, includeKey = false) => (key) => ({
key,
content: includeKey ? (
<>
<ForestTypeButton code={key} compact />
<ForestTypeModal compact data={info(type, key)} />
{key} - {info(type, key)[lng]}
</>
) : (
Expand Down

0 comments on commit 347150a

Please sign in to comment.