-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
SelectSource.svelte
81 lines (73 loc) 路 1.59 KB
/
SelectSource.svelte
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
<script lang="ts">
import { Microphone, Upload, Video } from "@gradio/icons";
export let sources: string[];
export let active_source: string;
export let handle_clear: () => void = () => {};
</script>
{#if sources.length > 1}
<span class="source-selection">
{#if sources.includes("upload")}
<button
class="icon"
class:selected={active_source === "upload"}
aria-label="Upload file"
on:click={() => {
handle_clear();
active_source = "upload";
}}><Upload /></button
>
{/if}
{#if sources.includes("microphone")}
<button
class="icon"
class:selected={active_source === "microphone"}
aria-label="Record audio"
on:click={() => {
handle_clear();
active_source = "microphone";
}}><Microphone /></button
>
{/if}
{#if sources.includes("webcam")}
<button
class="icon"
class:selected={active_source === "webcam"}
aria-label="Record video"
on:click={() => {
handle_clear();
active_source = "webcam";
}}><Video /></button
>
{/if}
</span>
{/if}
<style>
.source-selection {
display: flex;
align-items: center;
justify-content: center;
border-top: 1px solid var(--border-color-primary);
width: 95%;
bottom: 0;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
align-self: flex-end;
}
.icon {
width: 22px;
height: 22px;
margin: var(--spacing-lg) var(--spacing-xs);
padding: var(--spacing-xs);
color: var(--neutral-400);
border-radius: var(--radius-md);
}
.selected {
color: var(--color-accent);
}
.icon:hover,
.icon:focus {
color: var(--color-accent);
}
</style>