Skip to content
kerfjsGitHub

Prejoin

Check your name, mic and camera before you go into a call.

SourcePackage @kerf-js/veneer

Preview

tsx
import { state } from '@kerf-js/core'import {  Button,  Prejoin,  Row,  Stack,  Text} from '@kerf-js/veneer'export function IncidentCall() {  const joining = state(false)  const joined = state('')  const said = state('')  const join = async (name: string) => {    joining.value = true    await pause(1200)    joining.value = false    joined.value = name  }  return (    <>      {joined.value ? (        <Row gap="related">          <Text>{joined.value} is in the call.</Text>          <Button            emphasis="outline"            tone="neutral"            size="sm"            onClick={() => (joined.value = '')}          >            Go back          </Button>        </Row>      ) : (        <Stack gap="related">          <Prejoin            name="Priya Raman"            devices={CALL_DEVICES}            level={0.4}            joining={joining.value}            onJoin={(n) => void join(n)}            onTestSound={() =>              (said.value = 'Test sound played')            }          />          {said.value && (            <Text              role="caption"              subtle            >              {said.value}            </Text>          )}        </Stack>      )}    </>  )}const CALL_DEVICES = {  mics: [    { value: 'mbp', label: 'MacBook Pro Microphone' },    { value: 'pods', label: 'AirPods Pro' },  ],  cameras: [{ value: 'hd', label: 'FaceTime HD Camera' }],  speakers: [    { value: 'pods', label: 'AirPods Pro' },    { value: 'mbp', label: 'MacBook Pro Speakers' },  ],}const pause = (ms: number) =>  new Promise((done) => {    setTimeout(done, ms)  })

Installation

npm install @kerf-js/veneer

Usage

tsx
import { Prejoin } from '@kerf-js/veneer'

Accessibility

  • This has no shortcuts of its own: controls inside it use Tab, Enter and Space as usual, and veneer's parts keep their roles and labels.

API Reference

PropTypeDefaultDescription
namestring—Fills the name field.
preview(() => unknown)—Your <video>.
levelnumber—The mic level, 0 to 1.
micbooleanfalseWhether your mic starts on.
camerabooleanfalseWhether your camera starts on.
devicesPrejoinDevices—The microphones, cameras and speakers to list.
joiningbooleanfalseJoin is under way.
joinLabelstring—The join button's words. Default "Join now".
EventTypeDefaultDescription
onMic((on: boolean) => void)—Called with the mic toggle's new state.
onCamera((on: boolean) => void)—Called with the camera toggle's new state.
onDevice((kind: "camera" | "mic" | "speaker", id: string) => void)—A device was picked.
onTestSound(() => void)—Adds Play test sound.
onJoin((name: string) => void)—Gets the name.

Parts

Every element carries a stable name, so you can style it from your own CSS: [data-scope="prejoin"] [data-part="layout"]

layoutstack

RelatedLobbyMeeting room