-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathDropDownCam.js
113 lines (107 loc) · 4.57 KB
/
DropDownCam.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { Popover, Transition } from '@headlessui/react'
import { ChevronDownIcon, CheckIcon } from "@heroicons/react/outline";
import { Fragment, useState } from 'react'
import React from "react";
import DropCAM from '../icons/DropDown/DropCAM';
import { useMeetingAppContext } from '../MeetingAppContextDef';
export default function DropDownCam({
webcams,
changeWebcam
}) {
const {
setSelectedWebcam,
selectedWebcam,
isCameraPermissionAllowed
} = useMeetingAppContext()
const [isHovered, setIsHovered] = useState(false);
return (
<>
<Popover className="relative ml-3">
{({ open }) => (
<>
<Popover.Button
onMouseEnter={() => { setIsHovered(true) }}
onMouseLeave={() => { setIsHovered(false) }}
disabled={!isCameraPermissionAllowed}
className={`focus:outline-none hover:ring-1 hover:ring-gray-250 hover:bg-black
${open
? "text-white ring-1 ring-gray-250 bg-black"
: "text-customGray-250 hover:text-white"
}
group inline-flex items-center rounded-md px-1 py-1 w-44 text-base font-normal
${!isCameraPermissionAllowed ? "opacity-50" : ""}`}
>
<DropCAM fillColor={isHovered || open ? "#FFF" : "#B4B4B4"} />
<span className=" overflow-hidden whitespace-nowrap overflow-ellipsis w-28 ml-7">
{isCameraPermissionAllowed ? selectedWebcam?.label : "Permission Needed"}
</span>
<ChevronDownIcon
className={`${open ? 'text-orange-300' : 'text-orange-300/70'}
ml-8 h-5 w-5 transition duration-150 ease-in-out group-hover:text-orange-300/80 mt-1`}
aria-hidden="true"
/>
</Popover.Button>
<Transition
as={Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<Popover.Panel className="absolute bottom-full z-10 mt-3 w-72 px-4 sm:px-0 pb-2">
<div className="rounded-lg shadow-lg">
<div className="bg-gray-350 rounded-lg">
<div>
<div className="flex flex-col">
{webcams.map(
(item, index) => {
return (
item?.kind === "videoinput" && (
<div
key={`webcams_${index}`}
className={` my-1 pl-4 pr-2 text-white text-left flex`}
>
<span className="w-6 mr-2 flex items-center justify-center">
{selectedWebcam?.label === item?.label && (
<CheckIcon className='h-5 w-5' />
)}
</span>
<button
className={`flex flex-1 w-full text-left`}
value={item?.deviceId}
onClick={() => {
setSelectedWebcam(
(s) => ({
...s,
id: item?.deviceId,
label: item?.label
})
);
changeWebcam(item?.deviceId);
}}
>
{item?.label ? (
<span>{item?.label}</span>
) : (
<span >{`Webcam ${index + 1}`}</span>
)}
</button>
</div>
)
);
}
)}
</div>
</div>
</div>
</div>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
</>
)
}