Skip to content

Commit

Permalink
feat(remove-compare): add remove compare data set button (#193)
Browse files Browse the repository at this point in the history
* feat(data-set-info): display data set info in data mode

* refactor(data-set-info): use reduce instead of forEach

* style(data-set-info): remove console.log

* refactor(data-set-info): add layer selector, rename selectedLayerSelector to selectedLayerIdsSelector

* style(layer-selector): remove curly braces

* refactor(selectors): move all selectors to separate folder

* refactor(globes): rename selector const

* refactor(layer-loader): rename selector const

* feat(remove-compare): add remove compare-globe button
  • Loading branch information
KatvonRivia authored Nov 13, 2019
1 parent 4f95cc4 commit 102ff78
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 7 deletions.
1 change: 1 addition & 0 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"share": "Inhalt teilen",
"export": "Daten exportieren",
"info": "Weitere Informationen",
"remove-compare": "Vergleich entfernen",
"data-info": "Dateninformation"
}
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"share": "Share Content",
"export": "Export Data",
"info": "More Information",
"remove-compare": "Remove Compare",
"data-info": "Data Information"
}
5 changes: 5 additions & 0 deletions src/scripts/components/data-set-info/data-set-info.styl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
margin-top: 0
color: #fff
font-size: 1em

.buttons
display: flex
flex-direction: row
align-self: center
15 changes: 8 additions & 7 deletions src/scripts/components/data-set-info/data-set-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {FunctionComponent} from 'react';
import {useSelector} from 'react-redux';

import {selectedLayersSelector} from '../../selectors/layers/selected';
import RemoveCompare from '../remove-compare/remove-compare';
import InfoButton from '../info-button/info-button';

import styles from './data-set-info.styl';
Expand All @@ -12,16 +13,16 @@ interface Props {

const DataSetInfo: FunctionComponent<Props> = ({isMain}) => {
const {main, compare} = useSelector(selectedLayersSelector);
const layer = isMain ? main : compare;

return (
<div className={styles.dataSetInfo}>
<h1 className={styles.title}>
{isMain ? main && main.name : compare && compare.name}
</h1>
<h2 className={styles.description}>
{isMain ? main && main.description : compare && compare.description}
</h2>
<InfoButton layer={main || compare} />
<h1 className={styles.title}>{layer && layer.name}</h1>
<h2 className={styles.description}>{layer && layer.description}</h2>
<div className={styles.buttons}>
<InfoButton layer={layer} />
{!isMain && <RemoveCompare />}
</div>
</div>
);
};
Expand Down
12 changes: 12 additions & 0 deletions src/scripts/components/icons/remove-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, {FunctionComponent} from 'react';

export const RemoveIcon: FunctionComponent = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24">
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
<path d="M0 0h24v24H0z" fill="none" />
</svg>
);
15 changes: 15 additions & 0 deletions src/scripts/components/remove-compare/remove-compare.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.removeCompare
display: flex
flex-direction: column

.icon
padding: 2px
outline: 0
border: none
border-radius: 50%
background-color: transparent
line-height: 50%
cursor: pointer

svg
fill: #fff
30 changes: 30 additions & 0 deletions src/scripts/components/remove-compare/remove-compare.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, {FunctionComponent} from 'react';
import {useDispatch} from 'react-redux';
import {useIntl} from 'react-intl';

import setSelectedLayerIdsAction from '../../actions/set-selected-layer-ids';
import {RemoveIcon} from '../icons/remove-icon';

import styles from './remove-compare.styl';

const RemoveCompare: FunctionComponent = () => {
const intl = useIntl();
const dispatch = useDispatch();

const onButtonClick = () => {
dispatch(setSelectedLayerIdsAction(null, false));
};

return (
<div className={styles.removeCompare}>
<button
className={styles.icon}
title={intl.formatMessage({id: 'remove-compare'})}
onClick={onButtonClick}>
<RemoveIcon />
</button>
</div>
);
};

export default RemoveCompare;
6 changes: 6 additions & 0 deletions storage/layers/layers-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"link": "http://...",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
"description": "Das ist der dritte Layer",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
Expand Down
6 changes: 6 additions & 0 deletions storage/layers/layers-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"link": "http://...",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
"description": "This is the third layer",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
Expand Down
6 changes: 6 additions & 0 deletions storage/layers/layers-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
"link": "http://...",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
"description": "Das ist der dritte Layer",
"subLayers": []
},
{
"id": "layer3",
"name": "Layer 3",
Expand Down

0 comments on commit 102ff78

Please sign in to comment.