website/src/components/header.lisp

72 lines
2.6 KiB
Common Lisp
Raw Normal View History

2025-05-02 09:39:55 +09:00
(defpackage #:website/components/header
2025-05-02 01:31:26 +09:00
(:use #:cl
2025-05-04 00:26:49 +09:00
#:hsx
#:jingle)
2025-05-02 01:31:26 +09:00
(:export #:~header))
2025-05-02 09:39:55 +09:00
(in-package #:website/components/header)
2025-05-02 01:31:26 +09:00
(defparameter *nav-menu*
2025-05-03 13:26:31 +09:00
'(("/about" "about")
2025-05-02 01:31:26 +09:00
("/work" "work")
("/blog" "blog")))
2025-05-03 13:01:49 +09:00
(defcomp ~pc-header ()
2025-05-02 01:31:26 +09:00
(hsx
(header :class "hidden md:flex justify-between py-4 border-b-1 top-0 bg-white"
(h1 :class "z-20 text-3xl font-bold"
2025-05-04 01:35:09 +09:00
(a :preload "mouseover" :href "/" "skyizwhite"))
(nav :class "flex items-end"
(ul :preload "mouseover" :class "flex gap-4 text-xl font-medium"
2025-05-02 01:31:26 +09:00
(loop
:for (href label) :in *nav-menu* :collect
2025-05-05 02:07:41 +09:00
(if (string= href (request-uri *request*))
2025-05-04 00:38:07 +09:00
(hsx (li :class "text-pink-500" label))
(hsx (li (a :href href :class "hover:text-pink-500" label))))))))))
2025-05-03 13:01:49 +09:00
(defcomp ~sp-header ()
2025-05-03 13:01:49 +09:00
(hsx
(header
2025-05-04 00:38:07 +09:00
:id "sp-header" :x-data "{ open: false }"
:class "flex md:hidden justify-between py-2 border-b-1 top-0 bg-white"
(h1 :class "z-20 text-2xl font-bold"
2025-05-04 01:35:09 +09:00
(a :preload "mousedown" :href "/" "skyizwhite"))
(div
(button
:class "z-20 size-8 flex flex-col justify-center cursor-pointer relative"
:type "button"
:@click "open = !open"
(div :class "grid justify-items-center gap-1.5"
(span
:class "h-1 w-8 rounded-full bg-black transition duration-400"
:|:class| "open && 'rotate-45 translate-y-2.5'")
(span
:class "h-1 w-8 rounded-full bg-black transition duration-400"
:|:class| "open && 'scale-x-0'")
(span
:class "h-1 w-8 rounded-full bg-black transition duration-400"
:|:class| "open && '-rotate-45 -translate-y-2.5'")))
(nav
:class (<>
"fixed flex flex-col items-center justify-center "
"z-10 top-0 right-0 w-full h-full gap-16 bg-gray-200")
:x-show "open"
2025-05-04 15:21:25 +09:00
:x-transition.opacity t
:|x-transition:enter.duration.300ms| t
:|x-transition:leave.duration.300ms| t
(h2 :class "text-5xl font-bold"
"Menu")
(ul
:preload "mousedown"
:class "flex flex-col h-fit gap-8 text-3xl font-medium"
(loop
:for (href label) :in (append '(("/" "home")) *nav-menu*) :collect
2025-05-05 02:07:41 +09:00
(if (string= href (request-uri *request*))
(hsx (li :class "text-pink-500" label))
(hsx (li (a :href href :class "hover:text-pink-500" label)))))))))))
(defcomp ~header ()
(hsx
(<>
2025-05-03 13:01:49 +09:00
(~pc-header)
(~sp-header))))