-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(check-language): add info bubble and store language in localStor…
…age (#526) * feat(check-language): add info bubble and store language in localStorage * refactor(check-language): store localStorage language in state * refactor(language): sort imports * feat(check-language): rename variable, remove substr
- Loading branch information
1 parent
9a9047f
commit ea694d8
Showing
13 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/scripts/components/main/language-bubble/language-bubble.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
33 changes: 33 additions & 0 deletions
33
src/scripts/components/main/language-bubble/language-bubble.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import config from '../config/main'; | ||
|
||
import {Language} from '../types/language'; | ||
|
||
export default function getLocalStorageLanguage(): Language | null { | ||
const storedLanguage = localStorage.getItem(config.localStorageLanguageKey); | ||
const languages = Object.values(Language); | ||
|
||
const availableLanguage = | ||
storedLanguage && languages.find(language => language === storedLanguage); | ||
|
||
return availableLanguage || null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters