3 Commits
Author SHA1 Message Date
cedric 5936de59ff fix: mettre en valeur l'option Transcription dans le select
Déploiement FRONT BETA / check (push) Successful in 2m7s
Vérification PR / check (pull_request) Successful in 2m11s
Déploiement FRONT BETA / deploy (push) Successful in 20s
Vérification PR / deploy-beta (pull_request) Successful in 19s
2026-07-06 02:01:44 +04:00
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
+93 -23
View File
@@ -3,7 +3,11 @@
import {useEffect, useState} from 'react'
import PropTypes from 'prop-types'
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 Tooltip from '@mui/material/Tooltip'
import {useMediaQuery} from '@mui/material'
@@ -12,6 +16,9 @@ import slugify from 'slugify'
import {styled} from '@mui/material/styles'
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'
@@ -88,15 +95,34 @@ const LANG_NAMES = {
pt: 'Português', ja: '日本語', ko: '한국어',
}
const CONTINENTS = ['Afrique', 'Asie', 'Europe']
const TRAD_FIELDS = [
{field: 'japonais', title: '日本語'},
{field: 'coreen', title: '한국어'},
{field: 'anglais', title: 'English'},
{field: 'francais', title: 'Français'},
{field: 'espagnol', title: 'Español'},
{field: 'allemand', title: 'Deutsch'},
{field: 'italien', title: 'Italiano'},
{field: 'portugais', title: 'Português'},
// Afrique — langues vedettes en premier
{field: 'yoruba', title: 'Yorùbá', continent: 'Afrique', vedette: true},
{field: 'lingala', title: 'Lingála', continent: 'Afrique', vedette: true},
{field: 'wolof', title: 'Wolof', continent: 'Afrique', vedette: true},
{field: 'swahili', title: 'Kiswahili', continent: 'Afrique', vedette: true},
{field: 'hausa', title: 'Hausa', continent: 'Afrique', vedette: true},
{field: 'arabe', title: 'العربية', continent: 'Afrique'},
{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 => {
@@ -106,10 +132,13 @@ const langToArray = parole => {
return TRAD_FIELDS
.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 = {
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',
es: 'espagnol', de: 'allemand', it: 'italien', pt: 'portugais',
}
@@ -123,7 +152,6 @@ export default function Teks({parole}) {
const coverFmt = formatKuveti(parole.couverture)
const [tab, setTab] = useState(0)
const [, setCurrentTrack] = useCurrentTrack()
const options = ['Transcription', ...langArray.map(({title}) => title)]
useEffect(() => {
const isBrowser = () => typeof window !== 'undefined'
@@ -247,18 +275,60 @@ export default function Teks({parole}) {
)}
</Box>
<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}}>
{options.map((label, index) => (
<Chip
key={label}
clickable
color='primary'
label={label}
sx={{fontWeight: tab === index ? 600 : 400}}
variant={tab === index ? 'filled' : 'outlined'}
onClick={() => setTab(index)}
/>
))}
<Box sx={{display: 'flex', justifyContent: 'center', borderBottom: 1, borderColor: 'divider', mb: 2, pb: 2}}>
<FormControl size='small' sx={{minWidth: 240, width: isMobile ? '100%' : 'auto'}}>
<Select
value={tab}
MenuProps={{PaperProps: {sx: {maxHeight: 420}}}}
renderValue={value => {
const label = value === 0 ? 'Transcription' : langArray[value - 1]?.title
const Icon = value === 0 ? ArticleIcon : TranslateIcon
return (
<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>
{tab === 0 && (
<>