Refactors layout using tailwind
Ugly but more responsive column design.
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
@tailwind utilities;
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div
|
||||
class="h-full bg-neutral-400 text-neutral-800 dark:bg-neutral-800 dark:text-neutral-400"
|
||||
class="min-h-screen bg-neutral-400 text-neutral-800 dark:bg-neutral-800 dark:text-neutral-400"
|
||||
>
|
||||
<div class="container mx-auto flex h-full flex-col">%sveltekit.body%</div>
|
||||
<div class="container mx-auto flex min-h-screen flex-col px-4 md:px-8">
|
||||
%sveltekit.body%
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -4,6 +4,8 @@ logo: 'icon-any.svg'
|
||||
icon: 'fa fa-cloud'
|
||||
asmask: true
|
||||
|
||||
columns: 4
|
||||
|
||||
links:
|
||||
- title: 'Cloud'
|
||||
icon: 'fa fa-cloud'
|
||||
@@ -24,6 +26,7 @@ services:
|
||||
- title: 'Sonarr'
|
||||
url: 'http://sonarr.lan'
|
||||
type: sonarr
|
||||
api_key: 43f13770f9a0419bbdc3224dae76e886
|
||||
keywords: 'shows tracker torrent usenet'
|
||||
|
||||
- title: 'Radarr'
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
<div class="flex flex h-12 w-12 flex-row text-4xl">
|
||||
<Brand brand={brand()} />
|
||||
</div>
|
||||
<div>
|
||||
<div class="h-12">
|
||||
<p class="text-xl">{service.title}</p>
|
||||
<p class="text-md">
|
||||
<p class="text-md min-h-12">
|
||||
{subtitle()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mr-6 mt-2 h-7 overflow-hidden pl-20">
|
||||
<div class="min-h-7 mr-6 mt-2 h-7 overflow-hidden pl-20">
|
||||
{#if component != undefined}
|
||||
<svelte:component this={component} {data} />
|
||||
{/if}
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
export let group: ServiceGroupConfig;
|
||||
export let groupData: Array<unknown>;
|
||||
export let columns: number;
|
||||
|
||||
function renderClasses(columns: number, direction: LayoutDirection): string {
|
||||
if (direction === 'column') {
|
||||
return 'flex flex-col';
|
||||
}
|
||||
switch (columns) {
|
||||
case 1:
|
||||
return 'grid grid-cols-1';
|
||||
case 2:
|
||||
return 'grid grid-cols-1 md:grid-cols-2';
|
||||
case 3:
|
||||
return 'grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3';
|
||||
default:
|
||||
return 'grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4';
|
||||
}
|
||||
}
|
||||
|
||||
$: layoutClasses = renderClasses(columns, $layoutDirection);
|
||||
</script>
|
||||
|
||||
<div>
|
||||
@@ -18,20 +36,9 @@
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class={'gap-4' + ' layout-' + $layoutDirection} style={'--columns: ' + columns}>
|
||||
<div class="gap-4 {layoutClasses}">
|
||||
{#each group.items as service, i}
|
||||
<ServiceCard {service} data={groupData[i]} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.layout-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
|
||||
}
|
||||
.layout-column {
|
||||
display: flex;
|
||||
flex-flow: row wrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,24 +1,49 @@
|
||||
<script lang="ts">
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import ServiceGroup from '$lib/components/ServiceGroup.svelte';
|
||||
import { layoutDirection } from '$lib/stores/layout';
|
||||
import { layoutDirection, type LayoutDirection } from '$lib/stores/layout';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
function renderClasses(columns: number, direction: LayoutDirection): string {
|
||||
if (direction === 'row') {
|
||||
switch (columns) {
|
||||
case 1:
|
||||
return 'grid grid-rows-1';
|
||||
case 2:
|
||||
return 'grid grid-rows-1 md:grid-rows-2';
|
||||
case 3:
|
||||
return 'grid grid-rows-1 md:grid-rows-2 xl:grid-rows-3';
|
||||
default:
|
||||
return 'grid grid-rows-1 md:grid-rows-2 xl:grid-rows-3 2xl:grid-rows-4';
|
||||
}
|
||||
}
|
||||
switch (columns) {
|
||||
case 1:
|
||||
return 'grid grid-cols-1';
|
||||
case 2:
|
||||
return 'grid grid-cols-1 md:grid-cols-2';
|
||||
case 3:
|
||||
return 'grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3';
|
||||
default:
|
||||
return 'grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4';
|
||||
}
|
||||
}
|
||||
|
||||
$: columns = Math.min(data.config.columns, data.config.services.length);
|
||||
$: layoutClasses = renderClasses(columns, $layoutDirection);
|
||||
</script>
|
||||
|
||||
<Header section={data.config} links={data.config.links} />
|
||||
|
||||
<main
|
||||
class={'container mb-auto mt-20 gap-4 transition-all' + ' layout-' + $layoutDirection}
|
||||
style={'--columns:' + data.config.columns}
|
||||
>
|
||||
<main class="mb-auto mt-16 gap-12 {layoutClasses}" style="--columns: {data.config.columns}">
|
||||
{#each data.config.services as group, i}
|
||||
<ServiceGroup {group} groupData={data.serviceData[i]} columns={data.config.columns} />
|
||||
<ServiceGroup {group} groupData={data.serviceData[i]} {columns} />
|
||||
{/each}
|
||||
</main>
|
||||
|
||||
<footer class="flex h-8 w-full flex-row">
|
||||
<footer class="mt-12 flex h-8 w-full flex-row">
|
||||
<div class="mx-auto">
|
||||
Made with ♥ by atuleu. Your IP: {data.location}.
|
||||
{#if data.privateAccess === true}
|
||||
@@ -28,14 +53,3 @@
|
||||
{/if}
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
.layout-column {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
|
||||
}
|
||||
.layout-row {
|
||||
display: grid;
|
||||
grid-template-rows: repeat(var(--columns), minmax(0, 1fr));
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user