<div class="container h-full mx-auto flex justify-center items-center flex-col">
    <h1 class="my-3">Blackbird Chess</h1>

    {#if message.visible}
        <aside class="alert variant-filled-error">
            <!-- Icon -->
            <div><i class="text-2xl icon icon-exclamation-triangle"></i></div>
            <!-- Message -->
            <p class="alert-message">{message.text}</p>
            <!-- Actions -->
            <div class="alert-actions">
                <i on:click={closeWarning} class="icon icon-close"></i>
            </div>
        </aside>
    {/if}

    <Server on:message={showMessage}/>
</div>

<style lang="scss">

</style>

<script lang="js">
    import { urls, serverurl } from "../../stores.js";
    import login from './Login.svelte'
    import Server  from './Server.svelte'

    let message = {
        visible: false,
        text: '',
        class: 'error'
    };
    var myserver

    serverurl.subscribe(value => {
        myserver = value;
    });

    function closeWarning() {
        message.visible = false;
    }

    function showMessage(error) {
        console.log(error);
        message.text = error.detail.text;
        message.class = 'error'
        message.visible = true;
    }
</script>