dropdown box
This commit is contained in:
parent
74cc804c7d
commit
c2b98b3e84
@ -8,7 +8,7 @@
|
||||
<script type="module" src="/main.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body onload="load();">
|
||||
<div class="container">
|
||||
<h1>Welcome to Tauri!</h1>
|
||||
|
||||
@ -28,6 +28,21 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="dropdown">
|
||||
<button onclick="packSelect()" class="dropbtn">Dropdown</button>
|
||||
<div id="myDropdown" class="dropdown-content">
|
||||
<a href="#">Pack 1</a>
|
||||
<a href="#">Pack 2</a>
|
||||
<a href="#">Pack 3</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<select name="cars" id="Modpacks">
|
||||
<option value="volvo">Volvo</option>
|
||||
<option value="saab">Saab</option>
|
||||
<option value="mercedes">Mercedes</option>
|
||||
<option value="audi">Audi</option>
|
||||
</select>
|
||||
<p>Click on the Tauri logo to learn more about the framework</p>
|
||||
|
||||
<form class="row" id="greet-form">
|
||||
|
@ -5,7 +5,8 @@ let greetMsgEl;
|
||||
|
||||
async function greet() {
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
|
||||
greetMsgEl.textContent = "testing";
|
||||
//greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
@ -16,3 +17,44 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
greet();
|
||||
});
|
||||
});
|
||||
function packSelect() {
|
||||
document.getElementById("myDropdown").classList.toggle("show");
|
||||
|
||||
|
||||
}
|
||||
|
||||
function load() {
|
||||
console.log("loading");
|
||||
var dropdown = document.getElementById("Modpacks");
|
||||
var opt = document.createElement("option");
|
||||
opt.text = 'something';
|
||||
opt.value = 'somethings value';
|
||||
dropdown.options.add(opt);
|
||||
}
|
||||
|
||||
window.onload = async function() {
|
||||
invoke("get_modpacks").then(addModpacks);
|
||||
|
||||
}
|
||||
|
||||
function addModpacks(modpacks) {
|
||||
var dropdown = document.getElementById("Modpacks");
|
||||
var opt = document.createElement("option");
|
||||
opt.text = modpacks[0];
|
||||
opt.value = 'somethings value';
|
||||
dropdown.options.add(opt);
|
||||
}
|
||||
|
||||
|
||||
//window.onclick = function(event) {
|
||||
//if (!event.target.matches('.dropbtn')) {
|
||||
//var dropdowns = document.getElementsByClassName("dropdown-content");
|
||||
//var i;
|
||||
//for (i = 0; i < dropdowns.length; i++) {
|
||||
//var openDropdown = dropdowns[i];
|
||||
//if (openDropdown.classList.contains('show')) {
|
||||
//openDropdown.classList.remove('show');
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
@ -109,4 +109,43 @@ button {
|
||||
button:active {
|
||||
background-color: #0f0f0f69;
|
||||
}
|
||||
|
||||
.dropbtn {
|
||||
background-color: #3498DB;
|
||||
color: white;
|
||||
padding: 16px;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropbtn:hover, .dropbtn:focus {
|
||||
background-color: #2980B9;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
background-color: #f1f1f1;
|
||||
min-width: 160px;
|
||||
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.dropdown-content a {
|
||||
color: black;
|
||||
padding: 12px 16px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.dropdown-content a:hover {background-color: #DDD;}
|
||||
|
||||
.show {display:block;}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user