You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
import { Fragment } from 'react'
|
|
|
|
import map from 'lodash/map'
|
|
|
|
import { OutsideClick } from 'features/OutsideClick'
|
|
|
|
import type { Props } from './hooks'
|
|
import { useSettings } from './hooks'
|
|
import {
|
|
SettingsButton,
|
|
QualitiesList,
|
|
QualityItem,
|
|
} from './styled'
|
|
|
|
export const Settings = (props: Props) => {
|
|
const { selectedQuality, videoQualities } = props
|
|
const {
|
|
close,
|
|
isOpen,
|
|
onItemClick,
|
|
open,
|
|
} = useSettings(props)
|
|
return (
|
|
<Fragment>
|
|
<SettingsButton onClick={open} />
|
|
{
|
|
isOpen && (
|
|
<OutsideClick onClick={close}>
|
|
<QualitiesList>
|
|
{
|
|
map(videoQualities, (quality) => (
|
|
<QualityItem
|
|
key={quality}
|
|
active={quality === selectedQuality}
|
|
onClick={() => onItemClick(quality)}
|
|
>
|
|
{quality}
|
|
</QualityItem>
|
|
))
|
|
}
|
|
</QualitiesList>
|
|
</OutsideClick>
|
|
)
|
|
}
|
|
</Fragment>
|
|
)
|
|
}
|
|
|