|
| 1 | +# Create Your Own UI Sample |
| 2 | + |
| 3 | +This sample demonstrates how to create a custom meeting UI using Cloudflare RealtimeKit with vanilla HTML, CSS, and JavaScript. It showcases custom components for setup screen, in-meeting experience, control bar, sidebar, and media preview functionality. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Custom Setup Screen**: Participant preview with media settings |
| 8 | +- **Media Preview Modal**: Audio and video device selection with preview |
| 9 | +- **Custom Control Bar**: Meeting controls with custom sidebar toggle |
| 10 | +- **Custom Sidebar**: Standard tabs (chat, participants, polls, plugins) plus custom "warnings" tab |
| 11 | +- **Custom Meeting Header**: Logo, indicators, meeting title, and controls |
| 12 | +- **Responsive Design**: Built with Tailwind CSS for modern UI |
| 13 | +- **State Management**: Uses simple reactive state implementation |
| 14 | +- **No Build Steps**: Pure HTML/CSS/JS implementation |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | + |
| 20 | +- A valid Cloudflare RealtimeKit auth token |
| 21 | +- A local web server (like `serve` or `live-server`) |
| 22 | + |
| 23 | +### Installation |
| 24 | + |
| 25 | +1. Clone or download this repository |
| 26 | +2. Navigate to the `html-samples` directory |
| 27 | +3. Install dependencies (optional, for development server): |
| 28 | + ```bash |
| 29 | + npm install |
| 30 | + ``` |
| 31 | + |
| 32 | +### Running the Sample |
| 33 | + |
| 34 | +1. Start a local server: |
| 35 | + ```bash |
| 36 | + npx serve samples/create-your-own-ui |
| 37 | + ``` |
| 38 | + |
| 39 | +2. Open your browser and navigate to: |
| 40 | + ``` |
| 41 | + http://localhost:3000/?authToken=<your-auth-token> |
| 42 | + ``` |
| 43 | + |
| 44 | + Replace `<your-auth-token>` with your actual Cloudflare RealtimeKit auth token. |
| 45 | + |
| 46 | +## Project Structure |
| 47 | + |
| 48 | +``` |
| 49 | +create-your-own-ui/ |
| 50 | +├── index.html # Main HTML file |
| 51 | +├── store.js # Simple reactive state management |
| 52 | +├── utils.js # Utility functions |
| 53 | +├── types.js # Type definitions |
| 54 | +├── components/ # Component files |
| 55 | +│ ├── setup-screen.js/css # Custom setup screen |
| 56 | +│ ├── custom-rtk-meeting.js/css # Main meeting wrapper |
| 57 | +│ ├── in-meeting.js/css # In-meeting layout |
| 58 | +│ ├── meeting-header.js/css # Meeting header |
| 59 | +│ ├── meeting-control-bar.js/css # Control bar |
| 60 | +│ ├── meeting-sidebar.js/css # Custom sidebar |
| 61 | +│ ├── media-preview-modal.js/css # Media preview |
| 62 | +│ ├── audio-preview.js/css # Audio device preview |
| 63 | +│ └── video-preview.js/css # Video device preview |
| 64 | +└── README.md # This file |
| 65 | +``` |
| 66 | + |
| 67 | +## Key Components |
| 68 | + |
| 69 | +### Setup Screen |
| 70 | +- Participant tile with avatar and name tag |
| 71 | +- Audio visualizer |
| 72 | +- Mic/camera toggles |
| 73 | +- Media preview modal access |
| 74 | +- Name editing (if permitted) |
| 75 | +- Join button |
| 76 | + |
| 77 | +### Media Preview Modal |
| 78 | +- Tabbed interface for audio/video settings |
| 79 | +- Device selection dropdowns |
| 80 | +- Audio visualizer for microphone |
| 81 | +- Video preview tile |
| 82 | +- Speaker test functionality |
| 83 | + |
| 84 | +### Control Bar |
| 85 | +- Left: Fullscreen, settings, screen share |
| 86 | +- Center: Mic, camera, stage, leave, more menu |
| 87 | +- Right: Chat, polls, participants, plugins, custom sidebar toggle |
| 88 | + |
| 89 | +### Custom Sidebar |
| 90 | +- Standard RTK tabs: chat, participants, polls, plugins |
| 91 | +- Custom "warnings" tab with example content |
| 92 | +- Responsive design |
| 93 | + |
| 94 | +## Customization |
| 95 | + |
| 96 | +### Adding New Components |
| 97 | +1. Create `.js` and `.css` files in the `components/` directory |
| 98 | +2. Add script and link tags to `index.html` |
| 99 | +3. Implement the component using the module pattern |
| 100 | +4. Ensure proper cleanup in the component's cleanup function |
| 101 | + |
| 102 | +### State Management |
| 103 | +- Use `window.StatesStore.statesStore` for RTK states |
| 104 | +- Use `window.StatesStore.customStatesStore` for custom states |
| 105 | +- Subscribe to state changes using `window.StatesStore.subscribe()` |
| 106 | + |
| 107 | +### Styling |
| 108 | +- Uses Tailwind CSS via CDN |
| 109 | +- Component-specific styles in individual CSS files |
| 110 | +- Dark theme with consistent color scheme |
| 111 | + |
| 112 | +## Dependencies |
| 113 | + |
| 114 | +- **Cloudflare RealtimeKit**: Core meeting functionality |
| 115 | +- **Cloudflare RealtimeKit UI**: Pre-built UI components |
| 116 | +- **Simple Reactive State**: Custom reactive state implementation |
| 117 | +- **Tailwind CSS**: Utility-first CSS framework |
| 118 | + |
| 119 | +All dependencies are loaded via CDN, no build process required. |
| 120 | + |
| 121 | +## Browser Support |
| 122 | + |
| 123 | +This sample works in modern browsers that support: |
| 124 | +- ES6 modules |
| 125 | +- Custom elements |
| 126 | +- WebRTC |
| 127 | +- Modern CSS features |
| 128 | + |
| 129 | +## Troubleshooting |
| 130 | + |
| 131 | +### Common Issues |
| 132 | + |
| 133 | +1. **Auth Token Error**: Ensure you're passing a valid `authToken` in the URL |
| 134 | +2. **Components Not Loading**: Check browser console for script loading errors |
| 135 | +3. **State Not Updating**: Verify reactive state subscriptions are properly set up |
| 136 | +4. **Media Devices**: Ensure browser permissions for camera/microphone access |
| 137 | + |
| 138 | +### Debug Mode |
| 139 | + |
| 140 | +The meeting object is exposed on `window.meeting` for debugging purposes. Open browser dev tools and inspect the meeting object to troubleshoot issues. |
| 141 | + |
| 142 | +### State Subscription Issues |
| 143 | + |
| 144 | +If components aren't updating when states change, ensure you're subscribing to the store object, not the nested states: |
| 145 | +- ✅ `window.StatesStore.subscribe(statesStore, callback)` |
| 146 | +- ❌ `window.StatesStore.subscribe(statesStore.states, callback)` |
| 147 | + |
| 148 | +## License |
| 149 | + |
| 150 | +This sample is provided as-is for demonstration purposes. |
0 commit comments