JSFiddle - React, Tailwind, and code Playground
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Microphone Activation</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
overflow: hidden; /* Prevent vertical scrollbar */
}
#miniTaskbar {
position: fixed;
top: -30px; /* Initially hidden above the screen */
left: 0;
width: 100%;
height: 30px;
background-color: #333;
color: #fff;
display: flex;
justify-content: space-around;
align-items: center;
transition: top 0.3s;
cursor: pointer;
}
#miniTaskbar:hover,
#miniTaskbar.active {
top: 0;
}
.switch-container {
display: inline-block;
margin: 0 15px;
}
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 20px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 20px;
}
.slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 2px;
bottom: 2px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
.switch input:checked + .slider {
background-color: #2196F3;
}
.switch input:checked + .slider:before {
transform: translateX(20px);
}
</style>
</head>
<body>
<div id="miniTaskbar" onmouseleave="hideTaskbar()">
<div class="switch-container">
<label class="switch">
<input type="checkbox" onclick="toggleMicrophone()">
<span class="slider"></span>
</label>
Microphone
</div>
</div>
<script>
let isMicrophoneActive = false;
let audioContext;
...