@behivetech/atoms.sidebar 1.0.0 → 1.1.0
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/LICENSE +21 -0
- package/README.md +9 -1
- package/dist/index.cjs +42 -12
- package/dist/index.css +21 -11
- package/dist/index.d.ts +40 -1
- package/dist/index.js +42 -12
- package/dist/index.native.js +63 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/sidebar.block.d.ts +34 -0
- package/dist/native/sidebar.block.native.d.ts +2 -0
- package/dist/native/sidebar.native.d.ts +22 -0
- package/docs.json +8 -1
- package/index.ts +2 -2
- package/package.json +26 -8
- package/sidebar.block.css +25 -0
- package/sidebar.block.native.ts +48 -0
- package/sidebar.block.ts +33 -0
- package/sidebar.native.tsx +46 -0
- package/sidebar.tsx +15 -9
- package/sidebar.module.scss +0 -17
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BEhive Tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
A dumb, styled sidebar shell — sticky, full-height, scrollable flex
|
|
4
4
|
container. It renders an `<aside>` and applies no internal structure; the
|
|
5
5
|
consumer is responsible for composing whatever goes inside (logo, nav,
|
|
6
|
-
`NavItem`s, etc.).
|
|
6
|
+
`NavItem`s, etc.). Below the `sm` breakpoint (40rem, a phone) it is as tall
|
|
7
|
+
as its content and does not stick, so `SidebarLayout` can stack it above
|
|
8
|
+
the page.
|
|
7
9
|
|
|
8
10
|
Docs: https://platform.behivetech.com/behivetech/atoms/sidebar
|
|
9
11
|
|
|
@@ -22,3 +24,9 @@ import { NavItem } from "@behivetech/atoms.nav-item";
|
|
|
22
24
|
</nav>
|
|
23
25
|
</Sidebar>;
|
|
24
26
|
```
|
|
27
|
+
|
|
28
|
+
## On React Native
|
|
29
|
+
|
|
30
|
+
The native `Sidebar` is a column `View` with the same surface and text color; `style` is `className` there. The web's sticky, full-height, scrolling behavior has no native counterpart: give it a height (or `flex: 1`) in `style`, and put a `ScrollView` inside when the content can overflow.
|
|
31
|
+
|
|
32
|
+
React Native has no text inheritance. Text you pass straight in as `children` (a string or a number, alone or in a list or a fragment) is drawn by the sidebar, in a `Text` with the sidebar's color and the body type; a `Text` of your own gets nothing from it, so give it a color.
|
package/dist/index.cjs
CHANGED
|
@@ -25,22 +25,52 @@ __export(index_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
|
|
27
27
|
// sidebar.tsx
|
|
28
|
-
var
|
|
28
|
+
var import_blocks2 = require("@behivetech/blocks.core");
|
|
29
29
|
|
|
30
|
-
// sidebar.
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
};
|
|
30
|
+
// sidebar.block.ts
|
|
31
|
+
var import_blocks = require("@behivetech/blocks.core");
|
|
32
|
+
var import_tokens = require("@behivetech/blocks.core/tokens");
|
|
33
|
+
var { color, type } = import_tokens.tokens;
|
|
34
|
+
var sidebar = (0, import_blocks.defineBlock)("BHT__Sidebar", {
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: "column",
|
|
37
|
+
top: 0,
|
|
38
|
+
backgroundColor: color.surfaceContainerLow,
|
|
39
|
+
color: color.onSurfaceVariant,
|
|
40
|
+
children: {
|
|
41
|
+
// Native only: text given straight to the sidebar. React Native has no inheritance, so the renderer draws it
|
|
42
|
+
// in a `Text` of its own, which takes the sidebar's color (the root's text twin) and the body type the
|
|
43
|
+
// document gives it on the web. It writes no CSS.
|
|
44
|
+
text: {
|
|
45
|
+
native: {
|
|
46
|
+
fontFamily: type.bodyLarge.font,
|
|
47
|
+
fontSize: type.bodyLarge.size,
|
|
48
|
+
fontWeight: type.bodyLarge.weight,
|
|
49
|
+
lineHeight: type.bodyLarge.lineHeight,
|
|
50
|
+
letterSpacing: type.bodyLarge.tracking
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
web: {
|
|
55
|
+
position: "sticky",
|
|
56
|
+
height: "100vh",
|
|
57
|
+
overflowY: "auto",
|
|
58
|
+
"&": { height: "100dvh" }
|
|
59
|
+
},
|
|
60
|
+
// a phone: a row as tall as its content, which SidebarLayout stacks above the page, not a column of the screen
|
|
61
|
+
media: { maxSm: { web: { position: "static", height: "auto" } } }
|
|
62
|
+
});
|
|
34
63
|
|
|
35
64
|
// sidebar.tsx
|
|
36
65
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var Sidebar = ({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
var Sidebar = ({
|
|
67
|
+
className,
|
|
68
|
+
children,
|
|
69
|
+
styles,
|
|
70
|
+
...rest
|
|
71
|
+
}) => {
|
|
72
|
+
const [rootProps] = (0, import_blocks2.useBlock)(sidebar, {}, { className, styles });
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("aside", { ...rest, ...rootProps, children });
|
|
44
74
|
};
|
|
45
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
76
|
0 && (module.exports = {
|
package/dist/index.css
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/* sidebar.block.css */
|
|
2
|
+
@layer bht {
|
|
3
|
+
.BHT__Sidebar {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
top: 0;
|
|
7
|
+
background-color: var(--md-sys-color-surface-container-low, #f3f3f3);
|
|
8
|
+
color: var(--md-sys-color-on-surface-variant, #474747);
|
|
9
|
+
position: sticky;
|
|
10
|
+
height: 100vh;
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
}
|
|
13
|
+
.BHT__Sidebar {
|
|
14
|
+
height: 100dvh;
|
|
15
|
+
}
|
|
16
|
+
@media (max-width: 40rem) {
|
|
17
|
+
.BHT__Sidebar {
|
|
18
|
+
position: static;
|
|
19
|
+
height: auto;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
12
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,55 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import * as _behivetech_blocks_core from '@behivetech/blocks.core';
|
|
4
|
+
import { StylesFor } from '@behivetech/blocks.core';
|
|
5
|
+
|
|
6
|
+
declare const sidebar: _behivetech_blocks_core.Block<"BHT__Sidebar", {
|
|
7
|
+
readonly display: "flex";
|
|
8
|
+
readonly flexDirection: "column";
|
|
9
|
+
readonly top: 0;
|
|
10
|
+
readonly backgroundColor: _behivetech_blocks_core.Token<"color">;
|
|
11
|
+
readonly color: _behivetech_blocks_core.Token<"color">;
|
|
12
|
+
readonly children: {
|
|
13
|
+
readonly text: {
|
|
14
|
+
readonly native: {
|
|
15
|
+
readonly fontFamily: _behivetech_blocks_core.Token<"font">;
|
|
16
|
+
readonly fontSize: _behivetech_blocks_core.Token<"length">;
|
|
17
|
+
readonly fontWeight: _behivetech_blocks_core.Token<"weight">;
|
|
18
|
+
readonly lineHeight: _behivetech_blocks_core.Token<"length">;
|
|
19
|
+
readonly letterSpacing: _behivetech_blocks_core.Token<"tracking">;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly web: {
|
|
24
|
+
readonly position: "sticky";
|
|
25
|
+
readonly height: "100vh";
|
|
26
|
+
readonly overflowY: "auto";
|
|
27
|
+
readonly "&": {
|
|
28
|
+
readonly height: "100dvh";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly media: {
|
|
32
|
+
readonly maxSm: {
|
|
33
|
+
readonly web: {
|
|
34
|
+
readonly position: "static";
|
|
35
|
+
readonly height: "auto";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
3
40
|
|
|
4
41
|
interface SidebarProps extends HTMLAttributes<HTMLElement> {
|
|
5
42
|
/** Additional class names to merge with the component root element */
|
|
6
43
|
className?: string;
|
|
7
44
|
/** Content to render inside the sidebar */
|
|
8
45
|
children?: ReactNode;
|
|
46
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
47
|
+
styles?: StylesFor<typeof sidebar>;
|
|
9
48
|
}
|
|
10
49
|
/**
|
|
11
50
|
* Dumb, styled sidebar shell — sticky, full-height, scrollable container.
|
|
12
51
|
* Composition of logo, nav, links, etc. is left entirely to the consumer.
|
|
13
52
|
*/
|
|
14
|
-
declare const Sidebar: ({ className, children, ...rest }: SidebarProps) => react.JSX.Element;
|
|
53
|
+
declare const Sidebar: ({ className, children, styles, ...rest }: SidebarProps) => react.JSX.Element;
|
|
15
54
|
|
|
16
55
|
export { Sidebar, type SidebarProps };
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
// sidebar.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { useBlock } from "@behivetech/blocks.core";
|
|
3
3
|
|
|
4
|
-
// sidebar.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
4
|
+
// sidebar.block.ts
|
|
5
|
+
import { defineBlock } from "@behivetech/blocks.core";
|
|
6
|
+
import { tokens } from "@behivetech/blocks.core/tokens";
|
|
7
|
+
var { color, type } = tokens;
|
|
8
|
+
var sidebar = defineBlock("BHT__Sidebar", {
|
|
9
|
+
display: "flex",
|
|
10
|
+
flexDirection: "column",
|
|
11
|
+
top: 0,
|
|
12
|
+
backgroundColor: color.surfaceContainerLow,
|
|
13
|
+
color: color.onSurfaceVariant,
|
|
14
|
+
children: {
|
|
15
|
+
// Native only: text given straight to the sidebar. React Native has no inheritance, so the renderer draws it
|
|
16
|
+
// in a `Text` of its own, which takes the sidebar's color (the root's text twin) and the body type the
|
|
17
|
+
// document gives it on the web. It writes no CSS.
|
|
18
|
+
text: {
|
|
19
|
+
native: {
|
|
20
|
+
fontFamily: type.bodyLarge.font,
|
|
21
|
+
fontSize: type.bodyLarge.size,
|
|
22
|
+
fontWeight: type.bodyLarge.weight,
|
|
23
|
+
lineHeight: type.bodyLarge.lineHeight,
|
|
24
|
+
letterSpacing: type.bodyLarge.tracking
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
web: {
|
|
29
|
+
position: "sticky",
|
|
30
|
+
height: "100vh",
|
|
31
|
+
overflowY: "auto",
|
|
32
|
+
"&": { height: "100dvh" }
|
|
33
|
+
},
|
|
34
|
+
// a phone: a row as tall as its content, which SidebarLayout stacks above the page, not a column of the screen
|
|
35
|
+
media: { maxSm: { web: { position: "static", height: "auto" } } }
|
|
36
|
+
});
|
|
8
37
|
|
|
9
38
|
// sidebar.tsx
|
|
10
39
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
var Sidebar = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
40
|
+
var Sidebar = ({
|
|
41
|
+
className,
|
|
42
|
+
children,
|
|
43
|
+
styles,
|
|
44
|
+
...rest
|
|
45
|
+
}) => {
|
|
46
|
+
const [rootProps] = useBlock(sidebar, {}, { className, styles });
|
|
47
|
+
return /* @__PURE__ */ jsx("aside", { ...rest, ...rootProps, children });
|
|
18
48
|
};
|
|
19
49
|
export {
|
|
20
50
|
Sidebar
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// sidebar.native.tsx
|
|
2
|
+
import {
|
|
3
|
+
holdsText,
|
|
4
|
+
useBlock
|
|
5
|
+
} from "@behivetech/blocks.core/native";
|
|
6
|
+
import {
|
|
7
|
+
Text,
|
|
8
|
+
View
|
|
9
|
+
} from "react-native";
|
|
10
|
+
|
|
11
|
+
// sidebar.block.native.ts
|
|
12
|
+
import { createNativeBlock as __bhtCreateNativeBlock } from "@behivetech/blocks.core/native";
|
|
13
|
+
import { StyleSheet as __bhtStyleSheet } from "react-native";
|
|
14
|
+
var __bht0_shared = __bhtStyleSheet.create({
|
|
15
|
+
__text: {
|
|
16
|
+
fontFamily: "Inter",
|
|
17
|
+
fontSize: 16,
|
|
18
|
+
fontWeight: "400",
|
|
19
|
+
lineHeight: 24,
|
|
20
|
+
letterSpacing: 0.5008
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var __bht0_light = __bhtStyleSheet.create({
|
|
24
|
+
root: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexDirection: "column",
|
|
27
|
+
top: 0,
|
|
28
|
+
backgroundColor: "#f3f3f3",
|
|
29
|
+
color: "#474747"
|
|
30
|
+
},
|
|
31
|
+
"root~text": { color: "#474747" }
|
|
32
|
+
});
|
|
33
|
+
var __bht0_dark = __bhtStyleSheet.create({
|
|
34
|
+
root: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexDirection: "column",
|
|
37
|
+
top: 0,
|
|
38
|
+
backgroundColor: "#1b1b1b",
|
|
39
|
+
color: "#c6c6c6"
|
|
40
|
+
},
|
|
41
|
+
"root~text": { color: "#c6c6c6" }
|
|
42
|
+
});
|
|
43
|
+
var sidebar = __bhtCreateNativeBlock("BHT__Sidebar", {
|
|
44
|
+
structure: { children: { text: {} } },
|
|
45
|
+
sheets: {
|
|
46
|
+
light: { ...__bht0_shared, ...__bht0_light },
|
|
47
|
+
dark: { ...__bht0_shared, ...__bht0_dark }
|
|
48
|
+
},
|
|
49
|
+
plan: {
|
|
50
|
+
root: [{ key: "root" }],
|
|
51
|
+
children: { text: [{ key: "root~text" }, { key: "__text" }] }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// sidebar.native.tsx
|
|
56
|
+
import { jsx } from "react/jsx-runtime";
|
|
57
|
+
var Sidebar = ({ style, styles, children, ...rest }) => {
|
|
58
|
+
const [rootProps, childProps] = useBlock(sidebar, {}, { style, styles });
|
|
59
|
+
return /* @__PURE__ */ jsx(View, { ...rest, ...rootProps, children: holdsText(children) ? /* @__PURE__ */ jsx(Text, { ...childProps("text"), children }) : children });
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
Sidebar
|
|
63
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const sidebar: import("@behivetech/blocks.core").Block<"BHT__Sidebar", {
|
|
2
|
+
readonly display: "flex";
|
|
3
|
+
readonly flexDirection: "column";
|
|
4
|
+
readonly top: 0;
|
|
5
|
+
readonly backgroundColor: import("@behivetech/blocks.core").Token<"color">;
|
|
6
|
+
readonly color: import("@behivetech/blocks.core").Token<"color">;
|
|
7
|
+
readonly children: {
|
|
8
|
+
readonly text: {
|
|
9
|
+
readonly native: {
|
|
10
|
+
readonly fontFamily: import("@behivetech/blocks.core").Token<"font">;
|
|
11
|
+
readonly fontSize: import("@behivetech/blocks.core").Token<"length">;
|
|
12
|
+
readonly fontWeight: import("@behivetech/blocks.core").Token<"weight">;
|
|
13
|
+
readonly lineHeight: import("@behivetech/blocks.core").Token<"length">;
|
|
14
|
+
readonly letterSpacing: import("@behivetech/blocks.core").Token<"tracking">;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly web: {
|
|
19
|
+
readonly position: "sticky";
|
|
20
|
+
readonly height: "100vh";
|
|
21
|
+
readonly overflowY: "auto";
|
|
22
|
+
readonly "&": {
|
|
23
|
+
readonly height: "100dvh";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly media: {
|
|
27
|
+
readonly maxSm: {
|
|
28
|
+
readonly web: {
|
|
29
|
+
readonly position: "static";
|
|
30
|
+
readonly height: "auto";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StylesFor } from "@behivetech/blocks.core/native";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
4
|
+
import { sidebar } from "./sidebar.block.native";
|
|
5
|
+
export interface SidebarProps extends Omit<ViewProps, "style" | "children"> {
|
|
6
|
+
/** Additional styles, appended after the block's own */
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
9
|
+
styles?: StylesFor<typeof sidebar>;
|
|
10
|
+
/**
|
|
11
|
+
* Content to render inside the sidebar. Text you pass straight in (a string or a number, alone or in a list or
|
|
12
|
+
* a fragment) is drawn in a `Text` with the sidebar's color and the body type; a `Text` of your own cannot
|
|
13
|
+
* inherit them, because React Native has no inheritance
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The React Native renderer of Sidebar: a column container with the same surface. The web's sticky, scrolling,
|
|
19
|
+
* full-height behavior has no native counterpart: give it a height (or `flex: 1`) through `style` and put a
|
|
20
|
+
* `ScrollView` inside when the content can overflow.
|
|
21
|
+
*/
|
|
22
|
+
export declare const Sidebar: ({ style, styles, children, ...rest }: SidebarProps) => import("react").JSX.Element;
|
package/docs.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
3
|
"version": 2,
|
|
4
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"generatedAt": "2026-11-26T04:49:28.707Z",
|
|
5
5
|
"docs": [
|
|
6
6
|
{
|
|
7
7
|
"displayName": "Sidebar",
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
"required": false,
|
|
22
22
|
"defaultValue": null,
|
|
23
23
|
"description": "Additional class names to merge with the component root element"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "styles",
|
|
27
|
+
"type": "StylesFor<Block<\"BHT__Sidebar\", { readonly display: \"flex\"; readonly flexDirection: \"column\"; readonly top: 0; readonly backgroundColor: Token<\"color\">; readonly color: Token<\"color\">; readonly children: { ...; }; readonly web: { ...; }; readonly media: { ...; }; }>>",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": null,
|
|
30
|
+
"description": "An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles."
|
|
24
31
|
}
|
|
25
32
|
]
|
|
26
33
|
}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Sidebar } from "./sidebar
|
|
2
|
-
export type { SidebarProps } from "./sidebar
|
|
1
|
+
export { Sidebar } from "./sidebar";
|
|
2
|
+
export type { SidebarProps } from "./sidebar";
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.sidebar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "A dumb, styled sidebar shell — sticky, full-height, scrollable flex container. It renders an `<aside>` and applies no internal structure; the consumer is responsible for composing whatever goes inside (logo, nav, `NavItem`s, etc.).",
|
|
5
|
+
"description": "A dumb, styled sidebar shell — sticky, full-height, scrollable flex container. It renders an `<aside>` and applies no internal structure; the consumer is responsible for composing whatever goes inside (logo, nav, `NavItem`s, etc.). Below the `sm` breakpoint (40rem, a phone) it is as tall as its content and does not stick, so `SidebarLayout` can stack it above the page.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
8
8
|
"sideEffects": [
|
|
@@ -10,18 +10,26 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"react-native": {
|
|
14
|
+
"types": "./dist/native/index.d.ts",
|
|
15
|
+
"default": "./dist/index.native.js"
|
|
16
|
+
},
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
14
18
|
"import": "./dist/index.js",
|
|
15
19
|
"require": "./dist/index.cjs"
|
|
16
20
|
},
|
|
17
21
|
"./styles.css": "./dist/index.css"
|
|
18
22
|
},
|
|
23
|
+
"react-native": "./dist/index.native.js",
|
|
19
24
|
"files": [
|
|
20
25
|
"dist",
|
|
21
26
|
"README.md",
|
|
22
27
|
"index.ts",
|
|
23
28
|
"sidebar.tsx",
|
|
24
|
-
"sidebar.
|
|
29
|
+
"sidebar.native.tsx",
|
|
30
|
+
"sidebar.block.ts",
|
|
31
|
+
"sidebar.block.css",
|
|
32
|
+
"sidebar.block.native.ts",
|
|
25
33
|
"*.example.tsx",
|
|
26
34
|
"docs.json"
|
|
27
35
|
],
|
|
@@ -30,17 +38,27 @@
|
|
|
30
38
|
"tags": []
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
|
-
"@behivetech/
|
|
41
|
+
"@behivetech/blocks.core": "0.1.0"
|
|
34
42
|
},
|
|
35
43
|
"peerDependencies": {
|
|
36
44
|
"react": "^19.2.7",
|
|
37
|
-
"react-dom": "^19.2.7"
|
|
45
|
+
"react-dom": "^19.2.7",
|
|
46
|
+
"react-native": "*"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"react-native": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
38
52
|
},
|
|
39
53
|
"devDependencies": {
|
|
40
|
-
"@
|
|
54
|
+
"@behivetech/blocks.builder": "0.1.0",
|
|
55
|
+
"@behivetech/blocks.native-test": "0.0.1",
|
|
56
|
+
"@bht-component-registry/env": "0.3.0",
|
|
41
57
|
"@types/react": "19.2.17",
|
|
42
58
|
"@types/react-dom": "19.2.3",
|
|
43
59
|
"eslint": "^9.39.5",
|
|
60
|
+
"react": "19.2.8",
|
|
61
|
+
"react-dom": "19.2.8",
|
|
44
62
|
"tsup": "^8.5.1",
|
|
45
63
|
"typescript": "^6.0.3",
|
|
46
64
|
"vitest": "^4.1.10"
|
|
@@ -48,7 +66,7 @@
|
|
|
48
66
|
"repository": {
|
|
49
67
|
"type": "git",
|
|
50
68
|
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
51
|
-
"directory": "
|
|
69
|
+
"directory": "packages/atoms/sidebar"
|
|
52
70
|
},
|
|
53
71
|
"homepage": "https://platform.behivetech.com/behivetech/atoms/sidebar",
|
|
54
72
|
"publishConfig": {
|
|
@@ -56,7 +74,7 @@
|
|
|
56
74
|
"access": "public"
|
|
57
75
|
},
|
|
58
76
|
"scripts": {
|
|
59
|
-
"build": "tsup && bht-registry-docgen",
|
|
77
|
+
"build": "block check && tsup && bht-registry-docgen",
|
|
60
78
|
"dev": "tsup --watch",
|
|
61
79
|
"lint": "eslint . --max-warnings 0",
|
|
62
80
|
"check-types": "tsc --noEmit",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* GENERATED from sidebar.block.ts by @behivetech/blocks.builder. Do not edit by hand: run `pnpm block:build`. */
|
|
2
|
+
|
|
3
|
+
@layer bht {
|
|
4
|
+
.BHT__Sidebar {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
top: 0;
|
|
8
|
+
background-color: var(--md-sys-color-surface-container-low, #f3f3f3);
|
|
9
|
+
color: var(--md-sys-color-on-surface-variant, #474747);
|
|
10
|
+
position: sticky;
|
|
11
|
+
height: 100vh;
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.BHT__Sidebar {
|
|
16
|
+
height: 100dvh;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (max-width: 40rem) {
|
|
20
|
+
.BHT__Sidebar {
|
|
21
|
+
position: static;
|
|
22
|
+
height: auto;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// GENERATED from sidebar.block.ts by @behivetech/blocks.builder. Do not edit by hand: run `pnpm block:build`.
|
|
2
|
+
import { createNativeBlock as __bhtCreateNativeBlock } from "@behivetech/blocks.core/native";
|
|
3
|
+
import { StyleSheet as __bhtStyleSheet } from "react-native";
|
|
4
|
+
import type { sidebar as __bht0_source } from "./sidebar.block";
|
|
5
|
+
|
|
6
|
+
// Entries that read no color token are one object in both schemes.
|
|
7
|
+
const __bht0_shared = __bhtStyleSheet.create({
|
|
8
|
+
__text: {
|
|
9
|
+
fontFamily: "Inter",
|
|
10
|
+
fontSize: 16,
|
|
11
|
+
fontWeight: "400",
|
|
12
|
+
lineHeight: 24,
|
|
13
|
+
letterSpacing: 0.5008,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const __bht0_light = __bhtStyleSheet.create({
|
|
17
|
+
root: {
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection: "column",
|
|
20
|
+
top: 0,
|
|
21
|
+
backgroundColor: "#f3f3f3",
|
|
22
|
+
color: "#474747",
|
|
23
|
+
},
|
|
24
|
+
"root~text": { color: "#474747" },
|
|
25
|
+
});
|
|
26
|
+
const __bht0_dark = __bhtStyleSheet.create({
|
|
27
|
+
root: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "column",
|
|
30
|
+
top: 0,
|
|
31
|
+
backgroundColor: "#1b1b1b",
|
|
32
|
+
color: "#c6c6c6",
|
|
33
|
+
},
|
|
34
|
+
"root~text": { color: "#c6c6c6" },
|
|
35
|
+
});
|
|
36
|
+
export const sidebar: typeof __bht0_source = __bhtCreateNativeBlock<
|
|
37
|
+
typeof __bht0_source
|
|
38
|
+
>("BHT__Sidebar", {
|
|
39
|
+
structure: { children: { text: {} } },
|
|
40
|
+
sheets: {
|
|
41
|
+
light: { ...__bht0_shared, ...__bht0_light },
|
|
42
|
+
dark: { ...__bht0_shared, ...__bht0_dark },
|
|
43
|
+
},
|
|
44
|
+
plan: {
|
|
45
|
+
root: [{ key: "root" }],
|
|
46
|
+
children: { text: [{ key: "root~text" }, { key: "__text" }] },
|
|
47
|
+
},
|
|
48
|
+
});
|
package/sidebar.block.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Converted from sidebar.module.scss by `block convert`; this file is the source from here on.
|
|
2
|
+
import { defineBlock } from "@behivetech/blocks.core";
|
|
3
|
+
import { tokens } from "@behivetech/blocks.core/tokens";
|
|
4
|
+
const { color, type } = tokens;
|
|
5
|
+
export const sidebar = defineBlock("BHT__Sidebar", {
|
|
6
|
+
display: "flex",
|
|
7
|
+
flexDirection: "column",
|
|
8
|
+
top: 0,
|
|
9
|
+
backgroundColor: color.surfaceContainerLow,
|
|
10
|
+
color: color.onSurfaceVariant,
|
|
11
|
+
children: {
|
|
12
|
+
// Native only: text given straight to the sidebar. React Native has no inheritance, so the renderer draws it
|
|
13
|
+
// in a `Text` of its own, which takes the sidebar's color (the root's text twin) and the body type the
|
|
14
|
+
// document gives it on the web. It writes no CSS.
|
|
15
|
+
text: {
|
|
16
|
+
native: {
|
|
17
|
+
fontFamily: type.bodyLarge.font,
|
|
18
|
+
fontSize: type.bodyLarge.size,
|
|
19
|
+
fontWeight: type.bodyLarge.weight,
|
|
20
|
+
lineHeight: type.bodyLarge.lineHeight,
|
|
21
|
+
letterSpacing: type.bodyLarge.tracking,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
web: {
|
|
26
|
+
position: "sticky",
|
|
27
|
+
height: "100vh",
|
|
28
|
+
overflowY: "auto",
|
|
29
|
+
"&": { height: "100dvh" },
|
|
30
|
+
},
|
|
31
|
+
// a phone: a row as tall as its content, which SidebarLayout stacks above the page, not a column of the screen
|
|
32
|
+
media: { maxSm: { web: { position: "static", height: "auto" } } },
|
|
33
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
holdsText,
|
|
3
|
+
useBlock,
|
|
4
|
+
type StylesFor,
|
|
5
|
+
} from "@behivetech/blocks.core/native";
|
|
6
|
+
import { type ReactNode } from "react";
|
|
7
|
+
import {
|
|
8
|
+
Text,
|
|
9
|
+
View,
|
|
10
|
+
type StyleProp,
|
|
11
|
+
type ViewProps,
|
|
12
|
+
type ViewStyle,
|
|
13
|
+
} from "react-native";
|
|
14
|
+
import { sidebar } from "./sidebar.block";
|
|
15
|
+
|
|
16
|
+
export interface SidebarProps extends Omit<ViewProps, "style" | "children"> {
|
|
17
|
+
/** Additional styles, appended after the block's own */
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
20
|
+
styles?: StylesFor<typeof sidebar>;
|
|
21
|
+
/**
|
|
22
|
+
* Content to render inside the sidebar. Text you pass straight in (a string or a number, alone or in a list or
|
|
23
|
+
* a fragment) is drawn in a `Text` with the sidebar's color and the body type; a `Text` of your own cannot
|
|
24
|
+
* inherit them, because React Native has no inheritance
|
|
25
|
+
*/
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The React Native renderer of Sidebar: a column container with the same surface. The web's sticky, scrolling,
|
|
31
|
+
* full-height behavior has no native counterpart: give it a height (or `flex: 1`) through `style` and put a
|
|
32
|
+
* `ScrollView` inside when the content can overflow.
|
|
33
|
+
*/
|
|
34
|
+
export const Sidebar = ({ style, styles, children, ...rest }: SidebarProps) => {
|
|
35
|
+
const [rootProps, childProps] = useBlock(sidebar, {}, { style, styles });
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View {...rest} {...rootProps}>
|
|
39
|
+
{holdsText(children) ? (
|
|
40
|
+
<Text {...childProps("text")}>{children}</Text>
|
|
41
|
+
) : (
|
|
42
|
+
children
|
|
43
|
+
)}
|
|
44
|
+
</View>
|
|
45
|
+
);
|
|
46
|
+
};
|
package/sidebar.tsx
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import "./sidebar.block.css";
|
|
4
|
+
import { useBlock, type StylesFor } from "@behivetech/blocks.core";
|
|
5
|
+
import { sidebar } from "./sidebar.block";
|
|
4
6
|
|
|
5
7
|
export interface SidebarProps extends HTMLAttributes<HTMLElement> {
|
|
6
8
|
/** Additional class names to merge with the component root element */
|
|
7
9
|
className?: string;
|
|
8
10
|
/** Content to render inside the sidebar */
|
|
9
11
|
children?: ReactNode;
|
|
12
|
+
|
|
13
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
14
|
+
styles?: StylesFor<typeof sidebar>;
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* Dumb, styled sidebar shell — sticky, full-height, scrollable container.
|
|
14
19
|
* Composition of logo, nav, links, etc. is left entirely to the consumer.
|
|
15
20
|
*/
|
|
16
|
-
export const Sidebar = ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
export const Sidebar = ({
|
|
22
|
+
className,
|
|
23
|
+
children,
|
|
24
|
+
styles,
|
|
25
|
+
...rest
|
|
26
|
+
}: SidebarProps) => {
|
|
27
|
+
const [rootProps] = useBlock(sidebar, {}, { className, styles });
|
|
22
28
|
|
|
23
29
|
return (
|
|
24
|
-
<aside {...rest}
|
|
30
|
+
<aside {...rest} {...rootProps}>
|
|
25
31
|
{children}
|
|
26
32
|
</aside>
|
|
27
33
|
);
|
package/sidebar.module.scss
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Material Design 3 standard navigation drawer container. The background
|
|
2
|
-
// previously came from `--admin-sidebar-bg`, which only the CMS admin app
|
|
3
|
-
// defined.
|
|
4
|
-
|
|
5
|
-
.BHT__Sidebar {
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
position: sticky;
|
|
9
|
-
top: 0;
|
|
10
|
-
// 100vh is the tallest the viewport gets on iOS Safari (toolbars retracted), so it
|
|
11
|
-
// runs past the visible area; dvh follows the toolbars where it is supported.
|
|
12
|
-
height: 100vh;
|
|
13
|
-
height: 100dvh;
|
|
14
|
-
overflow-y: auto;
|
|
15
|
-
background: var(--md-sys-color-surface-container-low, var(--color-surface));
|
|
16
|
-
color: var(--md-sys-color-on-surface-variant, var(--color-text-muted));
|
|
17
|
-
}
|