2 Commits
Author SHA1 Message Date
cedric 6804e3626f feat: remplacer les puces par un select groupé par continent
Déploiement FRONT BETA / check (push) Successful in 2m14s
Vérification PR / check (pull_request) Successful in 2m14s
Déploiement FRONT BETA / deploy (push) Successful in 23s
Vérification PR / deploy-beta (pull_request) Successful in 20s
2026-07-06 00:18:34 +04:00
cedric 461b063cff feat: regrouper les langues par continent, Afrique en tête 2026-07-06 00:10:34 +04:00
+86 -23
View File
@@ -3,7 +3,10 @@
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 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 +15,8 @@ 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 Image from 'next/image' import Image from 'next/image'
@@ -88,15 +93,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 +130,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 +150,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 +273,55 @@ 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}} return (
variant={tab === index ? 'filled' : 'outlined'} <Box sx={{display: 'flex', alignItems: 'center', gap: 1}}>
onClick={() => setTab(index)} <TranslateIcon fontSize='small' color='primary' />
/> {label}
))} </Box>
)
}}
onChange={event => setTab(event.target.value)}
>
<MenuItem value={0}>Transcription</MenuItem>
{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 && (
<> <>