gbs-add-block 0.0.83 → 0.0.85
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/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GBS Building Blocks 2.0 (v0.0.
|
|
1
|
+
# GBS Building Blocks 2.0 (v0.0.85)
|
|
2
2
|
|
|
3
3
|
Latest and upgraded version of GBS building blocks with headless UI and removed dependencies.
|
|
4
4
|
|
|
@@ -6,10 +6,10 @@ Latest and upgraded version of GBS building blocks with headless UI and removed
|
|
|
6
6
|
|
|
7
7
|
For detailed documentation on usage and props, Please visit: [Building Block Documentation v2.0](https://blackmax-designs.gitbook.io/building-block-v2.0)
|
|
8
8
|
|
|
9
|
-
## What's New 🎉 (Ver 0.0.
|
|
9
|
+
## What's New 🎉 (Ver 0.0.85)
|
|
10
10
|
|
|
11
11
|
- Updated for bug fixes.
|
|
12
|
-
- New Component Card & SideBar Added
|
|
12
|
+
- New Component Card, Tabs & SideBar Added
|
|
13
13
|
|
|
14
14
|
## Authors
|
|
15
15
|
|
package/index.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
1
2
|
import { MenuItem, IconComponent } from "../type";
|
|
2
3
|
|
|
3
4
|
type MenuItemProps = {
|
|
@@ -12,6 +13,13 @@ export const MenuItemComponent = ({
|
|
|
12
13
|
onToggle,
|
|
13
14
|
}: MenuItemProps) => {
|
|
14
15
|
const IconComponent = iconMap[item.icon] || (() => null);
|
|
16
|
+
const [path, setPath] = useState("");
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (typeof window !== "undefined") {
|
|
20
|
+
setPath(window.location.pathname);
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
15
23
|
|
|
16
24
|
return (
|
|
17
25
|
<li>
|
|
@@ -26,7 +34,7 @@ export const MenuItemComponent = ({
|
|
|
26
34
|
: undefined
|
|
27
35
|
}
|
|
28
36
|
className={`flex items-center py-2 px-3 rounded-md text-sm ${
|
|
29
|
-
item.
|
|
37
|
+
item.path === path
|
|
30
38
|
? "bg-gray-100 text-black font-medium"
|
|
31
39
|
: "text-gray-700 hover:bg-gray-50"
|
|
32
40
|
}`}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { TabsProps } from "./types";
|
|
10
|
+
|
|
11
|
+
export function Tabs({
|
|
12
|
+
tabs,
|
|
13
|
+
defaultTabId,
|
|
14
|
+
renderContent,
|
|
15
|
+
onChange,
|
|
16
|
+
className = "",
|
|
17
|
+
}: TabsProps) {
|
|
18
|
+
const [activeTabId, setActiveTabId] = useState<string>(
|
|
19
|
+
defaultTabId || (tabs.length > 0 ? tabs[0].id : "")
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const handleTabChange = (tabId: string) => {
|
|
23
|
+
setActiveTabId(tabId);
|
|
24
|
+
if (onChange) {
|
|
25
|
+
onChange(tabId);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={`w-full ${className}`}>
|
|
31
|
+
<nav className="flex border-b border-gray-200">
|
|
32
|
+
{tabs.map((tab) => (
|
|
33
|
+
<button
|
|
34
|
+
key={tab.id}
|
|
35
|
+
disabled={tab.disabled}
|
|
36
|
+
className={`px-4 py-2 text-sm font-medium transition-colors ${
|
|
37
|
+
tab.disabled
|
|
38
|
+
? "text-gray-300 cursor-not-allowed"
|
|
39
|
+
: activeTabId === tab.id
|
|
40
|
+
? "border-b-2 border-black text-black"
|
|
41
|
+
: "text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
|
42
|
+
}`}
|
|
43
|
+
onClick={() => !tab.disabled && handleTabChange(tab.id)}
|
|
44
|
+
>
|
|
45
|
+
{tab.label}
|
|
46
|
+
</button>
|
|
47
|
+
))}
|
|
48
|
+
</nav>
|
|
49
|
+
<div className="pt-4">{renderContent(activeTabId)}</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export interface TabItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TabsProps {
|
|
10
|
+
tabs: TabItem[];
|
|
11
|
+
defaultTabId?: string;
|
|
12
|
+
renderContent: (activeTabId: string) => ReactNode;
|
|
13
|
+
onChange?: (tabId: string) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|