-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1086 from culturecreates/develop
Develop
- Loading branch information
Showing
27 changed files
with
1,488 additions
and
460 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import Tags from '../Tags/Common/Tags'; | ||
import TooltipStyled from '../Tooltip/TooltipStyled'; | ||
import './literalBadge.css'; | ||
|
||
const LiteralBadge = ({ tagTitle, promptText = 'promptText' }) => { | ||
return ( | ||
<div className="literal-badge"> | ||
<TooltipStyled title={promptText}> | ||
<Tags>{tagTitle}</Tags> | ||
</TooltipStyled> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LiteralBadge; |
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,16 @@ | ||
.literal-badge { | ||
position: absolute; | ||
top: 9px; | ||
right: 0; | ||
color: red; | ||
} | ||
|
||
.literal-badge .tags-wrapper { | ||
height: 24px; | ||
padding: 4px 8px 4px 8px; | ||
gap: 10px; | ||
border-radius: 4px; | ||
border: 1px solid #1b3de6; | ||
color: #0f0e98; | ||
text-transform: capitalize; | ||
} |
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
54 changes: 48 additions & 6 deletions
54
src/components/ContentLanguageInput/ContentLanguageInput.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 |
---|---|---|
@@ -1,14 +1,56 @@ | ||
import React from 'react'; | ||
import { useOutletContext } from 'react-router-dom'; | ||
import { contentLanguage } from '../../constants/contentLanguage'; | ||
import LiteralBadge from '../Badge/LiteralBadge'; | ||
import { useTranslation } from 'react-i18next'; | ||
import useModifyChildernWithFallbackLanguage from '../../hooks/useModifyChildernWithFallbackLanguage'; | ||
|
||
function ContentLanguageInput(props) { | ||
const { children, calendarContentLanguage } = props; | ||
const { t } = useTranslation(); | ||
|
||
if (calendarContentLanguage === contentLanguage.FRENCH) | ||
return children?.props?.children?.filter((child) => child?.key === contentLanguage.FRENCH); | ||
else if (calendarContentLanguage === contentLanguage.ENGLISH) | ||
return children?.props?.children?.filter((child) => child?.key === contentLanguage.ENGLISH); | ||
else if (calendarContentLanguage === contentLanguage.BILINGUAL) return children; | ||
else return children; | ||
// eslint-disable-next-line no-unused-vars | ||
const [currentCalendarData, _pageNumber, _setPageNumber, _getCalendar] = useOutletContext(); | ||
|
||
const { fallbackStatus, modifiedChildren } = useModifyChildernWithFallbackLanguage(props, currentCalendarData); | ||
|
||
if (!modifiedChildren) return children; | ||
|
||
if (calendarContentLanguage === contentLanguage.FRENCH) { | ||
const promptText = | ||
fallbackStatus?.fr?.fallbackLiteralKey === '?' | ||
? t('common.forms.languageLiterals.unKnownLanguagePromptText') | ||
: t('common.forms.languageLiterals.knownLanguagePromptText'); | ||
return ( | ||
<> | ||
{modifiedChildren[0]?.props?.children?.filter( | ||
(child) => child?.key?.replace(/[.$]/g, '') === contentLanguage.FRENCH, | ||
)} | ||
{fallbackStatus?.fr?.tagDisplayStatus && ( | ||
<LiteralBadge tagTitle={fallbackStatus?.fr?.fallbackLiteralKey} promptText={promptText} /> | ||
)} | ||
</> | ||
// add literal badge to the fr children | ||
); | ||
} else if (calendarContentLanguage === contentLanguage.ENGLISH) { | ||
const promptText = | ||
fallbackStatus?.en?.fallbackLiteralKey === '?' | ||
? t('common.forms.languageLiterals.unKnownLanguagePromptText') | ||
: t('common.forms.languageLiterals.knownLanguagePromptText'); | ||
return ( | ||
<> | ||
{modifiedChildren[0]?.props?.children?.filter( | ||
(child) => child?.key?.replace(/[.$]/g, '') === contentLanguage.ENGLISH, | ||
)} | ||
{fallbackStatus?.en?.tagDisplayStatus && ( | ||
<LiteralBadge tagTitle={fallbackStatus?.en?.fallbackLiteralKey} promptText={promptText} /> | ||
)} | ||
</> | ||
// add literal badge to the en children | ||
); | ||
} else if (calendarContentLanguage === contentLanguage.BILINGUAL) return <>{modifiedChildren[0]}</>; | ||
else return <>{modifiedChildren[0]}</>; | ||
// for bilingual, return the children as is, literal is added in BilingualInput component | ||
} | ||
|
||
export default ContentLanguageInput; |
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
Oops, something went wrong.