Appearance
Peripheral Devices Component Documentation
Overview
The Peripheral Devices component provides an interface for managing and interacting with connected peripheral devices in a video conferencing application. It displays available peripherals and allows users to select active devices.
Key Features
Peripheral Device Management:
- Displays connected peripheral devices
- Shows active device state
- Provides visual feedback for selection
Device Information:
- Device icons and names
- Active/inactive state visualization
- Loading state for device enumeration
User Interaction:
- Device selection
- Panel closing
- Empty state handling
Component Structure
Module Context (API Functions)
typescript
export async function getActivePeripheral(command: {
deviceTypeId: string;
deviceIds: string[];
}) {
// Queries server for active peripheral status
}
export async function loadPeripherals() {
// Loads available peripheral types from server
}Props
typescript
export let selectedId = ""; // Currently selected peripheral ID
export let peripherals: IPeripheral[]; // Array of peripheral devicesState Management
typescript
let load = true; // Loading state flagUI Components
Main Panel Structure
svelte
<aside class="bg-white flex flex-col h-full">
<!-- Header -->
<div class="flex justify-between border-b px-4 py-2">
<span class="font-semibold">Peripherals</span>
<button on:click={() => dispatch("close")}>
<Icon src={Close} size="21" />
</button>
</div>
<!-- Content States -->
{#if load}
<Progress step={1} /> <!-- Loading indicator -->
{:else if peripherals.length}
<!-- Peripheral Grid -->
<div class="grid grid-cols-2 gap-4">
{#each peripherals as peripheral}
<!-- Peripheral Item -->
{/each}
</div>
{:else}
<!-- Empty State -->
<div class="bg-orange-200 p-4 rounded-lg">
No peripherals available
</div>
{/if}
</aside>Peripheral Item
svelte
<button
on:click={() => dispatch("activePeripheral", id)}
class:text-blue-500={isActive}
class:loginbox={isActive}
class:shadow-sm={!isActive}
class:bg-blue-50={isActive}
class:border={!isActive}
class:border-gray-300={!isActive}
class:hover:bg-gray-100={!isActive}
>
<iconify-icon {icon} style="font-size: 30px;" />
<p class="text-center text-sm">{name}</p>
</button>Technical Implementation
Data Flow
Initialization:
- Shows loading state
- Receives peripherals via props
- Updates UI when data loads
User Interaction:
- Clicking a peripheral dispatches
activePeripheralevent - Clicking close button dispatches
closeevent - Visual feedback for active device
- Clicking a peripheral dispatches
Event Handling
Component Events:
close: Requests panel closureactivePeripheral: Notifies of peripheral selection
UI Interactions:
- Peripheral selection
- Panel closing
Usage Example
svelte
<script>
import Peripherals from "./peripherals.svelte";
let peripherals = [
{ id: "1", name: "Stethoscope", icon: "medical-icon" },
{ id: "2", name: "Headphones", icon: "audio-icon" }
];
let selectedPeripheralId = "1";
function handlePeripheralSelect(event) {
selectedPeripheralId = event.detail;
// Handle peripheral activation
}
</script>
<Peripherals
bind:selectedId={selectedPeripheralId}
{peripherals}
on:close={closePanel}
on:activePeripheral={handlePeripheralSelect}
/>Dependencies
@steeze-ui/svelte-iconfor icons@steeze-ui/remix-icons(Close)- Custom
Progresscomponent - Server query utilities
- Iconify for device icons
Styling Notes
- Clean white background with subtle borders
- Grid layout for peripherals
- Blue accent for active device
- Hover states for interactive elements
- Responsive padding and spacing
- Visual loading indicator
Accessibility Features
- Semantic HTML structure
- Clear visual feedback for interactions
- Sufficient contrast for text
- Focus states for interactive elements
- ARIA attributes for icons (recommended addition)