You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
inventory-app/templates/main.html

131 lines
4.4 KiB

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="light dark" />
<link rel="stylesheet" href="/css/main.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="/js/htmx.min.js"></script>
<!--TODO Vendor this script -->
<script
defer
src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"
></script>
<title>{% block title %}Title{% endblock %}</title>
</head>
<body
class="min-h-screen bg-slate-100 text-neutral-900 dark:bg-neutral-900 dark:text-slate-100"
>
<header class="top-0 w-full bg-slate-100 border-b border-neutral-600 border-opacity-90 font-sans">
<nav
class="mx-auto flex max-w-7xl justify-between gap-2 px-2 py-4 sm:px-6 lg:px-8"
>
<div>
<a
href="/home"
class="rounded-md bg-english-violet px-3 py-2 text-sm font-medium text-white"
>
Inventory App
</a>
</div>
<div>
<a
href="/overview"
class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white"
>
Overview
</a>
<a
href="/catalog"
class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white"
>
Catalog
</a>
<a
href="/upload"
class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white"
>
Upload
</a>
<a
href="/reports"
class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white"
>
Reports
</a>
<a
href="/history"
class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white"
>
History
</a>
</div>
</nav>
</header>
<main class="bg-slate-100 text-neutral-900 dark:bg-neutral-900 dark:text-slate-100">
<script>
function toastsHandler() {
return {
notices: [],
visible: [],
add(notice) {
notice.id = Date.now()
this.notices.push(notice)
this.fire(notice.id)
},
fire(id) {
this.visible.push(this.notices.find(notice => notice.id == id))
const timeShown = 2000 * this.visible.length
setTimeout(() => {
this.remove(id)
}, timeShown)
},
remove(id) {
const notice = this.visible.find(notice => notice.id == id)
const index = this.visible.indexOf(notice)
this.visible.splice(index, 1)
const index2 = this.notices.indexOf(notice)
this.notices.splice(index2, 1)
}
}
}
</script>
<div
x-data="toastsHandler()"
class="absolute flex flex-col justify-start h-full w-screen z-40 py-4"
@notice.window="add($event.detail)"
style="pointer-events:none">
<template x-for="notice of notices" :key="notice.id">
<div
x-show="visible.includes(notice)"
x-transition:enter="transition ease-in duration-200"
x-transition:enter-start="transform opacity-0 -translate-y-2"
x-transition:enter-end="transform opacity-100"
x-transition:leave="transition ease-out duration-500"
x-transition:leave-start="transform translate-y-0 opacity-100"
x-transition:leave-end="transform -translate-y-full opacity-0"
@click="remove(notice.id)"
class="rounded mb-4 mx-auto w-56 p-1 flex items-center justify-center text-white shadow-lg font-bold text-sm cursor-pointer"
:class="{
'bg-green-500': notice.type === 'info',
'bg-cerise': notice.type === 'error'
}"
style="pointer-events:all"
x-text="notice.text">
</div>
</template>
</div>
{% block content %}
<p>Content Missing</p>
{% endblock %}
</main>
<footer>
</footer>
</body>
</html>

Powered by TurnKey Linux.