@skalfa/skalfa-component 1.0.44 → 1.0.46

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.
@@ -3,5 +3,8 @@ export interface HeadbarProps {
3
3
  title?: string;
4
4
  backHref?: string | boolean;
5
5
  rightContent?: ReactNode;
6
+ sidebarId?: string;
7
+ /** Use custom class with: "left::", "right::", "title::", "toggle::", "back::". */
8
+ className?: string;
6
9
  }
7
- export declare function HeadbarComponent({ title, backHref, rightContent }: HeadbarProps): import("@types/react").JSX.Element;
10
+ export declare function HeadbarComponent({ title, backHref, rightContent, sidebarId, className, }: HeadbarProps): import("@types/react").JSX.Element;
@@ -3,10 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.HeadbarComponent = HeadbarComponent;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const _utils_1 = require("@utils");
7
+ const _contexts_1 = require("@contexts");
6
8
  const skalfa_icon_1 = require("@skalfa/skalfa-icon");
7
9
  const navigation_1 = require("next/navigation");
8
10
  ;
9
- function HeadbarComponent({ title, backHref, rightContent }) {
11
+ function HeadbarComponent({ title, backHref, rightContent, sidebarId, className = "", }) {
10
12
  const router = (0, navigation_1.useRouter)();
11
- return ((0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between w-full items-center mt-2 mb-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [backHref && ((0, jsx_runtime_1.jsx)("div", { className: "w-8 aspect-square flex justify-center items-center cursor-pointer", onClick: () => typeof backHref != "boolean" ? router.push(backHref) : router.back(), children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: "solid/chevron-left", className: "text-secondary text-xl" }) })), (0, jsx_runtime_1.jsx)("p", { className: "text-lg font-bold px-2", children: title })] }), rightContent && (0, jsx_runtime_1.jsx)("div", { children: rightContent })] }));
13
+ const { toggle, setToggle } = (0, _contexts_1.useToggleContext)();
14
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("flex justify-between w-full items-center mt-2 mb-4 headbar", (0, _utils_1.pcn)(className, "base")), children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, _utils_1.cn)("flex items-center headbar-left", (0, _utils_1.pcn)(className, "left")), children: [toggle[`SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`] && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("w-8 aspect-square flex justify-center items-center cursor-pointer headbar-toggle headbar-sidebar-toggle", (0, _utils_1.pcn)(className, "toggle")), onClick: () => setToggle(`SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`, !toggle[`SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`]), children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: "solid/sidebar", className: "text-xl headbar-toggle-icon headbar-icon" }) })), backHref && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("w-8 aspect-square flex justify-center items-center cursor-pointer headbar-back headbar-back-button", (0, _utils_1.pcn)(className, "back")), onClick: () => typeof backHref != "boolean" ? router.push(backHref) : router.back(), children: (0, jsx_runtime_1.jsx)(skalfa_icon_1.Icon, { icon: "solid/chevron-left", className: "text-xl headbar-back-icon headbar-icon" }) })), (0, jsx_runtime_1.jsx)("p", { className: (0, _utils_1.cn)("text-lg font-bold px-2 headbar-title", (0, _utils_1.pcn)(className, "title")), children: title })] }), rightContent && ((0, jsx_runtime_1.jsx)("div", { className: (0, _utils_1.cn)("headbar-right", (0, _utils_1.pcn)(className, "right")), children: rightContent }))] }));
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalfa/skalfa-component",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "Reusable UI components for Skalfa App.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -1,33 +1,83 @@
1
1
  "use client"
2
+ import { cn, pcn } from "@utils";
3
+ import { useToggleContext } from "@contexts";
2
4
  import { Icon, type IconName } from "@skalfa/skalfa-icon";
3
-
4
-
5
5
  import { useRouter } from "next/navigation";
6
6
  import { ReactNode } from "react";
7
7
 
8
8
 
9
9
 
10
+ type CT = "base" | "left" | "right" | "title" | "toggle" | "back";
11
+
10
12
  export interface HeadbarProps {
11
13
  title ?: string;
12
14
  backHref ?: string | boolean;
13
15
  rightContent ?: ReactNode;
16
+ sidebarId ?: string;
17
+
18
+ /** Use custom class with: "left::", "right::", "title::", "toggle::", "back::". */
19
+ className ?: string;
14
20
  };
15
21
 
16
22
 
17
- export function HeadbarComponent({ title, backHref, rightContent }: HeadbarProps) {
23
+
24
+ export function HeadbarComponent({
25
+ title,
26
+ backHref,
27
+ rightContent,
28
+ sidebarId,
29
+ className = "",
30
+ }: HeadbarProps) {
18
31
  const router = useRouter();
32
+ const { toggle, setToggle } = useToggleContext();
19
33
 
20
34
  return (
21
- <div className="flex justify-between w-full items-center mt-2 mb-4">
22
- <div className="flex items-center">
35
+ <div
36
+ className={cn(
37
+ "flex justify-between w-full items-center mt-2 mb-4 headbar",
38
+ pcn<CT>(className, "base")
39
+ )}
40
+ >
41
+ <div className={cn("flex items-center headbar-left", pcn<CT>(className, "left"))}>
42
+ {toggle[`SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`] && (
43
+ <div
44
+ className={cn(
45
+ "w-8 aspect-square flex justify-center items-center cursor-pointer headbar-toggle headbar-sidebar-toggle",
46
+ pcn<CT>(className, "toggle")
47
+ )}
48
+ onClick={() =>
49
+ setToggle(
50
+ `SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`,
51
+ !toggle[`SIDEBAR${sidebarId ? ("_" + sidebarId?.toUpperCase()) : ""}`]
52
+ )
53
+ }
54
+ >
55
+ <Icon icon="solid/sidebar" className="text-xl headbar-toggle-icon headbar-icon" />
56
+ </div>
57
+ )}
23
58
  {backHref && (
24
- <div className="w-8 aspect-square flex justify-center items-center cursor-pointer" onClick={() => typeof backHref != "boolean" ? router.push(backHref) : router.back()}>
25
- <Icon icon="solid/chevron-left" className="text-secondary text-xl" />
59
+ <div
60
+ className={cn(
61
+ "w-8 aspect-square flex justify-center items-center cursor-pointer headbar-back headbar-back-button",
62
+ pcn<CT>(className, "back")
63
+ )}
64
+ onClick={() =>
65
+ typeof backHref != "boolean" ? router.push(backHref) : router.back()
66
+ }
67
+ >
68
+ <Icon icon="solid/chevron-left" className="text-xl headbar-back-icon headbar-icon" />
26
69
  </div>
27
70
  )}
28
- <p className="text-lg font-bold px-2">{title}</p>
71
+ <p className={cn("text-lg font-bold px-2 headbar-title", pcn<CT>(className, "title"))}>
72
+ {title}
73
+ </p>
29
74
  </div>
30
- {rightContent && <div>{rightContent}</div>}
75
+ {rightContent && (
76
+ <div className={cn("headbar-right", pcn<CT>(className, "right"))}>
77
+ {rightContent}
78
+ </div>
79
+ )}
31
80
  </div>
32
81
  );
33
82
  }
83
+