-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace device dropdowns with radio buttons
This is closer to what the designs actually want device settings to look like, and it avoids the visual glitch in which the dropdown would render underneath the slider.
- Loading branch information
Showing
3 changed files
with
123 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.selection { | ||
gap: 0; | ||
} | ||
|
||
.title { | ||
color: var(--cpd-color-text-secondary); | ||
margin-block-end: 0; | ||
} | ||
|
||
.separator { | ||
margin-block: 6px var(--cpd-space-4x); | ||
} | ||
|
||
.options { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--cpd-space-4x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
import { ChangeEvent, FC, useCallback, useId } from "react"; | ||
import { | ||
Heading, | ||
InlineField, | ||
Label, | ||
RadioControl, | ||
Separator, | ||
} from "@vector-im/compound-web"; | ||
|
||
import { MediaDevice } from "../livekit/MediaDevicesContext"; | ||
import styles from "./DeviceSelection.module.css"; | ||
|
||
interface Props { | ||
devices: MediaDevice; | ||
caption: string; | ||
} | ||
|
||
export const DeviceSelection: FC<Props> = ({ devices, caption }) => { | ||
const groupId = useId(); | ||
const onChange = useCallback( | ||
(e: ChangeEvent<HTMLInputElement>) => { | ||
devices.select(e.target.value); | ||
}, | ||
[devices], | ||
); | ||
|
||
if (devices.available.length == 0) return null; | ||
|
||
return ( | ||
<div className={styles.selection}> | ||
<Heading | ||
type="body" | ||
weight="semibold" | ||
size="sm" | ||
as="h4" | ||
className={styles.title} | ||
> | ||
{caption} | ||
</Heading> | ||
<Separator className={styles.separator} /> | ||
<div className={styles.options}> | ||
{devices.available.map(({ deviceId, label }, index) => ( | ||
<InlineField | ||
key={deviceId} | ||
name={groupId} | ||
control={ | ||
<RadioControl | ||
checked={deviceId === devices.selectedId} | ||
onChange={onChange} | ||
value={deviceId} | ||
/> | ||
} | ||
> | ||
<Label> | ||
{!!label && label.trim().length > 0 | ||
? label | ||
: `${caption} ${index + 1}`} | ||
</Label> | ||
</InlineField> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters