Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5936de59ff
|
||
|
|
6804e3626f
|
||
|
|
461b063cff
|
+93
-23
@@ -3,7 +3,11 @@
|
|||||||
import {useEffect, useState} from 'react'
|
import {useEffect, useState} from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Box from '@mui/material/Box'
|
import Box from '@mui/material/Box'
|
||||||
import Chip from '@mui/material/Chip'
|
import Select from '@mui/material/Select'
|
||||||
|
import MenuItem from '@mui/material/MenuItem'
|
||||||
|
import ListSubheader from '@mui/material/ListSubheader'
|
||||||
|
import Divider from '@mui/material/Divider'
|
||||||
|
import FormControl from '@mui/material/FormControl'
|
||||||
import Typography from '@mui/material/Typography'
|
import Typography from '@mui/material/Typography'
|
||||||
import Tooltip from '@mui/material/Tooltip'
|
import Tooltip from '@mui/material/Tooltip'
|
||||||
import {useMediaQuery} from '@mui/material'
|
import {useMediaQuery} from '@mui/material'
|
||||||
@@ -12,6 +16,9 @@ import slugify from 'slugify'
|
|||||||
|
|
||||||
import {styled} from '@mui/material/styles'
|
import {styled} from '@mui/material/styles'
|
||||||
import ExplicitIcon from '@mui/icons-material/Explicit'
|
import ExplicitIcon from '@mui/icons-material/Explicit'
|
||||||
|
import TranslateIcon from '@mui/icons-material/Translate'
|
||||||
|
import StarIcon from '@mui/icons-material/Star'
|
||||||
|
import ArticleIcon from '@mui/icons-material/Article'
|
||||||
|
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
|
|
||||||
@@ -88,15 +95,34 @@ const LANG_NAMES = {
|
|||||||
pt: 'Português', ja: '日本語', ko: '한국어',
|
pt: 'Português', ja: '日本語', ko: '한국어',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CONTINENTS = ['Afrique', 'Asie', 'Europe']
|
||||||
|
|
||||||
const TRAD_FIELDS = [
|
const TRAD_FIELDS = [
|
||||||
{field: 'japonais', title: '日本語'},
|
// Afrique — langues vedettes en premier
|
||||||
{field: 'coreen', title: '한국어'},
|
{field: 'yoruba', title: 'Yorùbá', continent: 'Afrique', vedette: true},
|
||||||
{field: 'anglais', title: 'English'},
|
{field: 'lingala', title: 'Lingála', continent: 'Afrique', vedette: true},
|
||||||
{field: 'francais', title: 'Français'},
|
{field: 'wolof', title: 'Wolof', continent: 'Afrique', vedette: true},
|
||||||
{field: 'espagnol', title: 'Español'},
|
{field: 'swahili', title: 'Kiswahili', continent: 'Afrique', vedette: true},
|
||||||
{field: 'allemand', title: 'Deutsch'},
|
{field: 'hausa', title: 'Hausa', continent: 'Afrique', vedette: true},
|
||||||
{field: 'italien', title: 'Italiano'},
|
{field: 'arabe', title: 'العربية', continent: 'Afrique'},
|
||||||
{field: 'portugais', title: 'Português'},
|
{field: 'oromo', title: 'Oromoo', continent: 'Afrique'},
|
||||||
|
{field: 'igbo', title: 'Igbo', continent: 'Afrique'},
|
||||||
|
{field: 'zoulou', title: 'isiZulu', continent: 'Afrique'},
|
||||||
|
{field: 'malgache', title: 'Malagasy', continent: 'Afrique'},
|
||||||
|
{field: 'xhosa', title: 'isiXhosa', continent: 'Afrique'},
|
||||||
|
{field: 'tswana', title: 'Setswana', continent: 'Afrique'},
|
||||||
|
{field: 'tsonga', title: 'Xitsonga', continent: 'Afrique'},
|
||||||
|
{field: 'sesotho', title: 'Sesotho', continent: 'Afrique'},
|
||||||
|
// Asie
|
||||||
|
{field: 'japonais', title: '日本語', continent: 'Asie'},
|
||||||
|
{field: 'coreen', title: '한국어', continent: 'Asie'},
|
||||||
|
// Europe
|
||||||
|
{field: 'anglais', title: 'English', continent: 'Europe'},
|
||||||
|
{field: 'francais', title: 'Français', continent: 'Europe'},
|
||||||
|
{field: 'espagnol', title: 'Español', continent: 'Europe'},
|
||||||
|
{field: 'allemand', title: 'Deutsch', continent: 'Europe'},
|
||||||
|
{field: 'italien', title: 'Italiano', continent: 'Europe'},
|
||||||
|
{field: 'portugais', title: 'Português', continent: 'Europe'},
|
||||||
]
|
]
|
||||||
|
|
||||||
const langToArray = parole => {
|
const langToArray = parole => {
|
||||||
@@ -106,10 +132,13 @@ const langToArray = parole => {
|
|||||||
|
|
||||||
return TRAD_FIELDS
|
return TRAD_FIELDS
|
||||||
.filter(({field}) => parole.traductions[field])
|
.filter(({field}) => parole.traductions[field])
|
||||||
.map(({field, title}) => ({field, title, lang: parole.traductions[field]}))
|
.map(({field, title, continent, vedette}) => ({field, title, continent, vedette, lang: parole.traductions[field]}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const BROWSER_LANG_TO_FIELD = {
|
const BROWSER_LANG_TO_FIELD = {
|
||||||
|
yo: 'yoruba', ln: 'lingala', wo: 'wolof', sw: 'swahili', ha: 'hausa',
|
||||||
|
ar: 'arabe', om: 'oromo', ig: 'igbo', zu: 'zoulou', mg: 'malgache',
|
||||||
|
xh: 'xhosa', tn: 'tswana', ts: 'tsonga', st: 'sesotho',
|
||||||
ja: 'japonais', ko: 'coreen', en: 'anglais', fr: 'francais',
|
ja: 'japonais', ko: 'coreen', en: 'anglais', fr: 'francais',
|
||||||
es: 'espagnol', de: 'allemand', it: 'italien', pt: 'portugais',
|
es: 'espagnol', de: 'allemand', it: 'italien', pt: 'portugais',
|
||||||
}
|
}
|
||||||
@@ -123,7 +152,6 @@ export default function Teks({parole}) {
|
|||||||
const coverFmt = formatKuveti(parole.couverture)
|
const coverFmt = formatKuveti(parole.couverture)
|
||||||
const [tab, setTab] = useState(0)
|
const [tab, setTab] = useState(0)
|
||||||
const [, setCurrentTrack] = useCurrentTrack()
|
const [, setCurrentTrack] = useCurrentTrack()
|
||||||
const options = ['Transcription', ...langArray.map(({title}) => title)]
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isBrowser = () => typeof window !== 'undefined'
|
const isBrowser = () => typeof window !== 'undefined'
|
||||||
@@ -247,18 +275,60 @@ export default function Teks({parole}) {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{maxWidth: 700, margin: '0 auto'}} className={classes.gridText}>
|
<Box sx={{maxWidth: 700, margin: '0 auto'}} className={classes.gridText}>
|
||||||
<Box sx={{display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 1, borderBottom: 1, borderColor: 'divider', mb: 2, pb: 2}}>
|
<Box sx={{display: 'flex', justifyContent: 'center', borderBottom: 1, borderColor: 'divider', mb: 2, pb: 2}}>
|
||||||
{options.map((label, index) => (
|
<FormControl size='small' sx={{minWidth: 240, width: isMobile ? '100%' : 'auto'}}>
|
||||||
<Chip
|
<Select
|
||||||
key={label}
|
value={tab}
|
||||||
clickable
|
MenuProps={{PaperProps: {sx: {maxHeight: 420}}}}
|
||||||
color='primary'
|
renderValue={value => {
|
||||||
label={label}
|
const label = value === 0 ? 'Transcription' : langArray[value - 1]?.title
|
||||||
sx={{fontWeight: tab === index ? 600 : 400}}
|
const Icon = value === 0 ? ArticleIcon : TranslateIcon
|
||||||
variant={tab === index ? 'filled' : 'outlined'}
|
return (
|
||||||
onClick={() => setTab(index)}
|
<Box sx={{display: 'flex', alignItems: 'center', gap: 1, fontWeight: value === 0 ? 700 : 400}}>
|
||||||
/>
|
<Icon fontSize='small' color='primary' />
|
||||||
))}
|
{label}
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
onChange={event => setTab(event.target.value)}
|
||||||
|
>
|
||||||
|
<MenuItem value={0} sx={{display: 'flex', gap: 0.75, fontWeight: 700}}>
|
||||||
|
<ArticleIcon fontSize='inherit' color='primary' />
|
||||||
|
Transcription
|
||||||
|
</MenuItem>
|
||||||
|
<Divider />
|
||||||
|
{CONTINENTS.flatMap(continent => {
|
||||||
|
const items = langArray
|
||||||
|
.map((item, index) => ({...item, index}))
|
||||||
|
.filter(item => item.continent === continent)
|
||||||
|
|
||||||
|
if (items.length === 0) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
<ListSubheader
|
||||||
|
key={`entet-${continent}`}
|
||||||
|
sx={{
|
||||||
|
fontWeight: 700,
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: 1,
|
||||||
|
color: 'primary.main',
|
||||||
|
lineHeight: '2.5em'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{continent}
|
||||||
|
</ListSubheader>,
|
||||||
|
...items.map(({title, index, vedette}) => (
|
||||||
|
<MenuItem key={title} value={index + 1} sx={{display: 'flex', gap: 0.75}}>
|
||||||
|
{vedette && <StarIcon fontSize='inherit' color='primary' />}
|
||||||
|
{title}
|
||||||
|
</MenuItem>
|
||||||
|
))
|
||||||
|
]
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
</Box>
|
</Box>
|
||||||
{tab === 0 && (
|
{tab === 0 && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user