@behivetech/organisms.site-header 0.1.6 → 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 +7 -1
- package/dist/index.cjs +76 -32
- package/dist/index.css +53 -45
- package/dist/index.d.ts +78 -2
- package/dist/index.js +77 -32
- package/dist/index.native.js +204 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/site-header-types.d.ts +14 -0
- package/dist/native/site-header.block.d.ts +70 -0
- package/dist/native/site-header.block.native.d.ts +2 -0
- package/dist/native/site-header.native.d.ts +33 -0
- package/docs.json +8 -1
- package/index.ts +2 -2
- package/package.json +34 -15
- package/site-header-types.ts +16 -0
- package/site-header.block.css +76 -0
- package/site-header.block.native.ts +100 -0
- package/site-header.block.ts +50 -0
- package/site-header.example.tsx +2 -2
- package/site-header.native.tsx +154 -0
- package/site-header.tsx +38 -41
- package/site-header.module.scss +0 -77
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
|
@@ -8,7 +8,7 @@ Docs: https://platform.behivetech.com/behivetech/organisms/site-header
|
|
|
8
8
|
|
|
9
9
|
```jsx
|
|
10
10
|
<SiteHeader
|
|
11
|
-
brand={<a href="/">
|
|
11
|
+
brand={<a href="/">Northwind</a>}
|
|
12
12
|
links={[
|
|
13
13
|
{ href: "/guide", label: "Guide", current: true },
|
|
14
14
|
{ href: "/gallery", label: "Gallery" },
|
|
@@ -22,3 +22,9 @@ Pass `linkComponent` (for example Next's `Link`) to render the links through you
|
|
|
22
22
|
The Drawer's Close button keeps its fixed English "Close" label.
|
|
23
23
|
|
|
24
24
|
The root is an inline-size container, so it needs a definite width: as a flex item without a width, or under `align-items: center`, give it `width: 100%` or it collapses.
|
|
25
|
+
|
|
26
|
+
## On React Native
|
|
27
|
+
|
|
28
|
+
The native `SiteHeader` has the same `brand`, `links`, `actions` and `menuLabel` props. While the window is at least 1024 dp wide the links sit in the bar; narrower, a menu button opens them in a right-hand `Drawer`. The web switches on the header's own width (a container query), which native has no counterpart of, so this follows the window width.
|
|
29
|
+
|
|
30
|
+
There is no `linkComponent`: a link is a `NavItem` with no `href`, and pressing it calls `onLinkPress(link)` (after closing the `Drawer`), where the app navigates. The link marked `current` is announced as selected. A string `brand` or `actions` is drawn in a `Text`. The header is a `banner` landmark; under a transparent status bar, pass the top inset as padding in `style`.
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -36,22 +37,61 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
37
|
|
|
37
38
|
// site-header.tsx
|
|
38
39
|
var import_react = require("react");
|
|
39
|
-
var import_get_class_name = require("@behivetech/get-class-name");
|
|
40
40
|
var import_atoms = require("@behivetech/atoms.button");
|
|
41
41
|
var import_icons = require("@behivetech/icons.menu");
|
|
42
42
|
var import_atoms2 = require("@behivetech/atoms.nav-item");
|
|
43
|
+
var import_blocks2 = require("@behivetech/blocks.core");
|
|
43
44
|
|
|
44
|
-
// site-header.
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
// site-header.block.ts
|
|
46
|
+
var import_blocks = require("@behivetech/blocks.core");
|
|
47
|
+
var import_tokens = require("@behivetech/blocks.core/tokens");
|
|
48
|
+
var { color, spacing } = import_tokens.tokens;
|
|
49
|
+
var siteHeader = (0, import_blocks.defineBlock)("BHT__SiteHeader", {
|
|
50
|
+
backgroundColor: color.surface,
|
|
51
|
+
color: color.onSurface,
|
|
52
|
+
borderBottom: [1, "solid", color.outlineVariant],
|
|
53
|
+
children: {
|
|
54
|
+
bar: {
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "space-between",
|
|
58
|
+
gap: spacing[4],
|
|
59
|
+
minHeight: "4rem",
|
|
60
|
+
padding: [spacing[2], spacing[4]],
|
|
61
|
+
web: {
|
|
62
|
+
"@container site-header lg": {
|
|
63
|
+
paddingInline: spacing[8]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
brand: { display: "flex", alignItems: "center", minWidth: 0 },
|
|
68
|
+
end: {
|
|
69
|
+
display: "flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
gap: spacing[2],
|
|
72
|
+
web: { "@container site-header lg": { gap: spacing[6] } }
|
|
73
|
+
},
|
|
74
|
+
nav: {
|
|
75
|
+
display: "none",
|
|
76
|
+
// the native renderer draws the links inline only while the window is wide, so it shows them
|
|
77
|
+
native: { display: "flex", alignItems: "center", gap: spacing[1] },
|
|
78
|
+
web: {
|
|
79
|
+
"@container site-header lg": {
|
|
80
|
+
display: "flex",
|
|
81
|
+
alignItems: "center",
|
|
82
|
+
gap: spacing[1]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
actions: { display: "flex", alignItems: "center" },
|
|
87
|
+
menu: {
|
|
88
|
+
display: "flex",
|
|
89
|
+
web: { "@container site-header lg": { display: "none" } }
|
|
90
|
+
},
|
|
91
|
+
drawerNav: { display: "flex", flexDirection: "column", gap: spacing[2] }
|
|
92
|
+
},
|
|
93
|
+
web: { container: "site-header/inline-size" }
|
|
94
|
+
});
|
|
55
95
|
|
|
56
96
|
// site-header.tsx
|
|
57
97
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -80,7 +120,7 @@ var MenuDrawer = ({
|
|
|
80
120
|
links,
|
|
81
121
|
linkComponent,
|
|
82
122
|
menuLabel,
|
|
83
|
-
|
|
123
|
+
navProps,
|
|
84
124
|
onClose
|
|
85
125
|
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
126
|
Drawer,
|
|
@@ -90,7 +130,7 @@ var MenuDrawer = ({
|
|
|
90
130
|
headingLevel: 2,
|
|
91
131
|
padding: "sm",
|
|
92
132
|
onClose,
|
|
93
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": menuLabel,
|
|
133
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": menuLabel, ...navProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
134
|
HeaderLinks,
|
|
95
135
|
{
|
|
96
136
|
links,
|
|
@@ -109,15 +149,17 @@ var useReturnFocus = (isOpen) => {
|
|
|
109
149
|
}, [isOpen]);
|
|
110
150
|
return menuButtonRef;
|
|
111
151
|
};
|
|
112
|
-
var HeaderMenu = ({
|
|
152
|
+
var HeaderMenu = ({
|
|
153
|
+
links,
|
|
154
|
+
linkComponent,
|
|
155
|
+
menuLabel,
|
|
156
|
+
styles
|
|
157
|
+
}) => {
|
|
113
158
|
const [isMenuOpen, setIsMenuOpen] = (0, import_react.useState)(false);
|
|
114
|
-
const [,
|
|
115
|
-
rootClass: "BHT__SiteHeader",
|
|
116
|
-
styles: site_header_module_default
|
|
117
|
-
});
|
|
159
|
+
const [, childProps] = (0, import_blocks2.useBlock)(siteHeader, {}, { styles });
|
|
118
160
|
const menuButtonRef = useReturnFocus(isMenuOpen);
|
|
119
161
|
const closeMenu = () => setIsMenuOpen(false);
|
|
120
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...childProps("menu"), children: [
|
|
121
163
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
164
|
import_atoms.Button,
|
|
123
165
|
{
|
|
@@ -145,7 +187,7 @@ var HeaderMenu = ({ links, linkComponent, menuLabel }) => {
|
|
|
145
187
|
links,
|
|
146
188
|
linkComponent,
|
|
147
189
|
menuLabel,
|
|
148
|
-
|
|
190
|
+
navProps: childProps("drawerNav"),
|
|
149
191
|
onClose: closeMenu
|
|
150
192
|
}
|
|
151
193
|
) : null
|
|
@@ -158,24 +200,26 @@ var SiteHeader = ({
|
|
|
158
200
|
actions,
|
|
159
201
|
linkComponent = "a",
|
|
160
202
|
menuLabel,
|
|
203
|
+
styles,
|
|
161
204
|
...rest
|
|
162
205
|
}) => {
|
|
163
|
-
const [
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
styles
|
|
167
|
-
|
|
168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", { ...rest,
|
|
169
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
171
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": menuLabel,
|
|
172
|
-
actions ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
206
|
+
const [rootProps, childProps] = (0, import_blocks2.useBlock)(
|
|
207
|
+
siteHeader,
|
|
208
|
+
{},
|
|
209
|
+
{ className, styles }
|
|
210
|
+
);
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", { ...rest, ...rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...childProps("bar"), children: [
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...childProps("brand"), children: brand }),
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...childProps("end"), children: [
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": menuLabel, ...childProps("nav"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HeaderLinks, { links, linkComponent }) }),
|
|
215
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...childProps("actions"), children: actions }) : null,
|
|
173
216
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
174
217
|
HeaderMenu,
|
|
175
218
|
{
|
|
176
219
|
links,
|
|
177
220
|
linkComponent,
|
|
178
|
-
menuLabel
|
|
221
|
+
menuLabel,
|
|
222
|
+
styles
|
|
179
223
|
}
|
|
180
224
|
)
|
|
181
225
|
] })
|
package/dist/index.css
CHANGED
|
@@ -1,56 +1,64 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: space-between;
|
|
12
|
-
gap: var(--spacing-4, 1rem);
|
|
13
|
-
min-height: 4rem;
|
|
14
|
-
padding: var(--spacing-2, 0.5rem) var(--spacing-4, 1rem);
|
|
15
|
-
}
|
|
16
|
-
.BHT__SiteHeader__brand {
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
min-width: 0;
|
|
20
|
-
}
|
|
21
|
-
.BHT__SiteHeader__end {
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
gap: var(--spacing-2, 0.5rem);
|
|
25
|
-
}
|
|
26
|
-
.BHT__SiteHeader__nav {
|
|
27
|
-
display: none;
|
|
28
|
-
}
|
|
29
|
-
.BHT__SiteHeader__actions {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
}
|
|
33
|
-
.BHT__SiteHeader__menu {
|
|
34
|
-
display: flex;
|
|
35
|
-
}
|
|
36
|
-
.BHT__SiteHeader__drawer-nav {
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
gap: var(--spacing-2, 0.5rem);
|
|
40
|
-
}
|
|
41
|
-
@container site-header (min-width: 64rem) {
|
|
1
|
+
/* site-header.block.css */
|
|
2
|
+
@layer bht {
|
|
3
|
+
.BHT__SiteHeader {
|
|
4
|
+
background-color: var(--md-sys-color-surface, #f9f9f9);
|
|
5
|
+
color: var(--md-sys-color-on-surface, #1b1b1b);
|
|
6
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant, #c6c6c6);
|
|
7
|
+
container: site-header/inline-size;
|
|
8
|
+
}
|
|
42
9
|
.BHT__SiteHeader__bar {
|
|
43
|
-
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
gap: var(--spacing-4, 1rem);
|
|
14
|
+
min-height: 4rem;
|
|
15
|
+
padding: var(--spacing-2, 0.5rem) var(--spacing-4, 1rem);
|
|
16
|
+
}
|
|
17
|
+
@container site-header (min-width: 64rem) {
|
|
18
|
+
.BHT__SiteHeader__bar {
|
|
19
|
+
padding-inline: var(--spacing-8, 2rem);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
.BHT__SiteHeader__brand {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
min-width: 0;
|
|
44
26
|
}
|
|
45
27
|
.BHT__SiteHeader__end {
|
|
46
|
-
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--spacing-2, 0.5rem);
|
|
31
|
+
}
|
|
32
|
+
@container site-header (min-width: 64rem) {
|
|
33
|
+
.BHT__SiteHeader__end {
|
|
34
|
+
gap: var(--spacing-6, 1.5rem);
|
|
35
|
+
}
|
|
47
36
|
}
|
|
48
37
|
.BHT__SiteHeader__nav {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
@container site-header (min-width: 64rem) {
|
|
41
|
+
.BHT__SiteHeader__nav {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: var(--spacing-1, 0.25rem);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
.BHT__SiteHeader__actions {
|
|
49
48
|
display: flex;
|
|
50
49
|
align-items: center;
|
|
51
|
-
gap: var(--spacing-1, 0.25rem);
|
|
52
50
|
}
|
|
53
51
|
.BHT__SiteHeader__menu {
|
|
54
|
-
display:
|
|
52
|
+
display: flex;
|
|
53
|
+
}
|
|
54
|
+
@container site-header (min-width: 64rem) {
|
|
55
|
+
.BHT__SiteHeader__menu {
|
|
56
|
+
display: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
.BHT__SiteHeader__drawer-nav {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
gap: var(--spacing-2, 0.5rem);
|
|
55
63
|
}
|
|
56
64
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { HTMLAttributes, ReactNode, ElementType
|
|
2
|
+
import { AnchorHTMLAttributes, HTMLAttributes, ReactNode, ElementType } from 'react';
|
|
3
|
+
import * as _behivetech_blocks_core from '@behivetech/blocks.core';
|
|
4
|
+
import { StylesFor } from '@behivetech/blocks.core';
|
|
5
|
+
|
|
6
|
+
declare const siteHeader: _behivetech_blocks_core.Block<"BHT__SiteHeader", {
|
|
7
|
+
readonly backgroundColor: _behivetech_blocks_core.Token<"color">;
|
|
8
|
+
readonly color: _behivetech_blocks_core.Token<"color">;
|
|
9
|
+
readonly borderBottom: readonly [1, "solid", _behivetech_blocks_core.Token<"color">];
|
|
10
|
+
readonly children: {
|
|
11
|
+
readonly bar: {
|
|
12
|
+
readonly display: "flex";
|
|
13
|
+
readonly alignItems: "center";
|
|
14
|
+
readonly justifyContent: "space-between";
|
|
15
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
16
|
+
readonly minHeight: "4rem";
|
|
17
|
+
readonly padding: readonly [_behivetech_blocks_core.Token<"length">, _behivetech_blocks_core.Token<"length">];
|
|
18
|
+
readonly web: {
|
|
19
|
+
readonly "@container site-header lg": {
|
|
20
|
+
readonly paddingInline: _behivetech_blocks_core.Token<"length">;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly brand: {
|
|
25
|
+
readonly display: "flex";
|
|
26
|
+
readonly alignItems: "center";
|
|
27
|
+
readonly minWidth: 0;
|
|
28
|
+
};
|
|
29
|
+
readonly end: {
|
|
30
|
+
readonly display: "flex";
|
|
31
|
+
readonly alignItems: "center";
|
|
32
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
33
|
+
readonly web: {
|
|
34
|
+
readonly "@container site-header lg": {
|
|
35
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly nav: {
|
|
40
|
+
readonly display: "none";
|
|
41
|
+
readonly native: {
|
|
42
|
+
readonly display: "flex";
|
|
43
|
+
readonly alignItems: "center";
|
|
44
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
45
|
+
};
|
|
46
|
+
readonly web: {
|
|
47
|
+
readonly "@container site-header lg": {
|
|
48
|
+
readonly display: "flex";
|
|
49
|
+
readonly alignItems: "center";
|
|
50
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
readonly actions: {
|
|
55
|
+
readonly display: "flex";
|
|
56
|
+
readonly alignItems: "center";
|
|
57
|
+
};
|
|
58
|
+
readonly menu: {
|
|
59
|
+
readonly display: "flex";
|
|
60
|
+
readonly web: {
|
|
61
|
+
readonly "@container site-header lg": {
|
|
62
|
+
readonly display: "none";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly drawerNav: {
|
|
67
|
+
readonly display: "flex";
|
|
68
|
+
readonly flexDirection: "column";
|
|
69
|
+
readonly gap: _behivetech_blocks_core.Token<"length">;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly web: {
|
|
73
|
+
readonly container: "site-header/inline-size";
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
3
76
|
|
|
4
77
|
/** One navigation link of the header. */
|
|
5
78
|
interface SiteHeaderLink {
|
|
@@ -14,6 +87,7 @@ interface SiteHeaderLink {
|
|
|
14
87
|
type SiteHeaderLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
15
88
|
href: string;
|
|
16
89
|
};
|
|
90
|
+
|
|
17
91
|
/** Props of the `SiteHeader` component. */
|
|
18
92
|
interface SiteHeaderProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
19
93
|
/** Additional class names to merge with the component root element */
|
|
@@ -31,6 +105,8 @@ interface SiteHeaderProps extends Omit<HTMLAttributes<HTMLElement>, "children">
|
|
|
31
105
|
linkComponent?: ElementType<SiteHeaderLinkProps>;
|
|
32
106
|
/** Accessible name of the menu button, the navigation landmarks and the Drawer title, already translated */
|
|
33
107
|
menuLabel: string;
|
|
108
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
109
|
+
styles?: StylesFor<typeof siteHeader>;
|
|
34
110
|
}
|
|
35
111
|
/**
|
|
36
112
|
* Site header with a brand slot, navigation links and optional actions. While
|
|
@@ -39,6 +115,6 @@ interface SiteHeaderProps extends Omit<HTMLAttributes<HTMLElement>, "children">
|
|
|
39
115
|
* one thumb on a phone. The switch follows the header's own width (a container
|
|
40
116
|
* query), not the viewport.
|
|
41
117
|
*/
|
|
42
|
-
declare const SiteHeader: ({ className, brand, links, actions, linkComponent, menuLabel, ...rest }: SiteHeaderProps) => react.JSX.Element;
|
|
118
|
+
declare const SiteHeader: ({ className, brand, links, actions, linkComponent, menuLabel, styles, ...rest }: SiteHeaderProps) => react.JSX.Element;
|
|
43
119
|
|
|
44
120
|
export { SiteHeader, type SiteHeaderLink, type SiteHeaderLinkProps, type SiteHeaderProps };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
// site-header.tsx
|
|
2
4
|
import {
|
|
3
5
|
Suspense,
|
|
@@ -6,22 +8,61 @@ import {
|
|
|
6
8
|
useRef,
|
|
7
9
|
useState
|
|
8
10
|
} from "react";
|
|
9
|
-
import { getClassName } from "@behivetech/get-class-name";
|
|
10
11
|
import { Button } from "@behivetech/atoms.button";
|
|
11
12
|
import { MenuIcon } from "@behivetech/icons.menu";
|
|
12
13
|
import { NavItem } from "@behivetech/atoms.nav-item";
|
|
14
|
+
import { useBlock } from "@behivetech/blocks.core";
|
|
13
15
|
|
|
14
|
-
// site-header.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
// site-header.block.ts
|
|
17
|
+
import { defineBlock } from "@behivetech/blocks.core";
|
|
18
|
+
import { tokens } from "@behivetech/blocks.core/tokens";
|
|
19
|
+
var { color, spacing } = tokens;
|
|
20
|
+
var siteHeader = defineBlock("BHT__SiteHeader", {
|
|
21
|
+
backgroundColor: color.surface,
|
|
22
|
+
color: color.onSurface,
|
|
23
|
+
borderBottom: [1, "solid", color.outlineVariant],
|
|
24
|
+
children: {
|
|
25
|
+
bar: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
justifyContent: "space-between",
|
|
29
|
+
gap: spacing[4],
|
|
30
|
+
minHeight: "4rem",
|
|
31
|
+
padding: [spacing[2], spacing[4]],
|
|
32
|
+
web: {
|
|
33
|
+
"@container site-header lg": {
|
|
34
|
+
paddingInline: spacing[8]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
brand: { display: "flex", alignItems: "center", minWidth: 0 },
|
|
39
|
+
end: {
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
gap: spacing[2],
|
|
43
|
+
web: { "@container site-header lg": { gap: spacing[6] } }
|
|
44
|
+
},
|
|
45
|
+
nav: {
|
|
46
|
+
display: "none",
|
|
47
|
+
// the native renderer draws the links inline only while the window is wide, so it shows them
|
|
48
|
+
native: { display: "flex", alignItems: "center", gap: spacing[1] },
|
|
49
|
+
web: {
|
|
50
|
+
"@container site-header lg": {
|
|
51
|
+
display: "flex",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
gap: spacing[1]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
actions: { display: "flex", alignItems: "center" },
|
|
58
|
+
menu: {
|
|
59
|
+
display: "flex",
|
|
60
|
+
web: { "@container site-header lg": { display: "none" } }
|
|
61
|
+
},
|
|
62
|
+
drawerNav: { display: "flex", flexDirection: "column", gap: spacing[2] }
|
|
63
|
+
},
|
|
64
|
+
web: { container: "site-header/inline-size" }
|
|
65
|
+
});
|
|
25
66
|
|
|
26
67
|
// site-header.tsx
|
|
27
68
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -50,7 +91,7 @@ var MenuDrawer = ({
|
|
|
50
91
|
links,
|
|
51
92
|
linkComponent,
|
|
52
93
|
menuLabel,
|
|
53
|
-
|
|
94
|
+
navProps,
|
|
54
95
|
onClose
|
|
55
96
|
}) => /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
56
97
|
Drawer,
|
|
@@ -60,7 +101,7 @@ var MenuDrawer = ({
|
|
|
60
101
|
headingLevel: 2,
|
|
61
102
|
padding: "sm",
|
|
62
103
|
onClose,
|
|
63
|
-
children: /* @__PURE__ */ jsx("nav", { "aria-label": menuLabel,
|
|
104
|
+
children: /* @__PURE__ */ jsx("nav", { "aria-label": menuLabel, ...navProps, children: /* @__PURE__ */ jsx(
|
|
64
105
|
HeaderLinks,
|
|
65
106
|
{
|
|
66
107
|
links,
|
|
@@ -79,15 +120,17 @@ var useReturnFocus = (isOpen) => {
|
|
|
79
120
|
}, [isOpen]);
|
|
80
121
|
return menuButtonRef;
|
|
81
122
|
};
|
|
82
|
-
var HeaderMenu = ({
|
|
123
|
+
var HeaderMenu = ({
|
|
124
|
+
links,
|
|
125
|
+
linkComponent,
|
|
126
|
+
menuLabel,
|
|
127
|
+
styles
|
|
128
|
+
}) => {
|
|
83
129
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
84
|
-
const [,
|
|
85
|
-
rootClass: "BHT__SiteHeader",
|
|
86
|
-
styles: site_header_module_default
|
|
87
|
-
});
|
|
130
|
+
const [, childProps] = useBlock(siteHeader, {}, { styles });
|
|
88
131
|
const menuButtonRef = useReturnFocus(isMenuOpen);
|
|
89
132
|
const closeMenu = () => setIsMenuOpen(false);
|
|
90
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", { ...childProps("menu"), children: [
|
|
91
134
|
/* @__PURE__ */ jsx(
|
|
92
135
|
Button,
|
|
93
136
|
{
|
|
@@ -115,7 +158,7 @@ var HeaderMenu = ({ links, linkComponent, menuLabel }) => {
|
|
|
115
158
|
links,
|
|
116
159
|
linkComponent,
|
|
117
160
|
menuLabel,
|
|
118
|
-
|
|
161
|
+
navProps: childProps("drawerNav"),
|
|
119
162
|
onClose: closeMenu
|
|
120
163
|
}
|
|
121
164
|
) : null
|
|
@@ -128,24 +171,26 @@ var SiteHeader = ({
|
|
|
128
171
|
actions,
|
|
129
172
|
linkComponent = "a",
|
|
130
173
|
menuLabel,
|
|
174
|
+
styles,
|
|
131
175
|
...rest
|
|
132
176
|
}) => {
|
|
133
|
-
const [
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
styles
|
|
137
|
-
|
|
138
|
-
return /* @__PURE__ */ jsx("header", { ...rest,
|
|
139
|
-
/* @__PURE__ */ jsx("div", {
|
|
140
|
-
/* @__PURE__ */ jsxs("div", {
|
|
141
|
-
/* @__PURE__ */ jsx("nav", { "aria-label": menuLabel,
|
|
142
|
-
actions ? /* @__PURE__ */ jsx("div", {
|
|
177
|
+
const [rootProps, childProps] = useBlock(
|
|
178
|
+
siteHeader,
|
|
179
|
+
{},
|
|
180
|
+
{ className, styles }
|
|
181
|
+
);
|
|
182
|
+
return /* @__PURE__ */ jsx("header", { ...rest, ...rootProps, children: /* @__PURE__ */ jsxs("div", { ...childProps("bar"), children: [
|
|
183
|
+
/* @__PURE__ */ jsx("div", { ...childProps("brand"), children: brand }),
|
|
184
|
+
/* @__PURE__ */ jsxs("div", { ...childProps("end"), children: [
|
|
185
|
+
/* @__PURE__ */ jsx("nav", { "aria-label": menuLabel, ...childProps("nav"), children: /* @__PURE__ */ jsx(HeaderLinks, { links, linkComponent }) }),
|
|
186
|
+
actions ? /* @__PURE__ */ jsx("div", { ...childProps("actions"), children: actions }) : null,
|
|
143
187
|
/* @__PURE__ */ jsx(
|
|
144
188
|
HeaderMenu,
|
|
145
189
|
{
|
|
146
190
|
links,
|
|
147
191
|
linkComponent,
|
|
148
|
-
menuLabel
|
|
192
|
+
menuLabel,
|
|
193
|
+
styles
|
|
149
194
|
}
|
|
150
195
|
)
|
|
151
196
|
] })
|