-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lk/learning language selection (#1299)
* feat: add language selection chore: update tests so we have less error message test: update test * test: update tests * chore: remove duplicate translation * chore: lint for console * chore: remove comments * chore: make sure the affect url frame refresh after the language selection change
- Loading branch information
1 parent
ff7366d
commit 60ae8b3
Showing
41 changed files
with
9,818 additions
and
11,039 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
70 changes: 70 additions & 0 deletions
70
src/courseware/course/sequence/Unit/translation-selection/TranslationModal.jsx
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,70 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { | ||
StandardModal, | ||
ActionRow, | ||
Button, | ||
Icon, | ||
ListBox, | ||
ListBoxOption, | ||
} from '@edx/paragon'; | ||
import { Check } from '@edx/paragon/icons'; | ||
|
||
import useTranslationModal from './useTranslationModal'; | ||
import { languages } from './useSelectLanguage'; | ||
import messages, { languageMessages } from './messages'; | ||
|
||
import './TranslationModal.scss'; | ||
|
||
const TranslationModal = ({ | ||
isOpen, close, selectedLanguage, setSelectedLanguage, | ||
}) => { | ||
const { formatMessage } = useIntl(); | ||
const { | ||
selectedIndex, | ||
setSelectedIndex, | ||
onSubmit, | ||
} = useTranslationModal({ selectedLanguage, setSelectedLanguage, close }); | ||
|
||
return ( | ||
<StandardModal | ||
title={formatMessage(messages.languageSelectionModalTitle)} | ||
isOpen={isOpen} | ||
onClose={close} | ||
footerNode={( | ||
<ActionRow> | ||
<ActionRow.Spacer /> | ||
<Button variant="tertiary" onClick={close}> | ||
{formatMessage(messages.cancelButtonText)} | ||
</Button> | ||
<Button onClick={onSubmit}>{formatMessage(messages.submitButtonText)}</Button> | ||
</ActionRow> | ||
)} | ||
> | ||
<ListBox className="listbox-container"> | ||
{languages.map(([key, value], index) => ( | ||
<ListBoxOption | ||
className="d-flex justify-content-between" | ||
key={key} | ||
selectedOptionIndex={selectedIndex} | ||
onSelect={() => setSelectedIndex(index)} | ||
> | ||
{formatMessage(languageMessages[value])} | ||
{selectedIndex === index && <Icon src={Check} />} | ||
</ListBoxOption> | ||
))} | ||
</ListBox> | ||
</StandardModal> | ||
); | ||
}; | ||
|
||
TranslationModal.propTypes = { | ||
isOpen: PropTypes.bool.isRequired, | ||
close: PropTypes.func.isRequired, | ||
selectedLanguage: PropTypes.string.isRequired, | ||
setSelectedLanguage: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default TranslationModal; |
7 changes: 7 additions & 0 deletions
7
src/courseware/course/sequence/Unit/translation-selection/TranslationModal.scss
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,7 @@ | ||
.listbox-container { | ||
max-height: 400px; | ||
|
||
:last-child { | ||
margin-bottom: 5px; | ||
} | ||
} |
Oops, something went wrong.