funuicss 2.6.0 → 2.6.1
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/css/fun.css +133 -337
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/index.tsx +1 -0
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/ui/appbar/AppBar.d.ts +4 -1
- package/ui/appbar/AppBar.js +9 -5
- package/ui/appbar/AppBar.tsx +17 -1
- package/ui/input/Input.js +2 -1
- package/ui/input/Input.tsx +1 -1
- package/ui/sidebar/SideBar.d.ts +17 -8
- package/ui/sidebar/SideBar.js +89 -44
- package/ui/sidebar/SideBar.tsx +180 -53
- package/ui/specials/Circle.d.ts +2 -1
- package/ui/specials/Circle.js +2 -2
- package/ui/specials/Circle.tsx +4 -2
- package/ui/text/Text.d.ts +1 -1
- package/ui/text/Text.js +3 -2
- package/ui/text/Text.tsx +3 -2
- package/ui/theme/theme.js +3 -3
- package/ui/theme/theme.tsx +3 -3
package/ui/appbar/AppBar.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ interface NavbarProps {
|
|
|
12
12
|
sidebarTrigger?: React.ReactNode;
|
|
13
13
|
transparent?: boolean;
|
|
14
14
|
sideBar?: number;
|
|
15
|
+
hasSidebar?: boolean;
|
|
16
|
+
sidebarOpen?: boolean;
|
|
17
|
+
openSidebar?: () => void;
|
|
15
18
|
}
|
|
16
|
-
export default function AppBar({ fixedTop, funcss, padding, fixedBottom, justify, left, center, right, sideBar, sidebarTrigger, transparent, }: NavbarProps): React.JSX.Element;
|
|
19
|
+
export default function AppBar({ fixedTop, funcss, padding, fixedBottom, justify, left, center, right, sideBar, sidebarTrigger, transparent, hasSidebar, openSidebar, sidebarOpen }: NavbarProps): React.JSX.Element;
|
|
17
20
|
export {};
|
package/ui/appbar/AppBar.js
CHANGED
|
@@ -43,9 +43,9 @@ var react_1 = require("react");
|
|
|
43
43
|
var navigation_1 = require("next/navigation"); // <-- Updated import
|
|
44
44
|
var Hamburger_1 = __importDefault(require("./Hamburger"));
|
|
45
45
|
function AppBar(_a) {
|
|
46
|
-
var fixedTop = _a.fixedTop, funcss = _a.funcss, padding = _a.padding, fixedBottom = _a.fixedBottom, justify = _a.justify, left = _a.left, center = _a.center, right = _a.right, sideBar = _a.sideBar, sidebarTrigger = _a.sidebarTrigger, transparent = _a.transparent;
|
|
47
|
-
var
|
|
48
|
-
var
|
|
46
|
+
var fixedTop = _a.fixedTop, funcss = _a.funcss, padding = _a.padding, fixedBottom = _a.fixedBottom, justify = _a.justify, left = _a.left, center = _a.center, right = _a.right, sideBar = _a.sideBar, sidebarTrigger = _a.sidebarTrigger, transparent = _a.transparent, hasSidebar = _a.hasSidebar, openSidebar = _a.openSidebar, _b = _a.sidebarOpen, sidebarOpen = _b === void 0 ? false : _b;
|
|
47
|
+
var _c = (0, react_1.useState)(false), isMobileMenuOpen = _c[0], setIsMobileMenuOpen = _c[1];
|
|
48
|
+
var _d = (0, react_1.useState)(false), isMobileScreen = _d[0], setIsMobileScreen = _d[1];
|
|
49
49
|
var pathname = (0, navigation_1.usePathname)(); // <-- New hook to detect path changes
|
|
50
50
|
var toggleMenu = function () { return setIsMobileMenuOpen(function (prev) { return !prev; }); };
|
|
51
51
|
var closeMenu = function () { return setIsMobileMenuOpen(false); };
|
|
@@ -69,7 +69,9 @@ function AppBar(_a) {
|
|
|
69
69
|
var isOpen = _a.isOpen;
|
|
70
70
|
return React.createElement(Hamburger_1.default, { isOpen: isOpen });
|
|
71
71
|
};
|
|
72
|
-
return (React.createElement("nav", {
|
|
72
|
+
return (React.createElement("nav", {
|
|
73
|
+
// the id will be used to get the height for the sidebar in the sidebar file
|
|
74
|
+
id: 'appBar', className: "navigation-bar\n ".concat(isMobileMenuOpen ? 'navbar-mobile-open' : '', "\n ").concat(funcss || '', "\n ").concat(fixedTop ? 'fixed_top_navbar' : '', "\n ").concat(sideBar ? 'there_is_sidebar' : '', "\n ").concat(transparent ? 'transparent' : '', "\n ").concat(fixedBottom ? 'fixedBottom' : '', "\n "), style: {
|
|
73
75
|
padding: "".concat(padding || ''),
|
|
74
76
|
justifyContent: "".concat(justify || ''),
|
|
75
77
|
} },
|
|
@@ -79,5 +81,7 @@ function AppBar(_a) {
|
|
|
79
81
|
React.createElement(Trigger, { isOpen: isMobileMenuOpen })))),
|
|
80
82
|
React.createElement("div", { className: "linkWrapper" }, center),
|
|
81
83
|
React.createElement("div", { className: "linkWrapper" }, right),
|
|
82
|
-
isMobileScreen && !isMobileMenuOpen && (React.createElement(
|
|
84
|
+
isMobileScreen && !isMobileMenuOpen && (React.createElement(React.Fragment, null, hasSidebar ?
|
|
85
|
+
React.createElement("span", { className: "sidebar-trigger pointer hover-text-primary", onClick: openSidebar }, sidebarTrigger || React.createElement(Trigger, { isOpen: sidebarOpen }))
|
|
86
|
+
: React.createElement("span", { className: "sidebar-trigger pointer hover-text-primary", onClick: toggleMenu }, sidebarTrigger || React.createElement(Trigger, { isOpen: isMobileMenuOpen }))))));
|
|
83
87
|
}
|
package/ui/appbar/AppBar.tsx
CHANGED
|
@@ -17,6 +17,9 @@ interface NavbarProps {
|
|
|
17
17
|
sidebarTrigger?: React.ReactNode;
|
|
18
18
|
transparent?: boolean;
|
|
19
19
|
sideBar?: number;
|
|
20
|
+
hasSidebar?: boolean;
|
|
21
|
+
sidebarOpen?: boolean;
|
|
22
|
+
openSidebar?: () => void;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export default function AppBar({
|
|
@@ -31,6 +34,9 @@ export default function AppBar({
|
|
|
31
34
|
sideBar,
|
|
32
35
|
sidebarTrigger,
|
|
33
36
|
transparent,
|
|
37
|
+
hasSidebar,
|
|
38
|
+
openSidebar,
|
|
39
|
+
sidebarOpen = false
|
|
34
40
|
}: NavbarProps) {
|
|
35
41
|
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
|
36
42
|
const [isMobileScreen, setIsMobileScreen] = useState(false);
|
|
@@ -64,6 +70,8 @@ export default function AppBar({
|
|
|
64
70
|
|
|
65
71
|
return (
|
|
66
72
|
<nav
|
|
73
|
+
// the id will be used to get the height for the sidebar in the sidebar file
|
|
74
|
+
id='appBar'
|
|
67
75
|
className={`navigation-bar
|
|
68
76
|
${isMobileMenuOpen ? 'navbar-mobile-open' : ''}
|
|
69
77
|
${funcss || ''}
|
|
@@ -90,9 +98,17 @@ export default function AppBar({
|
|
|
90
98
|
<div className="linkWrapper">{right}</div>
|
|
91
99
|
|
|
92
100
|
{isMobileScreen && !isMobileMenuOpen && (
|
|
93
|
-
|
|
101
|
+
<>
|
|
102
|
+
{
|
|
103
|
+
hasSidebar ?
|
|
104
|
+
<span className="sidebar-trigger pointer hover-text-primary" onClick={openSidebar}>
|
|
105
|
+
{sidebarTrigger || <Trigger isOpen={sidebarOpen} />}
|
|
106
|
+
</span>
|
|
107
|
+
: <span className="sidebar-trigger pointer hover-text-primary" onClick={toggleMenu}>
|
|
94
108
|
{sidebarTrigger || <Trigger isOpen={isMobileMenuOpen} />}
|
|
95
109
|
</span>
|
|
110
|
+
}
|
|
111
|
+
</>
|
|
96
112
|
)}
|
|
97
113
|
</nav>
|
|
98
114
|
);
|
package/ui/input/Input.js
CHANGED
|
@@ -123,7 +123,8 @@ var Input = function (_a) {
|
|
|
123
123
|
}, value: value }, rest))));
|
|
124
124
|
return (react_1.default.createElement("div", { className: "_upload_container" },
|
|
125
125
|
react_1.default.createElement("label", { htmlFor: id || "fileInput", className: "_upload_label" },
|
|
126
|
-
react_1.default.createElement("div", { className: "_upload_icon" }, icon || react_1.default.createElement(react_1.default.Fragment, null,
|
|
126
|
+
react_1.default.createElement("div", { className: "_upload_icon" }, icon || react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
|
+
react_1.default.createElement(pi_1.PiCloudArrowUp, null))),
|
|
127
128
|
react_1.default.createElement("div", { className: "_upload_text", style: {
|
|
128
129
|
whiteSpace: 'nowrap',
|
|
129
130
|
overflow: 'hidden',
|
package/ui/input/Input.tsx
CHANGED
|
@@ -306,7 +306,7 @@ const Input: React.FC<InputProps> = ({
|
|
|
306
306
|
return (
|
|
307
307
|
<div className="_upload_container">
|
|
308
308
|
<label htmlFor={id || "fileInput"} className="_upload_label">
|
|
309
|
-
<div className="_upload_icon">{ icon ||
|
|
309
|
+
<div className="_upload_icon">{ icon || <><PiCloudArrowUp /></>}</div>
|
|
310
310
|
<div className="_upload_text" style={{
|
|
311
311
|
whiteSpace: 'nowrap',
|
|
312
312
|
overflow: 'hidden',
|
package/ui/sidebar/SideBar.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface SideBarLink {
|
|
3
|
+
uri: string;
|
|
4
|
+
icon: React.ReactNode;
|
|
5
|
+
text: string;
|
|
6
|
+
section: string;
|
|
7
|
+
}
|
|
8
|
+
interface SideBarProps {
|
|
4
9
|
funcss?: string;
|
|
5
|
-
position?:
|
|
6
|
-
glassy?: boolean;
|
|
10
|
+
position?: 'left' | 'right';
|
|
7
11
|
open?: boolean;
|
|
8
12
|
header?: ReactNode;
|
|
9
13
|
content?: ReactNode;
|
|
10
|
-
close?: ReactNode;
|
|
11
14
|
footer?: ReactNode;
|
|
12
|
-
|
|
15
|
+
top?: number;
|
|
16
|
+
sidebarWidth?: number;
|
|
17
|
+
sidebarCss?: string;
|
|
18
|
+
bodyCss?: string;
|
|
19
|
+
links?: SideBarLink[];
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
onClose?: () => void;
|
|
13
22
|
}
|
|
14
|
-
export default function SideBar({ funcss, position,
|
|
23
|
+
export default function SideBar({ funcss, position, open, header, content, footer, top, sidebarWidth, sidebarCss, bodyCss, links, children, onClose, }: SideBarProps): React.JSX.Element;
|
|
15
24
|
export {};
|
package/ui/sidebar/SideBar.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
2
|
+
'use client';
|
|
13
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
4
|
if (k2 === undefined) k2 = k;
|
|
15
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -43,44 +33,99 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
33
|
return result;
|
|
44
34
|
};
|
|
45
35
|
})();
|
|
46
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
47
|
-
var t = {};
|
|
48
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
49
|
-
t[p] = s[p];
|
|
50
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
51
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
52
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
53
|
-
t[p[i]] = s[p[i]];
|
|
54
|
-
}
|
|
55
|
-
return t;
|
|
56
|
-
};
|
|
57
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
38
|
};
|
|
60
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
40
|
exports.default = SideBar;
|
|
62
|
-
var
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
63
42
|
var RowFlex_1 = __importDefault(require("../specials/RowFlex"));
|
|
43
|
+
var Text_1 = __importDefault(require("../text/Text"));
|
|
44
|
+
var navigation_1 = require("next/navigation");
|
|
64
45
|
function SideBar(_a) {
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
46
|
+
var _b;
|
|
47
|
+
var _c = _a.funcss, funcss = _c === void 0 ? '' : _c, _d = _a.position, position = _d === void 0 ? 'left' : _d, _e = _a.open, open = _e === void 0 ? false : _e, header = _a.header, content = _a.content, footer = _a.footer, _f = _a.top, top = _f === void 0 ? 0 : _f, _g = _a.sidebarWidth, sidebarWidth = _g === void 0 ? 250 : _g, _h = _a.sidebarCss, sidebarCss = _h === void 0 ? '' : _h, _j = _a.bodyCss, bodyCss = _j === void 0 ? '' : _j, _k = _a.links, links = _k === void 0 ? [] : _k, children = _a.children, onClose = _a.onClose;
|
|
48
|
+
var _l = (0, react_1.useState)(false), isMobile = _l[0], setIsMobile = _l[1];
|
|
49
|
+
var _m = (0, react_1.useState)(open), internalOpen = _m[0], setInternalOpen = _m[1];
|
|
50
|
+
var _o = (0, react_1.useState)('0px'), appBarHeight = _o[0], setAppBarHeight = _o[1];
|
|
51
|
+
var pathname = (0, navigation_1.usePathname)();
|
|
52
|
+
var sidebarRef = (0, react_1.useRef)(null);
|
|
53
|
+
var updateIsMobile = (0, react_1.useCallback)(function () {
|
|
54
|
+
setIsMobile(window.innerWidth <= 992);
|
|
55
|
+
}, []);
|
|
56
|
+
(0, react_1.useEffect)(function () {
|
|
57
|
+
updateIsMobile();
|
|
58
|
+
window.addEventListener('resize', updateIsMobile);
|
|
59
|
+
return function () { return window.removeEventListener('resize', updateIsMobile); };
|
|
60
|
+
}, [updateIsMobile]);
|
|
61
|
+
// Sync internal state with prop changes
|
|
62
|
+
(0, react_1.useEffect)(function () {
|
|
63
|
+
setInternalOpen(open);
|
|
64
|
+
}, [open]);
|
|
65
|
+
(0, react_1.useEffect)(function () {
|
|
66
|
+
var appBar = document.querySelector('#appBar');
|
|
67
|
+
if (appBar) {
|
|
68
|
+
setAppBarHeight("".concat(appBar.offsetHeight, "px"));
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
(0, react_1.useEffect)(function () {
|
|
72
|
+
if (!isMobile || !internalOpen)
|
|
73
|
+
return;
|
|
74
|
+
var handleOutsideClick = function (e) {
|
|
75
|
+
if (sidebarRef.current && !sidebarRef.current.contains(e.target)) {
|
|
76
|
+
handleClose();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
document.addEventListener('mousedown', handleOutsideClick);
|
|
80
|
+
document.addEventListener('touchstart', handleOutsideClick);
|
|
81
|
+
return function () {
|
|
82
|
+
document.removeEventListener('mousedown', handleOutsideClick);
|
|
83
|
+
document.removeEventListener('touchstart', handleOutsideClick);
|
|
84
|
+
};
|
|
85
|
+
}, [isMobile, internalOpen]);
|
|
86
|
+
var handleClose = function () {
|
|
87
|
+
setInternalOpen(false);
|
|
88
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
89
|
+
};
|
|
90
|
+
var groupedLinks = links.reduce(function (acc, link) {
|
|
91
|
+
acc[link.section] = acc[link.section] || [];
|
|
92
|
+
acc[link.section].push(link);
|
|
93
|
+
return acc;
|
|
94
|
+
}, {});
|
|
95
|
+
var isOverlay = isMobile;
|
|
96
|
+
return (react_1.default.createElement("div", { className: "sidebar-container ".concat(isOverlay ? '' : 'with-content') },
|
|
97
|
+
internalOpen && (react_1.default.createElement("aside", { role: "complementary", ref: sidebarRef, className: "sidebar ".concat(funcss, " ").concat(sidebarCss, " ").concat(isOverlay ? 'nav_overlay' : ''), style: (_b = {
|
|
98
|
+
width: isOverlay ? '100%' : "".concat(sidebarWidth, "px"),
|
|
99
|
+
height: "calc(100vh - ".concat(appBarHeight || top || '0px', ")"),
|
|
100
|
+
position: 'fixed',
|
|
101
|
+
top: appBarHeight || top
|
|
102
|
+
},
|
|
103
|
+
_b[position] = 0,
|
|
104
|
+
_b.padding = '1rem',
|
|
105
|
+
_b) },
|
|
106
|
+
react_1.default.createElement(RowFlex_1.default, { justify: "space-between", funcss: "pl-2 pr-2" }, header && react_1.default.createElement("div", null, header)),
|
|
107
|
+
react_1.default.createElement("section", { className: "sidebar-body mt-3" },
|
|
108
|
+
links.length > 0 && (react_1.default.createElement("nav", { className: "sidebar-links" }, Object.entries(groupedLinks).map(function (_a) {
|
|
109
|
+
var section = _a[0], sectionLinks = _a[1];
|
|
110
|
+
return (react_1.default.createElement("div", { key: section, className: "sidebar-section mb-2 bt pt-2 pb-2" },
|
|
111
|
+
react_1.default.createElement(Text_1.default, { size: "sm", funcss: "opacity-5 p-1 pl-2 pr-2" }, section),
|
|
112
|
+
sectionLinks.map(function (link) {
|
|
113
|
+
var isActive = pathname === link.uri;
|
|
114
|
+
return (react_1.default.createElement("a", { onClick: handleClose, key: link.uri, href: link.uri },
|
|
115
|
+
react_1.default.createElement("div", { className: "p-1 pl-2 pr-2 sidebar-link ".concat(isActive ? 'primary50 outline-primary200' : 'hoverable') },
|
|
116
|
+
react_1.default.createElement("span", { style: { lineHeight: 0 } }, link.icon),
|
|
117
|
+
react_1.default.createElement(Text_1.default, { text: link.text, size: "sm", weight: 400 }))));
|
|
118
|
+
})));
|
|
119
|
+
}))),
|
|
120
|
+
content),
|
|
121
|
+
footer && react_1.default.createElement("footer", { className: "sidebar-footer mt-2" }, footer))),
|
|
122
|
+
react_1.default.createElement("main", { className: "main-content ".concat(bodyCss), style: {
|
|
123
|
+
flex: 1,
|
|
124
|
+
marginLeft: position === 'left' && !isOverlay && internalOpen ? "".concat(sidebarWidth, "px") : 0,
|
|
125
|
+
marginRight: position === 'right' && !isOverlay && internalOpen ? "".concat(sidebarWidth, "px") : 0,
|
|
126
|
+
overflowY: 'auto',
|
|
127
|
+
height: '100vh',
|
|
128
|
+
paddingTop: appBarHeight || top,
|
|
129
|
+
transition: 'margin 0.3s ease',
|
|
130
|
+
} }, children)));
|
|
86
131
|
}
|
package/ui/sidebar/SideBar.tsx
CHANGED
|
@@ -1,62 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
'use client';
|
|
2
|
+
import React, {
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
} from 'react';
|
|
3
9
|
import RowFlex from '../specials/RowFlex';
|
|
10
|
+
import Text from '../text/Text';
|
|
11
|
+
import { usePathname } from 'next/navigation';
|
|
12
|
+
import { PiX } from 'react-icons/pi';
|
|
4
13
|
|
|
14
|
+
interface SideBarLink {
|
|
15
|
+
uri: string;
|
|
16
|
+
icon: React.ReactNode;
|
|
17
|
+
text: string;
|
|
18
|
+
section: string;
|
|
19
|
+
}
|
|
5
20
|
|
|
6
|
-
interface
|
|
21
|
+
interface SideBarProps {
|
|
7
22
|
funcss?: string;
|
|
8
|
-
position?:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
position?: 'left' | 'right';
|
|
24
|
+
open?: boolean;
|
|
25
|
+
header?: ReactNode;
|
|
26
|
+
content?: ReactNode;
|
|
27
|
+
footer?: ReactNode;
|
|
28
|
+
top?: number;
|
|
29
|
+
sidebarWidth?: number;
|
|
30
|
+
sidebarCss?: string;
|
|
31
|
+
bodyCss?: string;
|
|
32
|
+
links?: SideBarLink[];
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
onClose?: () => void;
|
|
16
35
|
}
|
|
17
36
|
|
|
18
37
|
export default function SideBar({
|
|
19
|
-
funcss,
|
|
20
|
-
position ,
|
|
21
|
-
|
|
22
|
-
header
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
funcss = '',
|
|
39
|
+
position = 'left',
|
|
40
|
+
open = false,
|
|
41
|
+
header,
|
|
42
|
+
content,
|
|
43
|
+
footer,
|
|
44
|
+
top = 0,
|
|
45
|
+
sidebarWidth = 250,
|
|
46
|
+
sidebarCss = '',
|
|
47
|
+
bodyCss = '',
|
|
48
|
+
links = [],
|
|
49
|
+
children,
|
|
50
|
+
onClose,
|
|
51
|
+
}: SideBarProps) {
|
|
52
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
53
|
+
const [internalOpen, setInternalOpen] = useState(open);
|
|
54
|
+
const [appBarHeight, setAppBarHeight] = useState('0px');
|
|
55
|
+
const pathname = usePathname();
|
|
56
|
+
const sidebarRef = useRef<HTMLDivElement>(null);
|
|
57
|
+
|
|
58
|
+
const updateIsMobile = useCallback(() => {
|
|
59
|
+
setIsMobile(window.innerWidth <= 992);
|
|
60
|
+
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
updateIsMobile();
|
|
65
|
+
window.addEventListener('resize', updateIsMobile);
|
|
66
|
+
return () => window.removeEventListener('resize', updateIsMobile);
|
|
67
|
+
}, [updateIsMobile]);
|
|
68
|
+
|
|
69
|
+
// Sync internal state with prop changes
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
setInternalOpen(open);
|
|
72
|
+
}, [open]);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const appBar = document.querySelector('#appBar') as HTMLElement;
|
|
76
|
+
if (appBar) {
|
|
77
|
+
setAppBarHeight(`${appBar.offsetHeight}px`);
|
|
78
|
+
}
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!isMobile || !internalOpen) return;
|
|
83
|
+
|
|
84
|
+
const handleOutsideClick = (e: MouseEvent | TouchEvent) => {
|
|
85
|
+
if (sidebarRef.current && !sidebarRef.current.contains(e.target as Node)) {
|
|
86
|
+
handleClose();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
document.addEventListener('mousedown', handleOutsideClick);
|
|
91
|
+
document.addEventListener('touchstart', handleOutsideClick);
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
document.removeEventListener('mousedown', handleOutsideClick);
|
|
95
|
+
document.removeEventListener('touchstart', handleOutsideClick);
|
|
96
|
+
};
|
|
97
|
+
}, [isMobile, internalOpen]);
|
|
98
|
+
|
|
99
|
+
const handleClose = () => {
|
|
100
|
+
setInternalOpen(false);
|
|
101
|
+
onClose?.();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const groupedLinks = links.reduce<Record<string, SideBarLink[]>>((acc, link) => {
|
|
105
|
+
acc[link.section] = acc[link.section] || [];
|
|
106
|
+
acc[link.section].push(link);
|
|
107
|
+
return acc;
|
|
108
|
+
}, {});
|
|
109
|
+
|
|
110
|
+
const isOverlay = isMobile;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className={`sidebar-container ${isOverlay ? '' : 'with-content'}`}>
|
|
114
|
+
{internalOpen && (
|
|
115
|
+
<aside
|
|
116
|
+
role="complementary"
|
|
117
|
+
ref={sidebarRef}
|
|
118
|
+
className={`sidebar ${funcss} ${sidebarCss} ${isOverlay ? 'nav_overlay' : ''}`}
|
|
119
|
+
style={{
|
|
120
|
+
width: isOverlay ? '100%' : `${sidebarWidth}px`,
|
|
121
|
+
height: `calc(100vh - ${appBarHeight || top || '0px'})`,
|
|
122
|
+
position: 'fixed',
|
|
123
|
+
top: appBarHeight || top,
|
|
124
|
+
[position]: 0,
|
|
125
|
+
padding: '1rem',
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
{/* {isMobile && (
|
|
129
|
+
<div
|
|
130
|
+
className="hover-text-error pointer"
|
|
131
|
+
onClick={handleClose}
|
|
132
|
+
style={{ cursor: 'pointer' }}
|
|
133
|
+
>
|
|
134
|
+
{close || <PiX size={25}/>}
|
|
56
135
|
</div>
|
|
136
|
+
)} */}
|
|
137
|
+
|
|
138
|
+
<RowFlex justify="space-between" funcss="pl-2 pr-2">
|
|
139
|
+
{header && <div>{header}</div>}
|
|
140
|
+
|
|
141
|
+
</RowFlex>
|
|
142
|
+
|
|
143
|
+
<section className="sidebar-body mt-3">
|
|
144
|
+
{links.length > 0 && (
|
|
145
|
+
<nav className="sidebar-links">
|
|
146
|
+
{Object.entries(groupedLinks).map(([section, sectionLinks]) => (
|
|
147
|
+
<div key={section} className="sidebar-section mb-2 bt pt-2 pb-2">
|
|
148
|
+
<Text size="sm" funcss="opacity-5 p-1 pl-2 pr-2">{section}</Text>
|
|
149
|
+
{sectionLinks.map(link => {
|
|
150
|
+
const isActive = pathname === link.uri;
|
|
151
|
+
return (
|
|
152
|
+
<a onClick={handleClose} key={link.uri} href={link.uri}>
|
|
153
|
+
<div className={`p-1 pl-2 pr-2 sidebar-link ${
|
|
154
|
+
isActive ? 'primary50 outline-primary200' : 'hoverable'
|
|
155
|
+
}`}>
|
|
156
|
+
<span style={{ lineHeight: 0 }}>{link.icon}</span>
|
|
157
|
+
<Text text={link.text} size="sm" weight={400} />
|
|
158
|
+
</div>
|
|
159
|
+
</a>
|
|
160
|
+
);
|
|
161
|
+
})}
|
|
162
|
+
</div>
|
|
163
|
+
))}
|
|
164
|
+
</nav>
|
|
165
|
+
)}
|
|
166
|
+
{content}
|
|
167
|
+
</section>
|
|
168
|
+
|
|
169
|
+
{footer && <footer className="sidebar-footer mt-2">{footer}</footer>}
|
|
57
170
|
</aside>
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
<main
|
|
174
|
+
className={`main-content ${bodyCss}`}
|
|
175
|
+
style={{
|
|
176
|
+
flex: 1,
|
|
177
|
+
marginLeft: position === 'left' && !isOverlay && internalOpen ? `${sidebarWidth}px` : 0,
|
|
178
|
+
marginRight: position === 'right' && !isOverlay && internalOpen ? `${sidebarWidth}px` : 0,
|
|
179
|
+
overflowY: 'auto',
|
|
180
|
+
height: '100vh',
|
|
181
|
+
paddingTop: appBarHeight || top,
|
|
182
|
+
transition: 'margin 0.3s ease',
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
{children}
|
|
186
|
+
</main>
|
|
187
|
+
</div>
|
|
188
|
+
);
|
|
189
|
+
}
|
package/ui/specials/Circle.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ interface Circle_Props extends HTMLProps<HTMLDivElement> {
|
|
|
8
8
|
children?: ReactNode;
|
|
9
9
|
hoverable?: boolean;
|
|
10
10
|
raised?: boolean;
|
|
11
|
+
bordered?: boolean;
|
|
11
12
|
key?: React.Key;
|
|
12
13
|
onClick?: () => void;
|
|
13
14
|
}
|
|
14
|
-
export default function Circle({ size, funcss, bg, color, children, hoverable, raised, key, onClick, ...rest }: Circle_Props): React.JSX.Element;
|
|
15
|
+
export default function Circle({ size, funcss, bg, color, children, hoverable, raised, key, onClick, bordered, ...rest }: Circle_Props): React.JSX.Element;
|
|
15
16
|
export {};
|
package/ui/specials/Circle.js
CHANGED
|
@@ -59,8 +59,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
59
59
|
exports.default = Circle;
|
|
60
60
|
var React = __importStar(require("react"));
|
|
61
61
|
function Circle(_a) {
|
|
62
|
-
var _b = _a.size, size = _b === void 0 ? 2 : _b, funcss = _a.funcss,
|
|
63
|
-
return (React.createElement("div", __assign({ className: "pointer avatar ".concat(funcss || '', " ").concat("text-" + (color === null || color === void 0 ? void 0 : color.trim()) || '', " ").concat(raised ? "raised" : '', " ").concat(bg || 'lighter', " ").concat(hoverable ? 'hoverable' : ''), style: {
|
|
62
|
+
var _b = _a.size, size = _b === void 0 ? 2 : _b, funcss = _a.funcss, _c = _a.bg, bg = _c === void 0 ? 'lighter' : _c, color = _a.color, children = _a.children, hoverable = _a.hoverable, raised = _a.raised, key = _a.key, onClick = _a.onClick, bordered = _a.bordered, rest = __rest(_a, ["size", "funcss", "bg", "color", "children", "hoverable", "raised", "key", "onClick", "bordered"]);
|
|
63
|
+
return (React.createElement("div", __assign({ className: " ".concat(bordered ? "border" : "", "pointer avatar ").concat(funcss || '', " ").concat("text-" + (color === null || color === void 0 ? void 0 : color.trim()) || '', " ").concat(raised ? "raised" : '', " ").concat(bg || 'lighter', " ").concat(hoverable ? 'hoverable' : ''), style: {
|
|
64
64
|
width: "".concat(size + "rem" || '2.3rem'),
|
|
65
65
|
height: "".concat(size + "rem" || '2.3rem'),
|
|
66
66
|
}, key: key, onClick: onClick }, rest),
|
package/ui/specials/Circle.tsx
CHANGED
|
@@ -11,6 +11,7 @@ interface Circle_Props extends HTMLProps<HTMLDivElement> {
|
|
|
11
11
|
children?: ReactNode;
|
|
12
12
|
hoverable?: boolean;
|
|
13
13
|
raised?:boolean
|
|
14
|
+
bordered?:boolean
|
|
14
15
|
key?:React.Key
|
|
15
16
|
onClick?: ()=> void
|
|
16
17
|
}
|
|
@@ -19,18 +20,19 @@ interface Circle_Props extends HTMLProps<HTMLDivElement> {
|
|
|
19
20
|
export default function Circle({
|
|
20
21
|
size = 2,
|
|
21
22
|
funcss,
|
|
22
|
-
bg,
|
|
23
|
+
bg = 'lighter',
|
|
23
24
|
color,
|
|
24
25
|
children,
|
|
25
26
|
hoverable,
|
|
26
27
|
raised ,
|
|
27
28
|
key ,
|
|
28
29
|
onClick ,
|
|
30
|
+
bordered,
|
|
29
31
|
...rest
|
|
30
32
|
}: Circle_Props) {
|
|
31
33
|
return (
|
|
32
34
|
<div
|
|
33
|
-
className={`pointer avatar ${funcss || ''} ${`text-` + color?.trim() || ''} ${raised ? "raised" : ''} ${bg || 'lighter'} ${
|
|
35
|
+
className={` ${bordered ? "border" : ""}pointer avatar ${funcss || ''} ${`text-` + color?.trim() || ''} ${raised ? "raised" : ''} ${bg || 'lighter'} ${
|
|
34
36
|
hoverable ? 'hoverable' : ''
|
|
35
37
|
}`}
|
|
36
38
|
style={{
|
package/ui/text/Text.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ type TypographyProps = {
|
|
|
32
32
|
fontFamily?: string;
|
|
33
33
|
textShadow?: string;
|
|
34
34
|
textAlign?: "left" | "center" | "right" | "justify";
|
|
35
|
-
opacity?:
|
|
35
|
+
opacity?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
36
36
|
zIndex?: number;
|
|
37
37
|
truncate?: number;
|
|
38
38
|
transform?: string;
|
package/ui/text/Text.js
CHANGED
|
@@ -28,8 +28,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
var react_1 = __importDefault(require("react"));
|
|
29
29
|
var pi_1 = require("react-icons/pi");
|
|
30
30
|
var Text = function (_a) {
|
|
31
|
-
var id = _a.id, bg = _a.bg, color = _a.color, children = _a.children, hoverBg = _a.hoverBg, hoverText = _a.hoverText, text = _a.text, funcss = _a.funcss, emp = _a.emp, bold = _a.bold, block = _a.block, body = _a.body, article = _a.article, light = _a.light, lighter = _a.lighter, italic = _a.italic, weight = _a.weight, underline = _a.underline, align = _a.align, lineHeight = _a.lineHeight, letterSpacing = _a.letterSpacing, uppercase = _a.uppercase, lowercase = _a.lowercase, capitalize = _a.capitalize, textDecoration = _a.textDecoration, textTransform = _a.textTransform, whiteSpace = _a.whiteSpace, wordBreak = _a.wordBreak, fontFamily = _a.fontFamily, truncate = _a.truncate, textShadow = _a.textShadow, textAlign = _a.textAlign, customStyles = _a.customStyles, monospace = _a.monospace, quote = _a.quote, _b = _a.size, size = _b === void 0 ? 'base' : _b, // default
|
|
32
|
-
rest = __rest(_a, ["id", "bg", "color", "children", "hoverBg", "hoverText", "text", "funcss", "emp", "bold", "block", "body", "article", "light", "lighter", "italic", "weight", "underline", "align", "lineHeight", "letterSpacing", "uppercase", "lowercase", "capitalize", "textDecoration", "textTransform", "whiteSpace", "wordBreak", "fontFamily", "truncate", "textShadow", "textAlign", "customStyles", "monospace", "quote", "size"]);
|
|
31
|
+
var id = _a.id, bg = _a.bg, color = _a.color, children = _a.children, hoverBg = _a.hoverBg, hoverText = _a.hoverText, text = _a.text, funcss = _a.funcss, emp = _a.emp, bold = _a.bold, block = _a.block, body = _a.body, article = _a.article, light = _a.light, lighter = _a.lighter, italic = _a.italic, weight = _a.weight, underline = _a.underline, align = _a.align, lineHeight = _a.lineHeight, letterSpacing = _a.letterSpacing, uppercase = _a.uppercase, lowercase = _a.lowercase, capitalize = _a.capitalize, textDecoration = _a.textDecoration, textTransform = _a.textTransform, whiteSpace = _a.whiteSpace, wordBreak = _a.wordBreak, fontFamily = _a.fontFamily, truncate = _a.truncate, textShadow = _a.textShadow, textAlign = _a.textAlign, customStyles = _a.customStyles, monospace = _a.monospace, quote = _a.quote, opacity = _a.opacity, _b = _a.size, size = _b === void 0 ? 'base' : _b, // default
|
|
32
|
+
rest = __rest(_a, ["id", "bg", "color", "children", "hoverBg", "hoverText", "text", "funcss", "emp", "bold", "block", "body", "article", "light", "lighter", "italic", "weight", "underline", "align", "lineHeight", "letterSpacing", "uppercase", "lowercase", "capitalize", "textDecoration", "textTransform", "whiteSpace", "wordBreak", "fontFamily", "truncate", "textShadow", "textAlign", "customStyles", "monospace", "quote", "opacity", "size"]);
|
|
33
33
|
var Tag = block ? 'div' : 'span';
|
|
34
34
|
var sizeClass = "".concat(size === 'h1' ? "h1" :
|
|
35
35
|
size === 'h2' ? "h2" :
|
|
@@ -66,6 +66,7 @@ var Text = function (_a) {
|
|
|
66
66
|
uppercase ? 'uppercase' : '',
|
|
67
67
|
lowercase ? 'lowercase' : '',
|
|
68
68
|
capitalize ? 'capitalize' : '',
|
|
69
|
+
opacity ? 'opacity-' + opacity : '',
|
|
69
70
|
]
|
|
70
71
|
.filter(Boolean)
|
|
71
72
|
.join(' ');
|