Comparar commits

..

7 commits

Autor SHA1 Mensaje Fecha
Pau Figueras
9753ca4fd4 Remove default nav element, fix hamburger menu showing when no nav elements 2023-07-27 01:59:19 +02:00
Pau Figueras
1da26ece67 New svelte store 2023-07-27 01:58:40 +02:00
Pau Figueras
475e6217ed Square Menu component 2023-07-27 01:58:32 +02:00
Pau Figueras
094eefbd42 Add square menu, remove navbar elements 2023-07-27 01:58:24 +02:00
Pau Figueras
394d6eaaa7 Update deps 2023-07-27 01:58:06 +02:00
Pau Figueras
106ec485a2 Add custom screen sizes 2023-07-27 01:57:59 +02:00
Pau Figueras
fa860e4fb8 Add menuData type 2023-07-27 01:57:48 +02:00
S'han modificat 8 arxius amb 392 adicions i 335 eliminacions

La diferencia del archivo ha sido suprimido porque es demasiado grande Cargar Diff

Veure arxiu

@ -0,0 +1 @@
export type MenuData = {menuLink: string, menuName: string}

Veure arxiu

@ -1,18 +1,20 @@
<script lang="ts"> <script lang="ts">
import { NavbarObject } from "../classes/NavObject"; import type { NavbarObject } from "../classes/NavObject";
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger, DarkMode } from 'flowbite-svelte'; import { Navbar, NavBrand, NavLi, NavUl, NavHamburger, DarkMode } from 'flowbite-svelte';
export let navobjs: NavbarObject[] = [new NavbarObject('#', 'No nav elements provided')]; export let navobjs: NavbarObject[] = [];
export let pageTitle: string = "Default Title"; export let pageTitle: string = "Default Title";
export let toggleDarkModeButton: boolean = true; export let toggleDarkModeButton: boolean = true;
</script> </script>
<Navbar let:hidden let:toggle color="form" navDivClass="mx-auto flex flex-wrap justify-around items-center" navClass="px-4 md:px-2 py-2.5 w-full bg-zinc-200 dark:bg-zinc-900"> <Navbar let:hidden let:toggle color="form" navDivClass="mx-auto flex flex-wrap justify-between items-center" navClass="px-4 md:px-2 py-2.5 w-full bg-zinc-200 dark:bg-zinc-900">
<NavBrand href="/"> <NavBrand href="/">
<span class="self-center whitespace-nowrap text-xl font-semibold dark:text-white"> <span class="self-center whitespace-nowrap text-xl font-semibold dark:text-white">
{ pageTitle.toUpperCase() } { pageTitle.toUpperCase() }
</span> </span>
</NavBrand> </NavBrand>
<NavHamburger on:click={toggle} />
<div class="flex"> <div class="flex">
{#if navobjs.length !== 0}
<NavHamburger on:click={toggle} btnClass={'ml-3 lg:hidden'} />
{/if}
<NavUl {hidden}> <NavUl {hidden}>
{#each navobjs as navElem} {#each navobjs as navElem}
<NavLi href="{ navElem.link }">{ navElem.text }</NavLi> <NavLi href="{ navElem.link }">{ navElem.text }</NavLi>

12
src/lib/sqmenu.svelte Normal file
Veure arxiu

@ -0,0 +1,12 @@
<script lang="ts">
import { Card } from "flowbite-svelte";
export let menudata: {menuName: string, menuLink: string}[] = [];
$: colNum = Math.floor(menudata.length / 2) < 3 ? Math.floor(menudata.length / 2) : 3;
</script>
<div class="w-[60%] grid gap-y-8 grid-cols-{colNum} text-center mx-auto py-5 sm:grid-cols-1 justify-content-center">
{#each menudata as menu}
<Card href='{menu.menuLink}' class='lg:px-16 lg:py-8 md:px-12 md:py-6 dark:hover:bg-zinc-900 dark:bg-transparent bg-transparent min-w-[50%]'>
<h2 class='text-xl'>{menu.menuName}</h2>
</Card>
{/each}
</div>

3
src/lib/store.js Normal file
Veure arxiu

@ -0,0 +1,3 @@
import { readable, writable } from 'svelte/store';
export let navTitle = writable('Dashboard')

Veure arxiu

@ -1,11 +1,12 @@
<script lang="ts"> <script lang="ts">
import "../app.postcss"; import "../app.postcss";
import { NavbarObject } from "../classes/NavObject"; import { NavbarObject } from "../classes/NavObject";
import Navbar from "../lib/navbar.svelte"; import Navbar from "$lib/navbar.svelte";
import './styles.css'; import './styles.css';
import { navTitle } from "$lib/store";
let pageTitle: string = "pswsm meteo" let pageTitle: string = $navTitle ?? 'Default Title'
let navbarElements: NavbarObject[] = [new NavbarObject('/', 'Home'), new NavbarObject('/abtme', 'Sobre mi'), new NavbarObject('/temps', 'Temps'), new NavbarObject('/xema', 'Estacions'), new NavbarObject('/openmeteo', 'Dades Open Meteo')] // let navbarElements: NavbarObject[] = [new NavbarObject('/', 'Home'), new NavbarObject('/abtme', 'Sobre mi'), new NavbarObject('/temps', 'Temps'), new NavbarObject('/xema', 'Estacions'), new NavbarObject('/openmeteo', 'Dades Open Meteo')]
</script> </script>
<Navbar navobjs={navbarElements} pageTitle={pageTitle} /> <Navbar pageTitle={pageTitle} />
<slot></slot> <slot></slot>

Veure arxiu

@ -1,6 +1,10 @@
<script> <script lang="ts">
import Sqmenu from "$lib/sqmenu.svelte";
import type { MenuData } from "$lib/classes/menudata"
let menudata: MenuData[] = [{menuLink: '/abtme', menuName:'Sobre mi'}, {menuLink: '/temps', menuName:'Temps'}, {menuLink: '/xema', menuName:'Dades XEMA'}, {menuLink: '/openmeteo', menuName:'Dades Open Meteo'}]
// let menudata: MenuData[] = []
</script> </script>
<div class="p-8"> <div class="p-8">
<p>I Like trains</p> <Sqmenu {menudata} />
</div> </div>

Veure arxiu

@ -3,6 +3,16 @@ const config = {
theme: { theme: {
extend: {}, extend: {},
screens: {
'lg': {'min': '1024px'},
// => @media (max-width: 1023px) { ... }
'md': {'max': '1023px'},
// => @media (max-width: 767px) { ... }
'sm': {'max': '639px'},
// => @media (max-width: 639px) { ... }
}
}, },
plugins: [ plugins: [