2020-12-13 23:20:07 +01:00
|
|
|
import {useState} from 'react'
|
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
Grid,
|
|
|
|
|
Toolbar,
|
|
|
|
|
Typography,
|
|
|
|
|
AppBar,
|
|
|
|
|
CssBaseline,
|
|
|
|
|
Drawer,
|
|
|
|
|
Hidden,
|
|
|
|
|
IconButton
|
|
|
|
|
} from '@material-ui/core'
|
|
|
|
|
|
|
|
|
|
import KeyboardBackspaceIcon from '@material-ui/icons/KeyboardBackspace'
|
|
|
|
|
|
|
|
|
|
import MenuIcon from '@material-ui/icons/Menu'
|
|
|
|
|
|
|
|
|
|
import {makeStyles, useTheme} from '@material-ui/core/styles'
|
|
|
|
|
|
|
|
|
|
import DrawerBar from './drawer-bar'
|
|
|
|
|
import DenyeTeks from './denye-teks'
|
2020-12-15 08:50:14 +01:00
|
|
|
import VweKouteAchte from './vwe-koute-achte'
|
2021-01-12 21:58:08 +01:00
|
|
|
import OkiMizik from './oki-mizik'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
|
|
|
|
const drawerWidth = 240
|
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles(theme => ({
|
|
|
|
|
root: {
|
|
|
|
|
display: 'flex'
|
|
|
|
|
},
|
|
|
|
|
drawer: {
|
|
|
|
|
marginTop: '10em',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
width: drawerWidth,
|
|
|
|
|
flexShrink: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
appBar: {
|
|
|
|
|
borderTop: '2px solid #303030',
|
|
|
|
|
marginTop: '4.71rem',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
|
|
|
marginLeft: drawerWidth
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
menuButton: {
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
display: 'none'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
toolbar: theme.mixins.toolbar,
|
|
|
|
|
drawerPaper: {
|
|
|
|
|
borderTop: '2px solid #303030',
|
|
|
|
|
marginTop: '4.71rem',
|
|
|
|
|
width: drawerWidth
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
padding: theme.spacing(3)
|
|
|
|
|
},
|
|
|
|
|
list: {
|
|
|
|
|
marginBottom: '6em'
|
|
|
|
|
},
|
|
|
|
|
form: {
|
|
|
|
|
marginLeft: theme.spacing(1)
|
|
|
|
|
},
|
|
|
|
|
text: {
|
|
|
|
|
marginBottom: '0.5em'
|
|
|
|
|
},
|
|
|
|
|
gridText: {
|
|
|
|
|
border: '1px dashed grey',
|
|
|
|
|
borderRadius: '5px',
|
|
|
|
|
marginTop: '2em',
|
|
|
|
|
marginInline: '2px'
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
marginTop: '1em'
|
2020-12-15 08:50:14 +01:00
|
|
|
},
|
|
|
|
|
koute: {
|
|
|
|
|
position: 'absolute',
|
2020-12-17 23:44:01 +01:00
|
|
|
right: '1px',
|
2020-12-15 08:50:14 +01:00
|
|
|
top: '8px',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
top: '10px'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
vwe: {
|
|
|
|
|
position: 'absolute',
|
2020-12-17 23:44:01 +01:00
|
|
|
right: '60px',
|
2020-12-15 08:50:14 +01:00
|
|
|
top: '8px',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
top: '10px'
|
|
|
|
|
}
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const formatJsonString = stringToFormat => {
|
|
|
|
|
return stringToFormat.split('\n').map((string, index) => <div key={index}>{`${string}`}<br /></div>) // eslint-disable-line react/no-array-index-key
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 22:08:34 +01:00
|
|
|
export default function TeksDrawer({teks, anTeks}) {
|
2020-12-13 23:20:07 +01:00
|
|
|
const classes = useStyles()
|
|
|
|
|
const theme = useTheme()
|
2020-12-18 22:21:53 +01:00
|
|
|
const [esMobilOuve, meteEsMobilOuve] = useState(false)
|
2020-12-13 23:20:07 +01:00
|
|
|
|
|
|
|
|
const handleDrawerToggle = () => {
|
2020-12-18 22:21:53 +01:00
|
|
|
meteEsMobilOuve(!esMobilOuve)
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const container = typeof window === 'undefined' ? undefined : () => window.document.body
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={classes.root}>
|
|
|
|
|
<CssBaseline />
|
|
|
|
|
<AppBar position='fixed' className={classes.appBar}>
|
|
|
|
|
<Toolbar>
|
|
|
|
|
<IconButton
|
|
|
|
|
color='inherit'
|
|
|
|
|
aria-label='open drawer'
|
|
|
|
|
edge='start'
|
|
|
|
|
className={classes.menuButton}
|
|
|
|
|
onClick={handleDrawerToggle}
|
|
|
|
|
>
|
|
|
|
|
<MenuIcon />
|
|
|
|
|
</IconButton>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks ? (
|
2020-12-13 23:20:07 +01:00
|
|
|
<>
|
|
|
|
|
<Link href='/teks'>
|
2020-12-17 23:45:22 +01:00
|
|
|
<IconButton aria-label='return' size='medium'>
|
|
|
|
|
<KeyboardBackspaceIcon style={{fontSize: '1.5em'}} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</IconButton>
|
|
|
|
|
</Link>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.lyen && anTeks.lyen.length > 0 && (
|
2020-12-15 08:50:14 +01:00
|
|
|
<div className={classes.vwe}>
|
2020-12-18 22:08:34 +01:00
|
|
|
<VweKouteAchte niVideyo anTeks={anTeks} />
|
2020-12-15 08:50:14 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.kouteyAchtey && anTeks.kouteyAchtey.length > 0 && (
|
2020-12-15 08:50:14 +01:00
|
|
|
<div className={classes.koute}>
|
2020-12-18 22:08:34 +01:00
|
|
|
<VweKouteAchte niOdyo anTeks={anTeks} />
|
2020-12-15 08:50:14 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2020-12-13 23:20:07 +01:00
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<Typography noWrap variant='h6'>
|
|
|
|
|
Dènyé Tèks
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
</Toolbar>
|
|
|
|
|
</AppBar>
|
|
|
|
|
<nav className={classes.drawer} aria-label='mailbox folders'>
|
|
|
|
|
<Hidden smUp implementation='css'>
|
|
|
|
|
<Drawer
|
|
|
|
|
container={container}
|
|
|
|
|
variant='temporary'
|
|
|
|
|
anchor={theme.direction === 'rtl' ? 'right' : 'left'}
|
2020-12-18 22:21:53 +01:00
|
|
|
open={esMobilOuve}
|
2020-12-13 23:20:07 +01:00
|
|
|
classes={{
|
|
|
|
|
paper: classes.drawerPaper
|
|
|
|
|
}}
|
|
|
|
|
ModalProps={{
|
|
|
|
|
keepMounted: true
|
|
|
|
|
}}
|
|
|
|
|
onClose={handleDrawerToggle}
|
|
|
|
|
>
|
2020-12-18 22:21:53 +01:00
|
|
|
<DrawerBar meteEsMobilOuve={meteEsMobilOuve} teks={teks} anTeks={anTeks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</Drawer>
|
|
|
|
|
</Hidden>
|
|
|
|
|
<Hidden xsDown implementation='css'>
|
|
|
|
|
<Drawer
|
|
|
|
|
open
|
|
|
|
|
classes={{
|
|
|
|
|
paper: classes.drawerPaper
|
|
|
|
|
}}
|
|
|
|
|
variant='permanent'
|
|
|
|
|
>
|
2020-12-18 22:08:34 +01:00
|
|
|
<DrawerBar teks={teks} anTeks={anTeks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</Drawer>
|
|
|
|
|
</Hidden>
|
|
|
|
|
</nav>
|
|
|
|
|
<main className={classes.content}>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks ? (
|
2020-12-17 23:47:15 +01:00
|
|
|
<>
|
2021-01-12 21:58:08 +01:00
|
|
|
<Typography noWrap align='center' style={{marginTop: '0.8em'}} variant='h4'>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.tit}
|
2020-12-17 23:47:15 +01:00
|
|
|
</Typography>
|
2021-01-12 21:58:08 +01:00
|
|
|
{anTeks.okiMizikID && (
|
|
|
|
|
<OkiMizik id={anTeks.okiMizikID} />
|
|
|
|
|
)}
|
2020-12-17 23:47:15 +01:00
|
|
|
<Grid container className={classes.grid} spacing={3}>
|
2020-12-13 23:20:07 +01:00
|
|
|
<Grid item md className={classes.gridText}>
|
|
|
|
|
<Typography align='center' className={classes.text} variant='h4'>
|
2020-12-17 23:47:15 +01:00
|
|
|
Transcription
|
2020-12-13 23:20:07 +01:00
|
|
|
</Typography>
|
|
|
|
|
<Typography paragraph align='justify' component='span'>
|
2020-12-18 22:08:34 +01:00
|
|
|
{formatJsonString(anTeks.transkripsyon)}
|
2020-12-13 23:20:07 +01:00
|
|
|
</Typography>
|
|
|
|
|
</Grid>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.tradiksyon && (
|
2020-12-17 23:47:15 +01:00
|
|
|
<Grid item md className={classes.gridText}>
|
|
|
|
|
<Typography align='center' className={classes.text} variant='h4'>
|
|
|
|
|
Traduction
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography paragraph align='justify' component='span'>
|
2020-12-18 22:08:34 +01:00
|
|
|
{formatJsonString(anTeks.tradiksyon.francais)}
|
2020-12-17 23:47:15 +01:00
|
|
|
</Typography>
|
|
|
|
|
</Grid>
|
|
|
|
|
)}
|
|
|
|
|
</Grid>
|
|
|
|
|
</>
|
2020-12-13 23:20:07 +01:00
|
|
|
) : (
|
2020-12-18 22:08:34 +01:00
|
|
|
<DenyeTeks {...teks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
)}
|
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksDrawer.propTypes = {
|
2020-12-18 22:08:34 +01:00
|
|
|
teks: PropTypes.array.isRequired,
|
|
|
|
|
anTeks: PropTypes.object
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksDrawer.defaultProps = {
|
2020-12-18 22:08:34 +01:00
|
|
|
anTeks: null
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|