File size: 2,624 Bytes
9dfbb06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<script lang="ts">
	import { onMount } from "svelte";
	import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";

	export let record: RecordPlugin;
	export let dispatch: (event: string, detail?: any) => void;

	let recordButton: HTMLButtonElement;
	let stopButton: HTMLButtonElement;

	onMount(() => {
		recordButton = document.getElementById("record") as HTMLButtonElement;
		stopButton = document.getElementById("stop") as HTMLButtonElement;
	});

	function record_click() {
		if (isRecording) {
			record.stopRecording();
			dispatch("stop_recording");
		} else {
			record.startRecording();
			dispatch("start_recording");
		}
		isRecording = !isRecording;
	}

	let isRecording = false;
</script>

	<div class="wrapper">
		{#if !isRecording}
			<button
				bind:this={recordButton}
				class="record-button"
				on:click={record_click}
			>
				<div class="microphone-icon">
					<img
					width="200"
					height="200"
					src="https://img.icons8.com/material-rounded/200/microphone.png"
					alt="microphone"
					/>
				</div>
			</button>
		{:else}
			<button
				bind:this={stopButton}
				class="stop-button"
				on:click={record_click}
			>
				<div class="stop-icon pulsate">
					<img
					width="200"
					height="200"
					src="https://img.icons8.com/material-rounded/200/stop.png"
					alt="stop"
					/>
				</div>
			</button>
		{/if}
	</div>

<style>
	.wrapper {
		display: flex;
		align-items: center;
		justify-content: center;
		align-items: center;
		border-radius: 50px;
	}

	.microphone-icon {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.stop-icon {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.record-button {
		height: 350px;
		width: 350px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: white;
		border: 6px solid rgb(0, 140, 255);
	}

	.stop-button {
		height: 350px;
		width: 350px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: white;
		border: 6px solid red;
	}


  @keyframes pulsate {
    0% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.1);
    }
    100% {
      transform: scale(1);
    }
  }

  .pulsate {
    animation: pulsate 1s infinite;
  }

	.record-button:disabled {
		cursor: not-allowed;
		opacity: 0.5;
	}

	@keyframes scaling {
		0% {
			background-color: var(--primary-600);
			scale: 1;
		}
		50% {
			background-color: var(--primary-600);
			scale: 1.2;
		}
		100% {
			background-color: var(--primary-600);
			scale: 1;
		}
	}
</style>