-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(check-language): add info bubble and store language in localStorage #526
Changes from 4 commits
150e095
fa16dd0
1446a2d
d6b6f47
7a2c045
acd09a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@require '../../../../variables.styl' | ||
|
||
.languageBubble | ||
position: absolute | ||
top: emCalc(50px) | ||
right: emCalc(-16px) | ||
display: flex | ||
flex-direction: column | ||
padding: emCalc(16px) | ||
width: fit-content | ||
height: fit-content | ||
border-radius: 4px | ||
background-color: $darkGrey4 | ||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.14), 0px 3px 4px rgba(0, 0, 0, 0.12), 0px 1px 5px rgba(0, 0, 0, 0.2) | ||
|
||
.infoBubble:before | ||
position: absolute | ||
right: emCalc(20px) | ||
bottom: 100% | ||
border-top-color: inherit | ||
border-right: 8px solid transparent | ||
border-bottom: 10px solid $darkGrey4 | ||
border-left: 8px solid transparent | ||
content: '' | ||
|
||
.language | ||
margin: 0 | ||
color: $textWhite | ||
font-size: emCalc(16px) | ||
font-family: Arial | ||
|
||
.buttons | ||
display: flex | ||
flex-direction: row | ||
justify-content: space-between | ||
padding-top: emCalc(16px) | ||
|
||
.keepLanguage, .changeLanguage | ||
color: $textColor | ||
text-align: left | ||
text-transform: uppercase | ||
font-size: emCalc(11px) | ||
font-family: NotesEsaBold | ||
|
||
.changeLanguage | ||
color: $textDefault |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, {FunctionComponent} from 'react'; | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import Button from '../button/button'; | ||
|
||
import styles from './language-bubble.styl'; | ||
|
||
interface Props { | ||
onClose: () => void; | ||
onMenuOpen: () => void; | ||
} | ||
|
||
const LanguageBubble: FunctionComponent<Props> = ({onClose, onMenuOpen}) => ( | ||
<div className={styles.languageBubble}> | ||
<p className={styles.language}> | ||
<FormattedMessage id={'detectedLanguage'} /> | ||
</p> | ||
<div className={styles.buttons}> | ||
<Button | ||
className={styles.changeLanguage} | ||
label="changeLanguage" | ||
onClick={() => onMenuOpen()} | ||
/> | ||
<Button | ||
className={styles.keepLanguage} | ||
label="keepLanguage" | ||
onClick={() => onClose()} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default LanguageBubble; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,5 +78,6 @@ export default { | |
'http://twitter.com/intent/tweet?text=ESA%20Climate%20From%20Space&url={currentUrl}' | ||
}, | ||
legendImage: `${baseUrlStorage}/legend-images/{variable}.png`, | ||
downloadUrls | ||
downloadUrls, | ||
localStorageLanguage: 'language' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the key and not the language itself. Please name it 'localStorageLanguageKey' |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import config from '../config/main'; | ||
|
||
import {Language} from '../types/language'; | ||
|
||
export default function getLocalStorageLanguage(): Language | null { | ||
const storedLanguage = localStorage.getItem(config.localStorageLanguage); | ||
const languages = Object.values(Language); | ||
|
||
const availableLanguage = | ||
storedLanguage && | ||
languages.find( | ||
language => | ||
language.substr(0, 2).toLowerCase() === | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need the substr stuff here. Unlike in the getBrowserLanguage function the language in the localStorage should match the defined languages exactly. |
||
storedLanguage.substr(0, 2).toLowerCase() | ||
); | ||
|
||
return availableLanguage || null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add this? Debugging I guess, please remove.