From 2cbef5637731a8ca697acc3b2f9c959597953c9e Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Sat, 12 Oct 2024 03:32:28 +0200 Subject: [PATCH] feat: header and utenti page mobile friendly --- src/client/ComboBox.tsx | 8 +++-- src/client/lib/util.ts | 12 +++++++ src/components/Header.astro | 21 ++++++++++- src/styles/components.scss | 14 ++++++++ src/styles/controls.scss | 12 +++++++ src/styles/main.scss | 71 +++++++++++++++++++++++++++++++++++++ 6 files changed, 135 insertions(+), 3 deletions(-) diff --git a/src/client/ComboBox.tsx b/src/client/ComboBox.tsx index 81c65fe..be2b008 100644 --- a/src/client/ComboBox.tsx +++ b/src/client/ComboBox.tsx @@ -1,6 +1,6 @@ import { type ComponentChildren } from 'preact' import { useState, useRef, useEffect } from 'preact/hooks' -import { clsx } from './lib/util' +import { clsx, isMobile } from './lib/util' export const ComboBox = ({ value, @@ -33,7 +33,11 @@ export const ComboBox = ({ }, []) return ( -
+
setOpen(!open)}>
{children[value]}
expand_more diff --git a/src/client/lib/util.ts b/src/client/lib/util.ts index 38450a9..6bb94f8 100644 --- a/src/client/lib/util.ts +++ b/src/client/lib/util.ts @@ -1,3 +1,5 @@ +import { useEffect, useMemo, useState } from 'preact/hooks' + export const trottleDebounce = ( fn: (...args: T) => R, delay: number, @@ -52,3 +54,13 @@ export function clsx(...args: ClassValue[]): string { }) .join(' ') } + +export const isMobile = () => { + const [windowWidth, setWindowWidth] = useState(0) + + useEffect(() => { + setWindowWidth(window.innerWidth) + }, []) + + return windowWidth < 1024 +} diff --git a/src/components/Header.astro b/src/components/Header.astro index bd2effd..200bc68 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -2,7 +2,8 @@ -