@hogoshi/ui 0.1.3 → 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.3",
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
@@ -18,9 +18,9 @@ const SideContext = createContext<SheetSide>("right");
18
18
  const direction = { top: "up", right: "right", bottom: "down", left: "left" } as const;
19
19
 
20
20
  const edge = {
21
- top: "top-[max(0.75rem,var(--safe-top))]",
21
+ top: "top-[calc(var(--safe-top)+0.75rem)]",
22
22
  right: "right-[max(0.75rem,var(--safe-right))]",
23
- bottom: "bottom-[max(0.75rem,var(--safe-bottom))]",
23
+ bottom: "bottom-2",
24
24
  left: "left-[max(0.75rem,var(--safe-left))]",
25
25
  };
26
26
 
@@ -41,7 +41,7 @@ export function Sidebar({ className, ...props }: ComponentProps<"aside">) {
41
41
  <aside
42
42
  data-collapsed={collapsed || undefined}
43
43
  className={cn(
44
- "bg-bg-elevated border-border hidden h-full min-h-0 w-[calc(15rem+var(--safe-left))] shrink-0 flex-col overflow-hidden border-r pt-[var(--safe-top)] pb-[var(--safe-bottom)] pl-[var(--safe-left)] transition-[width] duration-[var(--motion-duration)] ease-[var(--motion-ease)] md:flex",
44
+ "bg-bg-elevated border-border hidden h-full min-h-0 w-[calc(15rem+var(--safe-left))] shrink-0 flex-col overflow-hidden border-r pt-[calc(var(--safe-top)+0.5rem)] pb-2 pl-[var(--safe-left)] transition-[width] duration-[var(--motion-duration)] ease-[var(--motion-ease)] md:flex",
45
45
  collapsed && "w-[calc(3.5rem+var(--safe-left))]",
46
46
  className,
47
47
  )}
@@ -154,7 +154,7 @@ export function BottomBar({ className, children, ...props }: ComponentProps<"nav
154
154
  return (
155
155
  <nav
156
156
  className={cn(
157
- "bg-bg-elevated/70 border-border fixed right-[max(0.75rem,var(--safe-right))] bottom-[max(0.5rem,var(--safe-bottom))] left-[max(0.75rem,var(--safe-left))] z-[var(--z-sticky)] rounded-[var(--radius-lg)] border p-1 shadow-[var(--shadow-md)] backdrop-blur-xl md:hidden",
157
+ "bg-bg-elevated/70 border-border fixed right-[max(0.75rem,var(--safe-right))] bottom-2 left-[max(0.75rem,var(--safe-left))] z-[var(--z-sticky)] rounded-[var(--radius-lg)] border p-1 shadow-[var(--shadow-md)] backdrop-blur-xl md:hidden",
158
158
  className,
159
159
  )}
160
160
  {...props}
@@ -13,13 +13,13 @@ export function Toaster() {
13
13
  position="bottom-right"
14
14
  closeButton
15
15
  offset={{
16
- bottom: "max(1.5rem, var(--safe-bottom))",
17
- right: "max(1.5rem, var(--safe-right))",
16
+ bottom: "1.5rem",
17
+ right: "1.5rem",
18
18
  }}
19
19
  mobileOffset={{
20
- bottom: "calc(4.25rem + max(0.5rem, var(--safe-bottom)))",
21
- left: "max(1rem, var(--safe-left))",
22
- right: "max(1rem, var(--safe-right))",
20
+ bottom: "5rem",
21
+ left: "1rem",
22
+ right: "1rem",
23
23
  }}
24
24
  style={{ zIndex: "var(--z-toast)" }}
25
25
  toastOptions={{
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";