Files
pawol.nu/components/teks/vwe-koute-achte.js
T

126 lines
2.9 KiB
JavaScript
Raw Normal View History

2020-12-18 22:05:43 +01:00
import {useState} from 'react'
2020-12-15 08:50:14 +01:00
import PropTypes from 'prop-types'
import {
Youtube,
Dailymotion,
Youtubemusic,
Applemusic,
Tidal,
Spotify,
Deezer,
Amazon,
2021-02-22 22:31:37 +01:00
Soundcloud,
2021-05-04 20:24:39 +02:00
Lbry,
Peertube
2020-12-15 08:50:14 +01:00
} from '@icons-pack/react-simple-icons'
2020-12-19 23:05:42 +01:00
import VideocamIcon from '@material-ui/icons/Videocam'
2020-12-15 08:50:14 +01:00
import MusicNoteIcon from '@material-ui/icons/MusicNote'
import AlbumIcon from '@material-ui/icons/Album'
2021-04-29 20:12:14 +02:00
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled'
2020-12-15 08:50:14 +01:00
import {makeStyles} from '@material-ui/core/styles'
import {SpeedDial, SpeedDialIcon, SpeedDialAction} from '@material-ui/lab'
const useStyles = makeStyles(() => ({
root: {
height: 0,
transform: 'translateZ(0px)'
}
}))
const kouteyAchteyIcons = {
Qobuz: <AlbumIcon />,
Deezer: <Deezer />,
Spotify: <Spotify />,
Tidal: <Tidal />,
Amazon: <Amazon />,
Applemusic: <Applemusic />,
2021-06-17 23:10:08 +02:00
Youtubemusic: <Youtubemusic />,
Soundcloud: <Soundcloud />
2020-12-15 08:50:14 +01:00
}
const vweyIcons = {
Youtube: <Youtube />,
Dailymotion: <Dailymotion />,
2021-04-29 20:12:14 +02:00
Lbry: <Lbry />,
2021-05-04 20:24:39 +02:00
Rumble: <PlayCircleFilledIcon />,
Peertube: <Peertube />
2020-12-15 08:50:14 +01:00
}
2020-12-18 22:05:43 +01:00
export default function VweKouteAchte({anTeks, niVideyo, niOdyo}) {
2020-12-15 08:50:14 +01:00
const classes = useStyles()
2020-12-18 22:05:43 +01:00
const [ouve, meteOuve] = useState(false)
const {kouteyAchtey, lyen} = anTeks
2020-12-15 08:50:14 +01:00
2020-12-18 22:05:43 +01:00
const kouteyAchteyActions = kouteyAchtey.map(({boutik, url}) => {
2020-12-15 08:50:14 +01:00
return {
2020-12-18 22:05:43 +01:00
icon: kouteyAchteyIcons[boutik],
name: boutik,
link: url
2020-12-15 08:50:14 +01:00
}
})
2020-12-18 22:05:43 +01:00
const vweyActions = lyen.map(({url, sit}) => {
2020-12-15 08:50:14 +01:00
return {
2020-12-18 22:05:43 +01:00
icon: vweyIcons[sit],
name: sit,
link: url
2020-12-15 08:50:14 +01:00
}
})
const handleOpen = () => {
2020-12-18 22:05:43 +01:00
meteOuve(true)
2020-12-15 08:50:14 +01:00
}
const handleClick = link => {
window.location = link
}
const handleClose = () => {
2020-12-18 22:05:43 +01:00
meteOuve(false)
2020-12-15 08:50:14 +01:00
}
return (
<div className={classes.root}>
<SpeedDial
color='secondary'
FabProps={{size: 'small', margin: 'auto', color: 'default'}}
ariaLabel='SpeedDial openIcon example'
className={classes.speedDial}
direction='down'
2020-12-19 23:05:42 +01:00
icon={<SpeedDialIcon icon={niOdyo ? <MusicNoteIcon /> : <VideocamIcon />} />}
2020-12-18 22:05:43 +01:00
open={ouve}
2020-12-15 08:50:14 +01:00
onClose={handleClose}
onOpen={handleOpen}
>
2020-12-18 22:05:43 +01:00
{niOdyo && kouteyAchteyActions.map(action => (
2020-12-15 08:50:14 +01:00
<SpeedDialAction
key={action.name}
icon={action.icon}
tooltipTitle={action.name}
onClick={() => handleClick(action.link)}
/>
))}
2020-12-18 22:05:43 +01:00
{niVideyo && vweyActions.map(action => (
2020-12-15 08:50:14 +01:00
<SpeedDialAction
key={action.name}
icon={action.icon}
tooltipTitle={action.name}
onClick={() => handleClick(action.link)}
/>
))}
</SpeedDial>
</div>
)
}
VweKouteAchte.propTypes = {
2020-12-18 22:05:43 +01:00
anTeks: PropTypes.object.isRequired,
niVideyo: PropTypes.bool,
niOdyo: PropTypes.bool
2020-12-15 08:50:14 +01:00
}
VweKouteAchte.defaultProps = {
2020-12-18 22:05:43 +01:00
niVideyo: false,
niOdyo: false
2020-12-15 08:50:14 +01:00
}