@hogoshi/ui 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogoshi/ui",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3,7 +3,7 @@
3
3
  import { Button as BaseButton } from "@base-ui/react/button";
4
4
  import { NavigationMenu } from "@base-ui/react/navigation-menu";
5
5
  import { ArrowDown01Icon } from "@hugeicons-pro/core-stroke-rounded";
6
- import type { ComponentProps, ReactNode } from "react";
6
+ import { useEffect, useState, type ComponentProps, type ReactNode } from "react";
7
7
  import { cn } from "../lib/cn";
8
8
  import { Glide, glideActive } from "./glide";
9
9
  import type { AppIcon } from "./icon";
@@ -14,6 +14,37 @@ const itemClass =
14
14
 
15
15
  const motion = "duration-[calc(var(--motion-duration)*3)] ease-[var(--motion-ease)] motion-reduce:transition-none";
16
16
 
17
+ export function TopBar({ contained = false, children, className }: { contained?: boolean; children: ReactNode; className?: string }) {
18
+ const [compact, setCompact] = useState(false);
19
+
20
+ useEffect(() => {
21
+ const root = document.querySelector("[data-scroll-root]");
22
+ const read = () => {
23
+ const top = root instanceof HTMLElement ? root.scrollTop : window.scrollY;
24
+ setCompact(top > 24);
25
+ };
26
+ read();
27
+ const target: EventTarget = root instanceof HTMLElement ? root : window;
28
+ target.addEventListener("scroll", read, { passive: true });
29
+ return () => target.removeEventListener("scroll", read);
30
+ }, []);
31
+
32
+ return (
33
+ <header className={cn("pointer-events-none inset-x-0 top-0 z-[var(--z-sticky)] flex justify-center", contained ? "absolute" : "fixed", className)}>
34
+ <div
35
+ className={cn(
36
+ "pointer-events-auto flex items-center transition-[width,height,margin,border-radius,background-color,border-color,box-shadow] duration-500 ease-[var(--motion-ease)] motion-reduce:transition-none",
37
+ compact
38
+ ? "border-border bg-bg-elevated mt-[calc(var(--safe-top)+0.75rem)] h-12 w-[min(40rem,calc(100%-1.5rem))] rounded-full border px-2 shadow-[var(--shadow-md)]"
39
+ : "mt-[calc(var(--safe-top)+0.5rem)] h-14 w-full border border-transparent bg-transparent px-3",
40
+ )}
41
+ >
42
+ <Navbar className="relative h-full w-full bg-transparent px-1 shadow-none backdrop-blur-none">{children}</Navbar>
43
+ </div>
44
+ </header>
45
+ );
46
+ }
47
+
17
48
  export function Navbar({ className, children, ...props }: ComponentProps<"header">) {
18
49
  return (
19
50
  <header
package/src/index.ts CHANGED
@@ -29,7 +29,7 @@ export type { SortDirection } from "./components/table";
29
29
  export { Progress } from "./components/progress";
30
30
  export { Logo } from "./components/logo";
31
31
  export { LOGO_PATH, LOGO_VIEWBOX, logoSvg } from "./components/logo-mark";
32
- export { Navbar, NavbarItem, NavbarMenu, NavbarMenuLink, NavbarMenus } from "./components/navbar";
32
+ export { Navbar, NavbarItem, NavbarMenu, NavbarMenuLink, NavbarMenus, TopBar } from "./components/navbar";
33
33
  export { Glide, glideActive } from "./components/glide";
34
34
  export type { GlideProps } from "./components/glide";
35
35
  export { Calendar } from "./components/calendar";