Style dialog and buttons

This commit is contained in:
Leon Grünewald 2024-09-07 15:46:51 +02:00
parent 723b305064
commit 3ddbe83ad4
6 changed files with 169 additions and 54 deletions

View file

@ -3,6 +3,7 @@
import Header from "./lib/Header.svelte"; import Header from "./lib/Header.svelte";
import Stream from "./lib/Stream.svelte"; import Stream from "./lib/Stream.svelte";
import AddStreamDialog from "./lib/AddStreamDialog.svelte"; import AddStreamDialog from "./lib/AddStreamDialog.svelte";
import ManageStreamDialog from "./lib/ManageStreamDialog.svelte";
let streams = $state([]); let streams = $state([]);
let fracsX = $state(0); let fracsX = $state(0);
@ -39,6 +40,10 @@
fracsY = 3; fracsY = 3;
} }
}); });
function closeDialog() {
currentDialog = null;
}
</script> </script>
<main> <main>
@ -54,8 +59,13 @@
newUrl.searchParams.append(newStream.type, newStream.streamId); newUrl.searchParams.append(newStream.type, newStream.streamId);
window.history.pushState({}, null, newUrl); window.history.pushState({}, null, newUrl);
}} }}
close={() => closeDialog()}
></AddStreamDialog> ></AddStreamDialog>
{/if} {/if}
{#if currentDialog === "manage-streams"}
<ManageStreamDialog close={() => closeDialog()} bind:streams
></ManageStreamDialog>
{/if}
<!--{#if currentDialog === "remove-stream"} <!--{#if currentDialog === "remove-stream"}
<RemoveStreamDialog <RemoveStreamDialog
remove={(streamId) => { remove={(streamId) => {

View file

@ -2,3 +2,29 @@ body {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
input[type="text"] {
border: none;
border-radius: 3px;
text-align: center;
text-decoration: none;
background: white;
line-height: 2rem;
padding: 0 1rem;
vertical-align: middle;
width: auto;
color: #000000;
}
button {
border: none;
border-radius: 3px;
text-align: center;
text-decoration: none;
background: white;
line-height: 2rem;
padding: 0 1rem;
vertical-align: middle;
width: auto;
color: #000000;
}

View file

@ -1,15 +1,19 @@
<script> <script>
let { add } = $props(); import Dialog from "./Dialog.svelte";
let { add, close } = $props();
let step = $state(0); let step = $state(0);
let type = null; let type = null;
let streamId = $state("doggoat"); let streamId = $state("doggoat");
</script> </script>
<div class="add-stream-dialog"> <Dialog close={() => close()}>
<div class="add-stream-dialog">
{#if step === 0} {#if step === 0}
<div> <div class="step-0">
<h2>Add stream</h2> <h2>Add stream</h2>
<div class="buttons">
<button <button
onclick={() => { onclick={() => {
type = "vdo"; type = "vdo";
@ -23,16 +27,23 @@
}}>Twitch</button }}>Twitch</button
> >
</div> </div>
</div>
{/if} {/if}
{#if step === 1} {#if step === 1}
<div> <div class="step-1">
<h2>Add stream</h2>
<p> <p>
Example:<br /> Example:<br />
https://vdo.ninja/?view=<strong>doggoat</strong https://vdo.ninja/?view=<strong>doggoat</strong
>&bitrate=4500&proaudio<br /> >&bitrate=4500&proaudio<br />
https://www.twitch.tv/<strong>saltybet</strong> https://www.twitch.tv/<strong>saltybet</strong>
</p> </p>
<label>Stream ID: <input bind:value={streamId} /></label> <label
>Stream ID: <input
type="text"
bind:value={streamId}
/></label
>
<button <button
onclick={() => { onclick={() => {
add({ type, streamId }); add({ type, streamId });
@ -41,17 +52,20 @@
> >
</div> </div>
{/if} {/if}
</div> </div>
</Dialog>
<style> <style>
.add-stream-dialog { .add-stream-dialog {
padding: 1rem; h2 {
background-color: #0000000a; text-align: center;
position: absolute; margin: 0 0 0.75rem 0;
width: 50vh; }
height: 50vh;
top: 50%; .buttons {
left: 50%; display: grid;
transform: translate(-50%, -50%); justify-content: center;
gap: 0.25rem;
}
} }
</style> </style>

43
src/lib/Dialog.svelte Normal file
View file

@ -0,0 +1,43 @@
<script>
let { children, close } = $props();
</script>
<div class="dialog">
<button
class="close"
onclick={() => {
if (close) close();
}}>x</button
>
{@render children()}
</div>
<style>
.dialog {
padding: 1rem;
position: absolute;
width: 50vw;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
border: none;
border-radius: 3px;
/*
* Created with https://www.css-gradient.com
* Gradient link: https://www.css-gradient.com/?c1=0b49d0&c2=8e0871&gt=l&gd=dtl
*/
background: #0b49d0;
background: linear-gradient(135deg, #0b49d0, #8e0871);
.close {
position: absolute;
top: 0.5rem;
left: 0.5rem;
padding: 0 0.5rem;
line-height: 1.25rem;
}
}
</style>

View file

@ -4,6 +4,11 @@
currentDialog = $bindable(null), currentDialog = $bindable(null),
containerElement = $bindable(null), containerElement = $bindable(null),
} = $props(); } = $props();
const buttons = [
{ key: "add-stream", label: "Add Stream" },
{ key: "manage-streams", label: "Manage Streams" },
];
</script> </script>
<header> <header>
@ -13,13 +18,15 @@
}}>[{showButtons ? "<" : ">"}]</button }}>[{showButtons ? "<" : ">"}]</button
> >
{#if showButtons} {#if showButtons}
{#each buttons as { key, label }}
<button <button
onclick={() => { onclick={() => {
currentDialog = "add-stream"; currentDialog = key;
}} }}
> >
Add Stream</button {label}</button
> >
{/each}
{/if} {/if}
</header> </header>
@ -27,6 +34,7 @@
header { header {
width: 100vw; width: 100vw;
display: flex; display: flex;
flex-flow: row nowrap;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;

View file

@ -0,0 +1,14 @@
<script>
import Dialog from "./Dialog.svelte";
let { streams = $bindable(null), close } = $props();
</script>
<Dialog close={() => close()}>
<pre>
{JSON.stringify(streams)}
</pre>
</Dialog>
<style>
</style>