@behivetech/organisms.site-header 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 +7 -1
- package/dist/index.cjs +75 -32
- package/dist/index.css +53 -45
- package/dist/index.d.ts +78 -2
- package/dist/index.js +75 -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 +33 -14
- 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
|
@@ -37,22 +37,61 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
|
|
38
38
|
// site-header.tsx
|
|
39
39
|
var import_react = require("react");
|
|
40
|
-
var import_get_class_name = require("@behivetech/get-class-name");
|
|
41
40
|
var import_atoms = require("@behivetech/atoms.button");
|
|
42
41
|
var import_icons = require("@behivetech/icons.menu");
|
|
43
42
|
var import_atoms2 = require("@behivetech/atoms.nav-item");
|
|
43
|
+
var import_blocks2 = require("@behivetech/blocks.core");
|
|
44
44
|
|
|
45
|
-
// site-header.
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
});
|
|
56
95
|
|
|
57
96
|
// site-header.tsx
|
|
58
97
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -81,7 +120,7 @@ var MenuDrawer = ({
|
|
|
81
120
|
links,
|
|
82
121
|
linkComponent,
|
|
83
122
|
menuLabel,
|
|
84
|
-
|
|
123
|
+
navProps,
|
|
85
124
|
onClose
|
|
86
125
|
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
126
|
Drawer,
|
|
@@ -91,7 +130,7 @@ var MenuDrawer = ({
|
|
|
91
130
|
headingLevel: 2,
|
|
92
131
|
padding: "sm",
|
|
93
132
|
onClose,
|
|
94
|
-
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)(
|
|
95
134
|
HeaderLinks,
|
|
96
135
|
{
|
|
97
136
|
links,
|
|
@@ -110,15 +149,17 @@ var useReturnFocus = (isOpen) => {
|
|
|
110
149
|
}, [isOpen]);
|
|
111
150
|
return menuButtonRef;
|
|
112
151
|
};
|
|
113
|
-
var HeaderMenu = ({
|
|
152
|
+
var HeaderMenu = ({
|
|
153
|
+
links,
|
|
154
|
+
linkComponent,
|
|
155
|
+
menuLabel,
|
|
156
|
+
styles
|
|
157
|
+
}) => {
|
|
114
158
|
const [isMenuOpen, setIsMenuOpen] = (0, import_react.useState)(false);
|
|
115
|
-
const [,
|
|
116
|
-
rootClass: "BHT__SiteHeader",
|
|
117
|
-
styles: site_header_module_default
|
|
118
|
-
});
|
|
159
|
+
const [, childProps] = (0, import_blocks2.useBlock)(siteHeader, {}, { styles });
|
|
119
160
|
const menuButtonRef = useReturnFocus(isMenuOpen);
|
|
120
161
|
const closeMenu = () => setIsMenuOpen(false);
|
|
121
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...childProps("menu"), children: [
|
|
122
163
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
123
164
|
import_atoms.Button,
|
|
124
165
|
{
|
|
@@ -146,7 +187,7 @@ var HeaderMenu = ({ links, linkComponent, menuLabel }) => {
|
|
|
146
187
|
links,
|
|
147
188
|
linkComponent,
|
|
148
189
|
menuLabel,
|
|
149
|
-
|
|
190
|
+
navProps: childProps("drawerNav"),
|
|
150
191
|
onClose: closeMenu
|
|
151
192
|
}
|
|
152
193
|
) : null
|
|
@@ -159,24 +200,26 @@ var SiteHeader = ({
|
|
|
159
200
|
actions,
|
|
160
201
|
linkComponent = "a",
|
|
161
202
|
menuLabel,
|
|
203
|
+
styles,
|
|
162
204
|
...rest
|
|
163
205
|
}) => {
|
|
164
|
-
const [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
styles
|
|
168
|
-
|
|
169
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", { ...rest,
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
171
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
172
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": menuLabel,
|
|
173
|
-
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,
|
|
174
216
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
217
|
HeaderMenu,
|
|
176
218
|
{
|
|
177
219
|
links,
|
|
178
220
|
linkComponent,
|
|
179
|
-
menuLabel
|
|
221
|
+
menuLabel,
|
|
222
|
+
styles
|
|
180
223
|
}
|
|
181
224
|
)
|
|
182
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
|
@@ -8,22 +8,61 @@ import {
|
|
|
8
8
|
useRef,
|
|
9
9
|
useState
|
|
10
10
|
} from "react";
|
|
11
|
-
import { getClassName } from "@behivetech/get-class-name";
|
|
12
11
|
import { Button } from "@behivetech/atoms.button";
|
|
13
12
|
import { MenuIcon } from "@behivetech/icons.menu";
|
|
14
13
|
import { NavItem } from "@behivetech/atoms.nav-item";
|
|
14
|
+
import { useBlock } from "@behivetech/blocks.core";
|
|
15
15
|
|
|
16
|
-
// site-header.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
});
|
|
27
66
|
|
|
28
67
|
// site-header.tsx
|
|
29
68
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -52,7 +91,7 @@ var MenuDrawer = ({
|
|
|
52
91
|
links,
|
|
53
92
|
linkComponent,
|
|
54
93
|
menuLabel,
|
|
55
|
-
|
|
94
|
+
navProps,
|
|
56
95
|
onClose
|
|
57
96
|
}) => /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
58
97
|
Drawer,
|
|
@@ -62,7 +101,7 @@ var MenuDrawer = ({
|
|
|
62
101
|
headingLevel: 2,
|
|
63
102
|
padding: "sm",
|
|
64
103
|
onClose,
|
|
65
|
-
children: /* @__PURE__ */ jsx("nav", { "aria-label": menuLabel,
|
|
104
|
+
children: /* @__PURE__ */ jsx("nav", { "aria-label": menuLabel, ...navProps, children: /* @__PURE__ */ jsx(
|
|
66
105
|
HeaderLinks,
|
|
67
106
|
{
|
|
68
107
|
links,
|
|
@@ -81,15 +120,17 @@ var useReturnFocus = (isOpen) => {
|
|
|
81
120
|
}, [isOpen]);
|
|
82
121
|
return menuButtonRef;
|
|
83
122
|
};
|
|
84
|
-
var HeaderMenu = ({
|
|
123
|
+
var HeaderMenu = ({
|
|
124
|
+
links,
|
|
125
|
+
linkComponent,
|
|
126
|
+
menuLabel,
|
|
127
|
+
styles
|
|
128
|
+
}) => {
|
|
85
129
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
86
|
-
const [,
|
|
87
|
-
rootClass: "BHT__SiteHeader",
|
|
88
|
-
styles: site_header_module_default
|
|
89
|
-
});
|
|
130
|
+
const [, childProps] = useBlock(siteHeader, {}, { styles });
|
|
90
131
|
const menuButtonRef = useReturnFocus(isMenuOpen);
|
|
91
132
|
const closeMenu = () => setIsMenuOpen(false);
|
|
92
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", { ...childProps("menu"), children: [
|
|
93
134
|
/* @__PURE__ */ jsx(
|
|
94
135
|
Button,
|
|
95
136
|
{
|
|
@@ -117,7 +158,7 @@ var HeaderMenu = ({ links, linkComponent, menuLabel }) => {
|
|
|
117
158
|
links,
|
|
118
159
|
linkComponent,
|
|
119
160
|
menuLabel,
|
|
120
|
-
|
|
161
|
+
navProps: childProps("drawerNav"),
|
|
121
162
|
onClose: closeMenu
|
|
122
163
|
}
|
|
123
164
|
) : null
|
|
@@ -130,24 +171,26 @@ var SiteHeader = ({
|
|
|
130
171
|
actions,
|
|
131
172
|
linkComponent = "a",
|
|
132
173
|
menuLabel,
|
|
174
|
+
styles,
|
|
133
175
|
...rest
|
|
134
176
|
}) => {
|
|
135
|
-
const [
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
styles
|
|
139
|
-
|
|
140
|
-
return /* @__PURE__ */ jsx("header", { ...rest,
|
|
141
|
-
/* @__PURE__ */ jsx("div", {
|
|
142
|
-
/* @__PURE__ */ jsxs("div", {
|
|
143
|
-
/* @__PURE__ */ jsx("nav", { "aria-label": menuLabel,
|
|
144
|
-
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,
|
|
145
187
|
/* @__PURE__ */ jsx(
|
|
146
188
|
HeaderMenu,
|
|
147
189
|
{
|
|
148
190
|
links,
|
|
149
191
|
linkComponent,
|
|
150
|
-
menuLabel
|
|
192
|
+
menuLabel,
|
|
193
|
+
styles
|
|
151
194
|
}
|
|
152
195
|
)
|
|
153
196
|
] })
|