zudoku 0.6.1-dev.2 → 0.6.1-dev.3

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": "zudoku",
3
- "version": "0.6.1-dev.2",
3
+ "version": "0.6.1-dev.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
package/src/app/main.css CHANGED
@@ -80,7 +80,7 @@
80
80
  :root {
81
81
  --top-header-height: 65px;
82
82
  --top-nav-height: 50px;
83
- --banner-height: 48px;
83
+ --banner-height: 40px;
84
84
  --header-height: calc(
85
85
  var(--top-header-height) + var(--top-nav-height) + var(--banner-height)
86
86
  );
@@ -0,0 +1,41 @@
1
+ import { CircleXIcon } from "lucide-react";
2
+ import { useState } from "react";
3
+ import { cn } from "../util/cn.js";
4
+ import { useZudoku } from "./context/ZudokuContext.js";
5
+
6
+ const COLOR_MAP = {
7
+ info: "bg-blue-500",
8
+ note: "bg-gray-500",
9
+ tip: "bg-green-600",
10
+ caution: "bg-orange-500",
11
+ danger: "bg-rose-500",
12
+ };
13
+
14
+ export const Banner = () => {
15
+ const { page } = useZudoku();
16
+ const [isBannerOpen, setIsBannerOpen] = useState(true);
17
+
18
+ if (!page?.banner || !isBannerOpen) {
19
+ return <style>{`:root { --banner-height: 0px; }`}</style>;
20
+ }
21
+
22
+ return (
23
+ <div
24
+ className={cn(
25
+ "relative text-primary-foreground text-sm font-medium px-4 py-2 flex gap-2 items-center",
26
+ page.banner.color ? COLOR_MAP[page.banner.color] : "bg-primary",
27
+ )}
28
+ >
29
+ <div className="w-full">{page.banner.message}</div>
30
+ {page.banner.dismissible && (
31
+ <button
32
+ type="button"
33
+ className="md:absolute md:right-4 -m-1.5 p-1.5 hover:bg-accent-foreground/10 rounded-md"
34
+ onClick={() => setIsBannerOpen(false)}
35
+ >
36
+ <CircleXIcon size={16} />
37
+ </button>
38
+ )}
39
+ </div>
40
+ );
41
+ };
@@ -17,6 +17,7 @@ import {
17
17
  DropdownMenuTrigger,
18
18
  } from "../ui/DropdownMenu.js";
19
19
  import { cn } from "../util/cn.js";
20
+ import { Banner } from "./Banner.js";
20
21
  import { useTheme } from "./context/ThemeContext.js";
21
22
  import { useZudoku } from "./context/ZudokuContext.js";
22
23
  import { MobileTopNavigation } from "./MobileTopNavigation.js";
@@ -60,15 +61,7 @@ export const Header = memo(function HeaderInner() {
60
61
 
61
62
  return (
62
63
  <header className="sticky lg:top-0 z-10 bg-background/80 backdrop-blur w-full">
63
- <>
64
- {page?.banner ? (
65
- <div className="h-[--banner-height] bg-primary/90 text-primary-foreground text-center text-sm font-medium py-2 flex items-center justify-center">
66
- <div>{page.banner.message}</div>
67
- </div>
68
- ) : (
69
- <style>{`:root{ --banner-height: 0px }`}</style>
70
- )}
71
- </>
64
+ <Banner />
72
65
  <div className="max-w-screen-2xl mx-auto">
73
66
  <div className="grid grid-cols-2 lg:grid-cols-[calc(var(--side-nav-width))_1fr] lg:gap-12 items-center border-b px-10 lg:px-12 h-[--top-header-height]">
74
67
  <div className="flex">
@@ -51,6 +51,8 @@ type Page = Partial<{
51
51
  };
52
52
  banner?: {
53
53
  message: ReactNode;
54
+ color?: "note" | "tip" | "info" | "caution" | "danger";
55
+ dismissible?: boolean;
54
56
  };
55
57
  }>;
56
58
 
@@ -1,6 +1,6 @@
1
1
  export const DemoAnnouncement = () => {
2
2
  return (
3
- <>
3
+ <div className="text-center">
4
4
  This demo version of your OpenAPI isn't as fast or flexible as
5
5
  self-hosting.{" "}
6
6
  <a
@@ -10,7 +10,7 @@ export const DemoAnnouncement = () => {
10
10
  Get started here
11
11
  </a>{" "}
12
12
  to see Zudoku at full tilt.
13
- </>
13
+ </div>
14
14
  );
15
15
  };
16
16