@behivetech/templates.sidebar-layout 0.0.0-stage → 0.4.2
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 +38 -2
- package/dist/index.cjs +179 -0
- package/dist/index.css +22 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +165 -0
- package/docs.json +43 -0
- package/index.ts +2 -0
- package/package.json +56 -3
- package/sidebar-layout.example.tsx +7 -0
- package/sidebar-layout.module.scss +26 -0
- package/sidebar-layout.tsx +45 -0
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SidebarLayout
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A dumb CSS Grid skeleton with sidebar, topbar, and content regions. It has no
|
|
4
|
+
opinion on what the sidebar or topbar contain — the elements passed in are
|
|
5
|
+
responsible for their own `grid-area: sidebar` / `grid-area: topbar`
|
|
6
|
+
placement (e.g. via `@behivetech/atoms.sidebar`).
|
|
7
|
+
|
|
8
|
+
Sidebar width, topbar height, and content max-width are configurable via CSS
|
|
9
|
+
custom properties, each with a sensible default:
|
|
10
|
+
|
|
11
|
+
- `--sidebar-layout-sidebar-width` (default `13.75rem`)
|
|
12
|
+
- `--sidebar-layout-topbar-height` (default `3.5rem`)
|
|
13
|
+
- `--sidebar-layout-content-max-width` (default `75rem`)
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { SidebarLayout } from "@behivetech/templates.sidebar-layout";
|
|
19
|
+
import { Sidebar } from "@behivetech/atoms.sidebar";
|
|
20
|
+
import { NavItem } from "@behivetech/atoms.nav-item";
|
|
21
|
+
|
|
22
|
+
function Example() {
|
|
23
|
+
return (
|
|
24
|
+
<SidebarLayout
|
|
25
|
+
sidebar={
|
|
26
|
+
<Sidebar>
|
|
27
|
+
<NavItem href="#" active>
|
|
28
|
+
Pages
|
|
29
|
+
</NavItem>
|
|
30
|
+
<NavItem href="#">Media</NavItem>
|
|
31
|
+
</Sidebar>
|
|
32
|
+
}
|
|
33
|
+
topbar={<header style={{ padding: "0.75rem 1rem" }}>Topbar</header>}
|
|
34
|
+
>
|
|
35
|
+
Page content
|
|
36
|
+
</SidebarLayout>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
34
|
+
var require_classnames = __commonJS({
|
|
35
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
(function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
var hasOwn = {}.hasOwnProperty;
|
|
40
|
+
function classNames() {
|
|
41
|
+
var classes = "";
|
|
42
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
43
|
+
var arg = arguments[i];
|
|
44
|
+
if (arg) {
|
|
45
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return classes;
|
|
49
|
+
}
|
|
50
|
+
function parseValue(arg) {
|
|
51
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (typeof arg !== "object") {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(arg)) {
|
|
58
|
+
return classNames.apply(null, arg);
|
|
59
|
+
}
|
|
60
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
61
|
+
return arg.toString();
|
|
62
|
+
}
|
|
63
|
+
var classes = "";
|
|
64
|
+
for (var key in arg) {
|
|
65
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
66
|
+
classes = appendClass(classes, key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
}
|
|
71
|
+
function appendClass(value, newClass) {
|
|
72
|
+
if (!newClass) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (value) {
|
|
76
|
+
return value + " " + newClass;
|
|
77
|
+
}
|
|
78
|
+
return value + newClass;
|
|
79
|
+
}
|
|
80
|
+
if (typeof module2 !== "undefined" && module2.exports) {
|
|
81
|
+
classNames.default = classNames;
|
|
82
|
+
module2.exports = classNames;
|
|
83
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
84
|
+
define("classnames", [], function() {
|
|
85
|
+
return classNames;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
window.classNames = classNames;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// index.ts
|
|
95
|
+
var index_exports = {};
|
|
96
|
+
__export(index_exports, {
|
|
97
|
+
SidebarLayout: () => SidebarLayout
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(index_exports);
|
|
100
|
+
|
|
101
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
102
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
103
|
+
var getClassName = ({
|
|
104
|
+
className,
|
|
105
|
+
modifiers = {},
|
|
106
|
+
rootClass,
|
|
107
|
+
styles = {}
|
|
108
|
+
}) => {
|
|
109
|
+
function getModifiers() {
|
|
110
|
+
const updatedModifiers = {};
|
|
111
|
+
const modifierKeys = Object.keys(modifiers);
|
|
112
|
+
if (modifierKeys.length) {
|
|
113
|
+
modifierKeys.forEach((modKey) => {
|
|
114
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
115
|
+
const newClassName = styles[classKey] || classKey;
|
|
116
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return updatedModifiers;
|
|
120
|
+
}
|
|
121
|
+
function getChildClass(childClassName) {
|
|
122
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
123
|
+
return styles[classKey] || classKey;
|
|
124
|
+
}
|
|
125
|
+
function getRootStyles() {
|
|
126
|
+
return (0, import_classnames.default)(
|
|
127
|
+
className,
|
|
128
|
+
{
|
|
129
|
+
...getModifiers()
|
|
130
|
+
},
|
|
131
|
+
styles[rootClass] || rootClass
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return [getRootStyles(), getChildClass];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// sidebar-layout.module.scss
|
|
138
|
+
var sidebar_layout_module_default = {
|
|
139
|
+
"BHT__SidebarLayout": "BHT__SidebarLayout",
|
|
140
|
+
"BHT__SidebarLayout__main": "BHT__SidebarLayout__main",
|
|
141
|
+
"BHT__SidebarLayout__content": "BHT__SidebarLayout__content",
|
|
142
|
+
"BHT__SidebarLayout__inner": "BHT__SidebarLayout__inner"
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// sidebar-layout.tsx
|
|
146
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
147
|
+
var SidebarLayout = ({
|
|
148
|
+
className,
|
|
149
|
+
sidebar,
|
|
150
|
+
topbar,
|
|
151
|
+
children,
|
|
152
|
+
...rest
|
|
153
|
+
}) => {
|
|
154
|
+
const [rootClass, getChildClass] = getClassName({
|
|
155
|
+
className,
|
|
156
|
+
rootClass: "BHT__SidebarLayout",
|
|
157
|
+
styles: sidebar_layout_module_default
|
|
158
|
+
});
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...rest, className: rootClass, children: [
|
|
160
|
+
sidebar,
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: getChildClass("main"), children: [
|
|
162
|
+
topbar,
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("main", { className: getChildClass("content"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getChildClass("inner"), children }) })
|
|
164
|
+
] })
|
|
165
|
+
] });
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
SidebarLayout
|
|
170
|
+
});
|
|
171
|
+
/*! Bundled license information:
|
|
172
|
+
|
|
173
|
+
classnames/index.js:
|
|
174
|
+
(*!
|
|
175
|
+
Copyright (c) 2018 Jed Watson.
|
|
176
|
+
Licensed under the MIT License (MIT), see
|
|
177
|
+
http://jedwatson.github.io/classnames
|
|
178
|
+
*)
|
|
179
|
+
*/
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* esbuild-sass-plugin:css-chunksidebar-layout.module.scss */
|
|
2
|
+
.BHT__SidebarLayout {
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-columns: var(--sidebar-layout-sidebar-width, 13.75rem) 1fr;
|
|
5
|
+
grid-template-rows: var(--sidebar-layout-topbar-height, 3.5rem) 1fr;
|
|
6
|
+
grid-template-areas: "sidebar topbar" "sidebar content";
|
|
7
|
+
min-height: 100vh;
|
|
8
|
+
}
|
|
9
|
+
.BHT__SidebarLayout__main {
|
|
10
|
+
grid-column: 2;
|
|
11
|
+
display: contents;
|
|
12
|
+
}
|
|
13
|
+
.BHT__SidebarLayout__content {
|
|
14
|
+
grid-area: content;
|
|
15
|
+
background: var(--md-sys-color-background, var(--color-background));
|
|
16
|
+
color: var(--md-sys-color-on-background, var(--color-text-body));
|
|
17
|
+
overflow-y: auto;
|
|
18
|
+
}
|
|
19
|
+
.BHT__SidebarLayout__inner {
|
|
20
|
+
padding: var(--spacing-8);
|
|
21
|
+
max-width: var(--sidebar-layout-content-max-width, 75rem);
|
|
22
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface SidebarLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/** Additional class names to merge with the component root element */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Sidebar region content; the element rendered here owns its own `grid-area: sidebar` placement */
|
|
8
|
+
sidebar: ReactNode;
|
|
9
|
+
/** Topbar region content; the element rendered here owns its own `grid-area: topbar` placement */
|
|
10
|
+
topbar: ReactNode;
|
|
11
|
+
/** Main content region */
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dumb CSS Grid skeleton with sidebar, topbar, and content regions.
|
|
16
|
+
* Composition of the actual sidebar/topbar/content is left entirely to the
|
|
17
|
+
* consumer — this only owns the grid tracks and the content scroll area.
|
|
18
|
+
*/
|
|
19
|
+
declare const SidebarLayout: ({ className, sidebar, topbar, children, ...rest }: SidebarLayoutProps) => react.JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { SidebarLayout, type SidebarLayoutProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
28
|
+
var require_classnames = __commonJS({
|
|
29
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
(function() {
|
|
32
|
+
"use strict";
|
|
33
|
+
var hasOwn = {}.hasOwnProperty;
|
|
34
|
+
function classNames() {
|
|
35
|
+
var classes = "";
|
|
36
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
37
|
+
var arg = arguments[i];
|
|
38
|
+
if (arg) {
|
|
39
|
+
classes = appendClass(classes, parseValue(arg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes;
|
|
43
|
+
}
|
|
44
|
+
function parseValue(arg) {
|
|
45
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== "object") {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(arg)) {
|
|
52
|
+
return classNames.apply(null, arg);
|
|
53
|
+
}
|
|
54
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
55
|
+
return arg.toString();
|
|
56
|
+
}
|
|
57
|
+
var classes = "";
|
|
58
|
+
for (var key in arg) {
|
|
59
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
60
|
+
classes = appendClass(classes, key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return classes;
|
|
64
|
+
}
|
|
65
|
+
function appendClass(value, newClass) {
|
|
66
|
+
if (!newClass) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
return value + " " + newClass;
|
|
71
|
+
}
|
|
72
|
+
return value + newClass;
|
|
73
|
+
}
|
|
74
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
75
|
+
classNames.default = classNames;
|
|
76
|
+
module.exports = classNames;
|
|
77
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
78
|
+
define("classnames", [], function() {
|
|
79
|
+
return classNames;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
window.classNames = classNames;
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
89
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
90
|
+
var getClassName = ({
|
|
91
|
+
className,
|
|
92
|
+
modifiers = {},
|
|
93
|
+
rootClass,
|
|
94
|
+
styles = {}
|
|
95
|
+
}) => {
|
|
96
|
+
function getModifiers() {
|
|
97
|
+
const updatedModifiers = {};
|
|
98
|
+
const modifierKeys = Object.keys(modifiers);
|
|
99
|
+
if (modifierKeys.length) {
|
|
100
|
+
modifierKeys.forEach((modKey) => {
|
|
101
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
102
|
+
const newClassName = styles[classKey] || classKey;
|
|
103
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return updatedModifiers;
|
|
107
|
+
}
|
|
108
|
+
function getChildClass(childClassName) {
|
|
109
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
110
|
+
return styles[classKey] || classKey;
|
|
111
|
+
}
|
|
112
|
+
function getRootStyles() {
|
|
113
|
+
return (0, import_classnames.default)(
|
|
114
|
+
className,
|
|
115
|
+
{
|
|
116
|
+
...getModifiers()
|
|
117
|
+
},
|
|
118
|
+
styles[rootClass] || rootClass
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return [getRootStyles(), getChildClass];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// sidebar-layout.module.scss
|
|
125
|
+
var sidebar_layout_module_default = {
|
|
126
|
+
"BHT__SidebarLayout": "BHT__SidebarLayout",
|
|
127
|
+
"BHT__SidebarLayout__main": "BHT__SidebarLayout__main",
|
|
128
|
+
"BHT__SidebarLayout__content": "BHT__SidebarLayout__content",
|
|
129
|
+
"BHT__SidebarLayout__inner": "BHT__SidebarLayout__inner"
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// sidebar-layout.tsx
|
|
133
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
134
|
+
var SidebarLayout = ({
|
|
135
|
+
className,
|
|
136
|
+
sidebar,
|
|
137
|
+
topbar,
|
|
138
|
+
children,
|
|
139
|
+
...rest
|
|
140
|
+
}) => {
|
|
141
|
+
const [rootClass, getChildClass] = getClassName({
|
|
142
|
+
className,
|
|
143
|
+
rootClass: "BHT__SidebarLayout",
|
|
144
|
+
styles: sidebar_layout_module_default
|
|
145
|
+
});
|
|
146
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: rootClass, children: [
|
|
147
|
+
sidebar,
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { className: getChildClass("main"), children: [
|
|
149
|
+
topbar,
|
|
150
|
+
/* @__PURE__ */ jsx("main", { className: getChildClass("content"), children: /* @__PURE__ */ jsx("div", { className: getChildClass("inner"), children }) })
|
|
151
|
+
] })
|
|
152
|
+
] });
|
|
153
|
+
};
|
|
154
|
+
export {
|
|
155
|
+
SidebarLayout
|
|
156
|
+
};
|
|
157
|
+
/*! Bundled license information:
|
|
158
|
+
|
|
159
|
+
classnames/index.js:
|
|
160
|
+
(*!
|
|
161
|
+
Copyright (c) 2018 Jed Watson.
|
|
162
|
+
Licensed under the MIT License (MIT), see
|
|
163
|
+
http://jedwatson.github.io/classnames
|
|
164
|
+
*)
|
|
165
|
+
*/
|
package/docs.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-20T05:49:37.758Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "SidebarLayout",
|
|
8
|
+
"description": "Dumb CSS Grid skeleton with sidebar, topbar, and content regions.\nComposition of the actual sidebar/topbar/content is left entirely to the\nconsumer — this only owns the grid tracks and the content scroll area.",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "sidebar",
|
|
13
|
+
"type": "ReactNode",
|
|
14
|
+
"required": true,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Sidebar region content; the element rendered here owns its own `grid-area: sidebar` placement"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "topbar",
|
|
20
|
+
"type": "ReactNode",
|
|
21
|
+
"required": true,
|
|
22
|
+
"defaultValue": null,
|
|
23
|
+
"description": "Topbar region content; the element rendered here owns its own `grid-area: topbar` placement"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "children",
|
|
27
|
+
"type": "ReactNode",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": null,
|
|
30
|
+
"description": "Main content region"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "className",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"required": false,
|
|
36
|
+
"defaultValue": null,
|
|
37
|
+
"description": "Additional class names to merge with the component root element"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"functions": []
|
|
43
|
+
}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/templates.sidebar-layout",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./dist/index.css"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"index.ts",
|
|
19
|
+
"sidebar-layout.tsx",
|
|
20
|
+
"sidebar-layout.module.scss",
|
|
21
|
+
"*.example.tsx",
|
|
22
|
+
"docs.json"
|
|
23
|
+
],
|
|
24
|
+
"registry": {
|
|
25
|
+
"status": "stable",
|
|
26
|
+
"tags": []
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.2.7",
|
|
30
|
+
"react-dom": "^19.2.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "19.2.17",
|
|
34
|
+
"@types/react-dom": "19.2.3",
|
|
35
|
+
"eslint": "^9.39.5",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"vitest": "^4.1.10",
|
|
39
|
+
"@bht-component-registry/env": "0.1.0",
|
|
40
|
+
"@bht-component-registry/class-names": "0.0.6"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
45
|
+
"directory": "registry/behivetech/templates/sidebar-layout"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org",
|
|
49
|
+
"access": "public",
|
|
50
|
+
"provenance": true
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup && bht-registry-docgen",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"lint": "eslint . --max-warnings 0",
|
|
56
|
+
"check-types": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run"
|
|
58
|
+
}
|
|
6
59
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.BHT__SidebarLayout {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: var(--sidebar-layout-sidebar-width, 13.75rem) 1fr;
|
|
4
|
+
grid-template-rows: var(--sidebar-layout-topbar-height, 3.5rem) 1fr;
|
|
5
|
+
grid-template-areas:
|
|
6
|
+
"sidebar topbar"
|
|
7
|
+
"sidebar content";
|
|
8
|
+
min-height: 100vh;
|
|
9
|
+
|
|
10
|
+
&__main {
|
|
11
|
+
grid-column: 2;
|
|
12
|
+
display: contents;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&__content {
|
|
16
|
+
grid-area: content;
|
|
17
|
+
background: var(--md-sys-color-background, var(--color-background));
|
|
18
|
+
color: var(--md-sys-color-on-background, var(--color-text-body));
|
|
19
|
+
overflow-y: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__inner {
|
|
23
|
+
padding: var(--spacing-8);
|
|
24
|
+
max-width: var(--sidebar-layout-content-max-width, 75rem);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { getClassName } from "@bht-component-registry/class-names";
|
|
3
|
+
import styles from "./sidebar-layout.module.scss";
|
|
4
|
+
|
|
5
|
+
export interface SidebarLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** Additional class names to merge with the component root element */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Sidebar region content; the element rendered here owns its own `grid-area: sidebar` placement */
|
|
9
|
+
sidebar: ReactNode;
|
|
10
|
+
/** Topbar region content; the element rendered here owns its own `grid-area: topbar` placement */
|
|
11
|
+
topbar: ReactNode;
|
|
12
|
+
/** Main content region */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Dumb CSS Grid skeleton with sidebar, topbar, and content regions.
|
|
18
|
+
* Composition of the actual sidebar/topbar/content is left entirely to the
|
|
19
|
+
* consumer — this only owns the grid tracks and the content scroll area.
|
|
20
|
+
*/
|
|
21
|
+
export const SidebarLayout = ({
|
|
22
|
+
className,
|
|
23
|
+
sidebar,
|
|
24
|
+
topbar,
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
}: SidebarLayoutProps) => {
|
|
28
|
+
const [rootClass, getChildClass] = getClassName({
|
|
29
|
+
className,
|
|
30
|
+
rootClass: "BHT__SidebarLayout",
|
|
31
|
+
styles,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div {...rest} className={rootClass}>
|
|
36
|
+
{sidebar}
|
|
37
|
+
<div className={getChildClass("main")}>
|
|
38
|
+
{topbar}
|
|
39
|
+
<main className={getChildClass("content")}>
|
|
40
|
+
<div className={getChildClass("inner")}>{children}</div>
|
|
41
|
+
</main>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|