@bccampus/ui-components 0.9.14 → 0.9.16

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.
@@ -5,6 +5,9 @@ export declare const bannerVariants: (props?: ({
5
5
  size?: "default" | "sm" | "lg" | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
7
  export interface BannerProps extends React.ComponentProps<"div">, BannerVariantsProps {
8
+ id: string;
9
+ title: string;
8
10
  dismissible?: boolean;
11
+ onDismiss?: (id: string) => void;
9
12
  }
10
- export declare function Banner({ className, size, variant, dismissible, children, ...props }: BannerProps): import("react").JSX.Element | null;
13
+ export declare function Banner({ className, size, variant, dismissible, onDismiss, id, title, children, ...props }: BannerProps): import("react").JSX.Element | null;
@@ -1,24 +1,43 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../_chunks/index2.js";
3
3
  import { c as cn } from "../../_chunks/utils.js";
4
- import { useState } from "react";
4
+ import { useState, useCallback } from "react";
5
5
  import { Button } from "./button.js";
6
+ import { PageSection } from "./page-section.js";
6
7
  import { c as createLucideIcon } from "../../_chunks/createLucideIcon.js";
8
+ const __iconNode$2 = [
9
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
10
+ ["path", { d: "M12 16v-4", key: "1dtifu" }],
11
+ ["path", { d: "M12 8h.01", key: "e9boi3" }]
12
+ ];
13
+ const Info = createLucideIcon("info", __iconNode$2);
14
+ const __iconNode$1 = [
15
+ [
16
+ "path",
17
+ {
18
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
19
+ key: "wmoenq"
20
+ }
21
+ ],
22
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
23
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
24
+ ];
25
+ const TriangleAlert = createLucideIcon("triangle-alert", __iconNode$1);
7
26
  const __iconNode = [
8
27
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
9
28
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
10
29
  ];
11
30
  const X = createLucideIcon("x", __iconNode);
12
- const bannerVariants = cva("flex flex-row items-center justify-between px-(--spacing-section) text-sm", {
31
+ const bannerVariants = cva("flex flex-row items-start justify-between px-(--spacing-section) text-sm", {
13
32
  variants: {
14
33
  variant: {
15
- default: "bg-complement-3 text-white",
16
- alert: "bg-complement-2-200 text-black"
34
+ default: "bg-complement-3 text-white dark:text-white",
35
+ alert: "bg-complement-2 text-black dark:text-black"
17
36
  },
18
37
  size: {
19
38
  default: "py-2",
20
39
  sm: "py-1",
21
- lg: "py-3 text-md font-semibold"
40
+ lg: "py-3"
22
41
  }
23
42
  },
24
43
  defaultVariants: {
@@ -26,13 +45,64 @@ const bannerVariants = cva("flex flex-row items-center justify-between px-(--spa
26
45
  size: "default"
27
46
  }
28
47
  });
29
- function Banner({ className, size, variant, dismissible, children, ...props }) {
48
+ function Banner({
49
+ className,
50
+ size,
51
+ variant,
52
+ dismissible,
53
+ onDismiss,
54
+ id,
55
+ title,
56
+ children,
57
+ ...props
58
+ }) {
30
59
  const [dismissed, setDismissed] = useState(false);
60
+ const dismiss = useCallback(() => {
61
+ setDismissed(true);
62
+ onDismiss?.(id);
63
+ }, [id, onDismiss]);
31
64
  if (dismissed) return null;
32
- return /* @__PURE__ */ jsxs("div", { "data-slot": "banner", className: cn(bannerVariants({ variant, size }), className), ...props, children: [
33
- /* @__PURE__ */ jsx("div", { className: "flex-auto text-center", children }),
34
- dismissible && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "size-6 text-white", onClick: () => setDismissed(true), children: /* @__PURE__ */ jsx(X, {}) }) })
35
- ] });
65
+ return /* @__PURE__ */ jsxs(
66
+ PageSection,
67
+ {
68
+ py: "none",
69
+ "data-slot": "banner",
70
+ id: `announcement-${id}`,
71
+ className: cn(bannerVariants({ variant, size }), className),
72
+ ...props,
73
+ children: [
74
+ /* @__PURE__ */ jsxs(
75
+ "div",
76
+ {
77
+ className: cn("flex-auto flex flex-col justify-center items-center", {
78
+ "items-start": children
79
+ }),
80
+ children: [
81
+ /* @__PURE__ */ jsxs("div", { className: "flex-auto flex justify-center items-center gap-2", children: [
82
+ variant === "alert" ? /* @__PURE__ */ jsx(TriangleAlert, { className: "size-5" }) : /* @__PURE__ */ jsx(Info, { className: "size-5" }),
83
+ /* @__PURE__ */ jsx("div", { className: cn({ "text-md font-semibold": size === "lg" }), dangerouslySetInnerHTML: { __html: title } })
84
+ ] }),
85
+ children && /* @__PURE__ */ jsx("div", { className: "pl-7", dangerouslySetInnerHTML: { __html: children } })
86
+ ]
87
+ }
88
+ ),
89
+ dismissible && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
90
+ Button,
91
+ {
92
+ variant: "ghost",
93
+ icon: true,
94
+ size: "icon",
95
+ className: cn("size-6", {
96
+ "text-white dark:text-white": !variant || variant === "default",
97
+ "text-black dark:text-black": variant === "alert"
98
+ }),
99
+ onClick: dismiss,
100
+ children: /* @__PURE__ */ jsx(X, {})
101
+ }
102
+ ) })
103
+ ]
104
+ }
105
+ );
36
106
  }
37
107
  export {
38
108
  Banner,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bccampus/ui-components",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "description": "BCcampus React components",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -44,7 +44,7 @@
44
44
  "@radix-ui/react-slot": "^1.2.4",
45
45
  "class-variance-authority": "^0.7.1",
46
46
  "clsx": "^2.1.1",
47
- "lucide-react": "^0.575.0",
47
+ "lucide-react": "^0.576.0",
48
48
  "nanostores": "^1.1.1",
49
49
  "react": "^19.2.4",
50
50
  "react-dom": "^19.2.4",
@@ -56,7 +56,7 @@
56
56
  "@eslint/js": "^9.39.3",
57
57
  "@ladle/react": "^5.1.1",
58
58
  "@tailwindcss/vite": "^4.2.1",
59
- "@types/node": "^24.10.14",
59
+ "@types/node": "^24.11.0",
60
60
  "@types/react": "^19.2.14",
61
61
  "@types/react-dom": "^19.2.3",
62
62
  "@vitejs/plugin-react-swc": "^4.2.3",
@@ -65,7 +65,7 @@
65
65
  "eslint-plugin-react-hooks": "^7.0.1",
66
66
  "eslint-plugin-react-refresh": "^0.5.2",
67
67
  "glob": "^13.0.6",
68
- "globals": "^17.3.0",
68
+ "globals": "^17.4.0",
69
69
  "typescript": "~5.9.3",
70
70
  "typescript-eslint": "^8.56.1",
71
71
  "vite": "^7.3.1",
@@ -1,20 +1,21 @@
1
1
  import { cva, type VariantProps } from "class-variance-authority";
2
2
  import { cn } from "@/lib/utils";
3
- import { useState } from "react";
3
+ import { useCallback, useState } from "react";
4
4
  import { Button } from "./button";
5
- import { X } from "lucide-react";
5
+ import { Info, TriangleAlert, X } from "lucide-react";
6
+ import { PageSection } from "./page-section";
6
7
 
7
8
  export type BannerVariantsProps = VariantProps<typeof bannerVariants>;
8
- export const bannerVariants = cva("flex flex-row items-center justify-between px-(--spacing-section) text-sm", {
9
+ export const bannerVariants = cva("flex flex-row items-start justify-between px-(--spacing-section) text-sm", {
9
10
  variants: {
10
11
  variant: {
11
- default: "bg-complement-3 text-white",
12
- alert: "bg-complement-2-200 text-black",
12
+ default: "bg-complement-3 text-white dark:text-white",
13
+ alert: "bg-complement-2 text-black dark:text-black",
13
14
  },
14
15
  size: {
15
16
  default: "py-2",
16
17
  sm: "py-1",
17
- lg: "py-3 text-md font-semibold",
18
+ lg: "py-3",
18
19
  },
19
20
  },
20
21
  defaultVariants: {
@@ -24,23 +25,66 @@ export const bannerVariants = cva("flex flex-row items-center justify-between px
24
25
  });
25
26
 
26
27
  export interface BannerProps extends React.ComponentProps<"div">, BannerVariantsProps {
28
+ id: string;
29
+ title: string;
27
30
  dismissible?: boolean;
31
+ onDismiss?: (id: string) => void;
28
32
  }
29
- export function Banner({ className, size, variant, dismissible, children, ...props }: BannerProps) {
33
+ export function Banner({
34
+ className,
35
+ size,
36
+ variant,
37
+ dismissible,
38
+ onDismiss,
39
+ id,
40
+ title,
41
+ children,
42
+ ...props
43
+ }: BannerProps) {
30
44
  const [dismissed, setDismissed] = useState(false);
31
45
 
46
+ const dismiss = useCallback(() => {
47
+ setDismissed(true);
48
+ onDismiss?.(id);
49
+ }, [id, onDismiss]);
50
+
32
51
  if (dismissed) return null;
33
52
 
34
53
  return (
35
- <div data-slot="banner" className={cn(bannerVariants({ variant, size }), className)} {...props}>
36
- <div className="flex-auto text-center">{children}</div>
54
+ <PageSection
55
+ py="none"
56
+ data-slot="banner"
57
+ id={`announcement-${id}`}
58
+ className={cn(bannerVariants({ variant, size }), className)}
59
+ {...props}
60
+ >
61
+ <div
62
+ className={cn("flex-auto flex flex-col justify-center items-center", {
63
+ "items-start": children,
64
+ })}
65
+ >
66
+ <div className="flex-auto flex justify-center items-center gap-2">
67
+ {variant === "alert" ? <TriangleAlert className="size-5" /> : <Info className="size-5" />}
68
+ <div className={cn({ "text-md font-semibold": size === "lg" })} dangerouslySetInnerHTML={{ __html: title }} />
69
+ </div>
70
+ {children && <div className="pl-7" dangerouslySetInnerHTML={{ __html: children }} />}
71
+ </div>
37
72
  {dismissible && (
38
73
  <div>
39
- <Button variant="ghost" size="icon" className="size-6 text-white" onClick={() => setDismissed(true)}>
74
+ <Button
75
+ variant="ghost"
76
+ icon
77
+ size="icon"
78
+ className={cn("size-6", {
79
+ "text-white dark:text-white": !variant || variant === "default",
80
+ "text-black dark:text-black": variant === "alert",
81
+ })}
82
+ onClick={dismiss}
83
+ >
40
84
  <X />
41
85
  </Button>
42
86
  </div>
43
87
  )}
44
- </div>
88
+ </PageSection>
45
89
  );
46
90
  }