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

127 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'
2022-01-19 07:06:26 +04:00
import VideocamIcon from '@mui/icons-material/Videocam'
import MusicNoteIcon from '@mui/icons-material/MusicNote'
import AlbumIcon from '@mui/icons-material/Album'
import PlayCircleFilledIcon from '@mui/icons-material/PlayCircleFilled'
import {styled} from '@mui/material/styles'
import {SpeedDial, SpeedDialIcon, SpeedDialAction} from '@mui/material'
2020-12-15 08:50:14 +01:00
2022-01-19 06:35:04 +04:00
const PREFIX = 'vwe-koute-achte'
const classes = {
root: `${PREFIX}-root`
}
const Root = styled('div')(() => ({
[`&.${classes.root}`]: {
2020-12-15 08:50:14 +01:00
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}) {
const [ouve, meteOuve] = useState(false)
const {kouteyAchtey, lyen} = anTeks
2020-12-15 08:50:14 +01:00
2022-01-18 09:08:26 +04:00
const kouteyAchteyActions = kouteyAchtey.map(({boutik, url}) => ({
icon: kouteyAchteyIcons[boutik],
name: boutik,
link: url
}))
2020-12-15 08:50:14 +01:00
2022-01-18 09:08:26 +04:00
const vweyActions = lyen.map(({url, sit}) => ({
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 (
2022-01-19 06:35:04 +04:00
<Root className={classes.root}>
2020-12-15 08:50:14 +01:00
<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>
2022-01-19 06:35:04 +04:00
</Root>
2020-12-15 08:50:14 +01:00
)
}
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
}