@equinor/cpl-top-bar-react 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +147 -100
- package/dist/index.mjs +144 -99
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,12 @@ interface FeedbackLinkProps {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function FeedbackLink({ link, subject, body }: FeedbackLinkProps): react_jsx_runtime.JSX.Element;
|
|
18
18
|
|
|
19
|
+
type MenuHeaderProps = {
|
|
20
|
+
appName: string;
|
|
21
|
+
icon: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
declare function MenuHeader({ appName, icon }: MenuHeaderProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
19
25
|
type AppUrls = {
|
|
20
26
|
[appName: string]: {
|
|
21
27
|
dev: string;
|
|
@@ -23,7 +29,6 @@ type AppUrls = {
|
|
|
23
29
|
prod: string;
|
|
24
30
|
};
|
|
25
31
|
};
|
|
26
|
-
|
|
27
32
|
type MenuItems = MenuItem | MenuItemGroup;
|
|
28
33
|
type MenuItem = {
|
|
29
34
|
name: string;
|
|
@@ -47,8 +52,21 @@ type SideMenuProps = {
|
|
|
47
52
|
otherMenuItems?: MenuItems[];
|
|
48
53
|
logoElement?: JSX.Element;
|
|
49
54
|
versionInfo?: React__default.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* supports next/link and react-router-dom, will default to using a regular anchor-element if not provided
|
|
57
|
+
*/
|
|
58
|
+
linkComponent?: React__default.ElementType;
|
|
50
59
|
};
|
|
51
|
-
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, linkComponent, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets the url by app name and current environment
|
|
64
|
+
* @param appName
|
|
65
|
+
* @param currentEnvironment needs to match a key in the appUrls
|
|
66
|
+
* @param appUrls
|
|
67
|
+
* @returns a string url
|
|
68
|
+
*/
|
|
69
|
+
declare function useAppUrlByNameAndEnvironment(appName: string | undefined, currentEnvironment: string, appUrls: AppUrls): string;
|
|
52
70
|
|
|
53
71
|
interface TopBarProps {
|
|
54
72
|
appName: string;
|
|
@@ -82,4 +100,4 @@ interface UserMenuProps {
|
|
|
82
100
|
}
|
|
83
101
|
declare function UserMenu({ user, logout, settingsLink, children }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
84
102
|
|
|
85
|
-
export { FeedbackLink, SideMenu, StyledLink, TopBar, UserMenu };
|
|
103
|
+
export { type AppUrls, FeedbackLink, MenuHeader, type MenuItem, type MenuItemGroup, type MenuItems, SideMenu, StyledLink, TopBar, UserMenu, useAppUrlByNameAndEnvironment };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ interface FeedbackLinkProps {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function FeedbackLink({ link, subject, body }: FeedbackLinkProps): react_jsx_runtime.JSX.Element;
|
|
18
18
|
|
|
19
|
+
type MenuHeaderProps = {
|
|
20
|
+
appName: string;
|
|
21
|
+
icon: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
declare function MenuHeader({ appName, icon }: MenuHeaderProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
19
25
|
type AppUrls = {
|
|
20
26
|
[appName: string]: {
|
|
21
27
|
dev: string;
|
|
@@ -23,7 +29,6 @@ type AppUrls = {
|
|
|
23
29
|
prod: string;
|
|
24
30
|
};
|
|
25
31
|
};
|
|
26
|
-
|
|
27
32
|
type MenuItems = MenuItem | MenuItemGroup;
|
|
28
33
|
type MenuItem = {
|
|
29
34
|
name: string;
|
|
@@ -47,8 +52,21 @@ type SideMenuProps = {
|
|
|
47
52
|
otherMenuItems?: MenuItems[];
|
|
48
53
|
logoElement?: JSX.Element;
|
|
49
54
|
versionInfo?: React__default.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* supports next/link and react-router-dom, will default to using a regular anchor-element if not provided
|
|
57
|
+
*/
|
|
58
|
+
linkComponent?: React__default.ElementType;
|
|
50
59
|
};
|
|
51
|
-
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, linkComponent, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets the url by app name and current environment
|
|
64
|
+
* @param appName
|
|
65
|
+
* @param currentEnvironment needs to match a key in the appUrls
|
|
66
|
+
* @param appUrls
|
|
67
|
+
* @returns a string url
|
|
68
|
+
*/
|
|
69
|
+
declare function useAppUrlByNameAndEnvironment(appName: string | undefined, currentEnvironment: string, appUrls: AppUrls): string;
|
|
52
70
|
|
|
53
71
|
interface TopBarProps {
|
|
54
72
|
appName: string;
|
|
@@ -82,4 +100,4 @@ interface UserMenuProps {
|
|
|
82
100
|
}
|
|
83
101
|
declare function UserMenu({ user, logout, settingsLink, children }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
84
102
|
|
|
85
|
-
export { FeedbackLink, SideMenu, StyledLink, TopBar, UserMenu };
|
|
103
|
+
export { type AppUrls, FeedbackLink, MenuHeader, type MenuItem, type MenuItemGroup, type MenuItems, SideMenu, StyledLink, TopBar, UserMenu, useAppUrlByNameAndEnvironment };
|
package/dist/index.js
CHANGED
|
@@ -31,10 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
FeedbackLink: () => FeedbackLink,
|
|
34
|
+
MenuHeader: () => MenuHeader,
|
|
34
35
|
SideMenu: () => SideMenu,
|
|
35
36
|
StyledLink: () => StyledLink,
|
|
36
37
|
TopBar: () => TopBar,
|
|
37
|
-
UserMenu: () => UserMenu
|
|
38
|
+
UserMenu: () => UserMenu,
|
|
39
|
+
useAppUrlByNameAndEnvironment: () => useAppUrlByNameAndEnvironment
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(index_exports);
|
|
40
42
|
|
|
@@ -135,24 +137,49 @@ function FeedbackLink({ link, subject, body }) {
|
|
|
135
137
|
);
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
// src/SideMenu/components/MenuHeader.tsx
|
|
141
|
+
var import_eds_tokens2 = require("@equinor/eds-tokens");
|
|
142
|
+
var import_styled_components2 = require("styled-components");
|
|
143
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
144
|
+
function MenuHeader({ appName, icon }) {
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LogoWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(LogoStyle, { children: [
|
|
146
|
+
icon,
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: appName })
|
|
148
|
+
] }) });
|
|
149
|
+
}
|
|
150
|
+
var LogoWrapper = import_styled_components2.styled.div`
|
|
151
|
+
padding: 0 ${import_eds_tokens2.tokens.spacings.comfortable.medium} ${import_eds_tokens2.tokens.spacings.comfortable.small}
|
|
152
|
+
${import_eds_tokens2.tokens.spacings.comfortable.medium};
|
|
153
|
+
text-align: center;
|
|
154
|
+
font-weight: 500;
|
|
155
|
+
`;
|
|
156
|
+
var LogoStyle = import_styled_components2.styled.div`
|
|
157
|
+
align-items: center;
|
|
158
|
+
display: flex;
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
gap: ${import_eds_tokens2.tokens.spacings.comfortable.small};
|
|
161
|
+
justify-content: center;
|
|
162
|
+
text-align: center;
|
|
163
|
+
`;
|
|
164
|
+
|
|
138
165
|
// src/SideMenu/SideMenu.tsx
|
|
139
166
|
var import_eds_core_react5 = require("@equinor/eds-core-react");
|
|
140
167
|
var import_eds_icons4 = require("@equinor/eds-icons");
|
|
141
|
-
var
|
|
168
|
+
var import_eds_tokens5 = require("@equinor/eds-tokens");
|
|
142
169
|
var import_react = require("react");
|
|
143
|
-
var
|
|
170
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
144
171
|
|
|
145
172
|
// src/SideMenu/components/MenuList.tsx
|
|
146
173
|
var import_eds_core_react4 = require("@equinor/eds-core-react");
|
|
147
|
-
var
|
|
148
|
-
var
|
|
174
|
+
var import_eds_tokens4 = require("@equinor/eds-tokens");
|
|
175
|
+
var import_styled_components4 = require("styled-components");
|
|
149
176
|
|
|
150
177
|
// src/SideMenu/components/MenuLink.tsx
|
|
151
178
|
var import_eds_core_react3 = require("@equinor/eds-core-react");
|
|
152
179
|
var import_eds_icons3 = require("@equinor/eds-icons");
|
|
153
|
-
var
|
|
180
|
+
var import_eds_tokens3 = require("@equinor/eds-tokens");
|
|
154
181
|
var import_navigation = require("next/navigation");
|
|
155
|
-
var
|
|
182
|
+
var import_styled_components3 = require("styled-components");
|
|
156
183
|
|
|
157
184
|
// src/SideMenu/useAppUrlByNameAndEnvironment.ts
|
|
158
185
|
function useAppUrlByNameAndEnvironment(appName, currentEnvironment, appUrls) {
|
|
@@ -166,7 +193,7 @@ function useAppUrlByNameAndEnvironment(appName, currentEnvironment, appUrls) {
|
|
|
166
193
|
}
|
|
167
194
|
|
|
168
195
|
// src/SideMenu/components/MenuLink.tsx
|
|
169
|
-
var
|
|
196
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
170
197
|
function MenuLink({
|
|
171
198
|
item,
|
|
172
199
|
environment,
|
|
@@ -178,15 +205,15 @@ function MenuLink({
|
|
|
178
205
|
const url = (_b = item == null ? void 0 : item.url) != null ? _b : urlByNameAndEnvironment;
|
|
179
206
|
const pathName = (0, import_navigation.usePathname)();
|
|
180
207
|
let isActive = !item.external && pathName == item.url;
|
|
181
|
-
const linkContent = /* @__PURE__ */ (0,
|
|
208
|
+
const linkContent = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
182
209
|
item.name,
|
|
183
|
-
item.external && /* @__PURE__ */ (0,
|
|
210
|
+
item.external && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_eds_core_react3.Icon, { data: import_eds_icons3.external_link, size: 16 })
|
|
184
211
|
] });
|
|
185
212
|
if (item.external) {
|
|
186
|
-
return /* @__PURE__ */ (0,
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledLink2, { href: url, target: "_blank", rel: "noopener noreferrer", children: linkContent });
|
|
187
214
|
}
|
|
188
215
|
if (LinkComponent) {
|
|
189
|
-
return /* @__PURE__ */ (0,
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
190
217
|
StyledLink2,
|
|
191
218
|
{
|
|
192
219
|
as: LinkComponent,
|
|
@@ -198,16 +225,17 @@ function MenuLink({
|
|
|
198
225
|
);
|
|
199
226
|
}
|
|
200
227
|
isActive = typeof window !== "undefined" ? window.location.pathname === item.url : false;
|
|
201
|
-
return /* @__PURE__ */ (0,
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledLink2, { href: url, $active: isActive, children: linkContent });
|
|
202
229
|
}
|
|
203
|
-
var StyledLink2 =
|
|
230
|
+
var StyledLink2 = import_styled_components3.styled.a`
|
|
204
231
|
text-decoration: none;
|
|
205
232
|
padding: 12px 16px 12px 19px;
|
|
206
233
|
display: inline-block;
|
|
207
234
|
width: 100%;
|
|
208
|
-
color: ${
|
|
209
|
-
background-color: ${({ $active }) => $active ?
|
|
235
|
+
color: ${import_eds_tokens3.tokens.colors.interactive.secondary__resting.rgba};
|
|
236
|
+
background-color: ${({ $active }) => $active ? import_eds_tokens3.tokens.colors.interactive.primary__selected_highlight.rgba : "transparent"};
|
|
210
237
|
font-weight: ${({ $active }) => $active ? 700 : 400};
|
|
238
|
+
font-size: 0.875rem;
|
|
211
239
|
|
|
212
240
|
&:hover {
|
|
213
241
|
//TODO: check hover color for dark theme with designer when back
|
|
@@ -217,50 +245,69 @@ var StyledLink2 = import_styled_components2.styled.a`
|
|
|
217
245
|
&:focus-visible {
|
|
218
246
|
outline-offset: -2px;
|
|
219
247
|
}
|
|
248
|
+
|
|
249
|
+
span {
|
|
250
|
+
align-items: center;
|
|
251
|
+
display: flex;
|
|
252
|
+
gap: 1rem;
|
|
253
|
+
justify-content: space-between;
|
|
254
|
+
font-size: 0.875rem;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
span svg {
|
|
258
|
+
opacity: 60%;
|
|
259
|
+
}
|
|
220
260
|
`;
|
|
221
261
|
|
|
222
262
|
// src/SideMenu/components/MenuList.tsx
|
|
223
|
-
var
|
|
224
|
-
function MenuList({
|
|
225
|
-
|
|
263
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
264
|
+
function MenuList({
|
|
265
|
+
items,
|
|
266
|
+
currentEnvironment,
|
|
267
|
+
appUrls,
|
|
268
|
+
onToggleMenuGroup,
|
|
269
|
+
linkComponent
|
|
270
|
+
}) {
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: items.map((menuItem) => {
|
|
226
272
|
if (isMenuItemGroup(menuItem)) {
|
|
227
|
-
return /* @__PURE__ */ (0,
|
|
228
|
-
/* @__PURE__ */ (0,
|
|
229
|
-
/* @__PURE__ */ (0,
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion.Header, { onToggle: onToggleMenuGroup, children: menuItem.title }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion.Panel, { "aria-label": `Links for ${menuItem.title}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: menuItem.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
230
276
|
MenuLink,
|
|
231
277
|
{
|
|
232
278
|
item,
|
|
233
279
|
environment: currentEnvironment,
|
|
234
|
-
appUrls
|
|
280
|
+
appUrls,
|
|
281
|
+
linkComponent
|
|
235
282
|
}
|
|
236
283
|
) }, menuItem.title + "-" + item.name)) }) })
|
|
237
284
|
] }, menuItem.title) }, menuItem.title) }, menuItem.title);
|
|
238
285
|
} else {
|
|
239
|
-
return /* @__PURE__ */ (0,
|
|
286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
287
|
+
MenuLink,
|
|
288
|
+
{
|
|
289
|
+
item: menuItem,
|
|
290
|
+
environment: currentEnvironment,
|
|
291
|
+
appUrls,
|
|
292
|
+
linkComponent
|
|
293
|
+
}
|
|
294
|
+
) }, menuItem.name);
|
|
240
295
|
}
|
|
241
296
|
}) });
|
|
242
297
|
}
|
|
243
298
|
function isMenuItemGroup(item) {
|
|
244
299
|
return typeof item === "object" && "title" in item && "items" in item;
|
|
245
300
|
}
|
|
246
|
-
var AccordionItem = (0,
|
|
301
|
+
var AccordionItem = (0, import_styled_components4.styled)(import_eds_core_react4.Accordion.Item)`
|
|
247
302
|
a {
|
|
248
303
|
display: block;
|
|
249
|
-
padding: 12px ${
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
a span {
|
|
253
|
-
align-items: center;
|
|
254
|
-
display: flex;
|
|
255
|
-
gap: 1rem;
|
|
256
|
-
justify-content: space-between;
|
|
257
|
-
font-size: 0.875rem;
|
|
304
|
+
padding: 12px ${import_eds_tokens4.tokens.spacings.comfortable.medium} 12px ${import_eds_tokens4.tokens.spacings.comfortable.x_large};
|
|
258
305
|
}
|
|
259
306
|
|
|
260
307
|
h2 {
|
|
261
308
|
background: transparent;
|
|
262
309
|
border: 0;
|
|
263
|
-
color: ${
|
|
310
|
+
color: ${import_eds_tokens4.tokens.colors.interactive.secondary__resting.rgba};
|
|
264
311
|
}
|
|
265
312
|
|
|
266
313
|
h2 + div {
|
|
@@ -273,13 +320,13 @@ var AccordionItem = (0, import_styled_components3.styled)(import_eds_core_react4
|
|
|
273
320
|
h2 button svg {
|
|
274
321
|
width: 14px;
|
|
275
322
|
height: 14px;
|
|
276
|
-
margin-right: ${
|
|
323
|
+
margin-right: ${import_eds_tokens4.tokens.spacings.comfortable.x_small};
|
|
277
324
|
transform: rotate(-90deg);
|
|
278
|
-
fill: ${
|
|
325
|
+
fill: ${import_eds_tokens4.tokens.colors.interactive.secondary__resting.rgba};
|
|
279
326
|
}
|
|
280
327
|
|
|
281
328
|
h2 button span {
|
|
282
|
-
color: ${
|
|
329
|
+
color: ${import_eds_tokens4.tokens.colors.interactive.secondary__resting.rgba};
|
|
283
330
|
font-weight: 700;
|
|
284
331
|
font-size: 0.875rem;
|
|
285
332
|
}
|
|
@@ -288,10 +335,6 @@ var AccordionItem = (0, import_styled_components3.styled)(import_eds_core_react4
|
|
|
288
335
|
transform: rotate(180deg);
|
|
289
336
|
}
|
|
290
337
|
|
|
291
|
-
li a svg {
|
|
292
|
-
opacity: 60%;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
338
|
h2 button:hover,
|
|
296
339
|
li a:hover {
|
|
297
340
|
background-color: var(--cpl-sidebar-hover-color);
|
|
@@ -303,7 +346,7 @@ var AccordionItem = (0, import_styled_components3.styled)(import_eds_core_react4
|
|
|
303
346
|
`;
|
|
304
347
|
|
|
305
348
|
// src/SideMenu/SideMenu.tsx
|
|
306
|
-
var
|
|
349
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
307
350
|
function SideMenu({
|
|
308
351
|
isOpen,
|
|
309
352
|
onToggle,
|
|
@@ -313,7 +356,8 @@ function SideMenu({
|
|
|
313
356
|
currentEnvironment,
|
|
314
357
|
titleOtherMenuItems,
|
|
315
358
|
otherMenuItems,
|
|
316
|
-
appUrls
|
|
359
|
+
appUrls,
|
|
360
|
+
linkComponent
|
|
317
361
|
}) {
|
|
318
362
|
var _a;
|
|
319
363
|
const width = "268px";
|
|
@@ -347,46 +391,47 @@ function SideMenu({
|
|
|
347
391
|
return () => element.removeEventListener("scroll", handleScroll);
|
|
348
392
|
}
|
|
349
393
|
}, [handleScroll]);
|
|
350
|
-
return /* @__PURE__ */ (0,
|
|
351
|
-
/* @__PURE__ */ (0,
|
|
352
|
-
/* @__PURE__ */ (0,
|
|
394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Sidebar, { $isOpen: isOpen, $width: isOpen ? width : "", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(InnerWrapper, { ref: containerRef, $width: width, children: [
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StickyCloseButton, { $showBorder: hasOverflow && scrolledDown, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
353
397
|
import_eds_core_react5.Button,
|
|
354
398
|
{
|
|
355
399
|
variant: "ghost_icon",
|
|
356
400
|
color: "secondary",
|
|
357
401
|
"aria-label": "Toggle side menu",
|
|
358
402
|
onClick: () => onToggle(!isOpen),
|
|
359
|
-
children: /* @__PURE__ */ (0,
|
|
403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_eds_core_react5.Icon, { data: import_eds_icons4.collapse, size: 24 })
|
|
360
404
|
}
|
|
361
405
|
) }),
|
|
362
406
|
logoElement,
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
364
|
-
/* @__PURE__ */ (0,
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
365
409
|
MenuList,
|
|
366
410
|
{
|
|
367
411
|
items: mainMenuItems,
|
|
368
412
|
currentEnvironment,
|
|
369
413
|
appUrls,
|
|
370
|
-
onToggleMenuGroup: checkOverflow
|
|
414
|
+
onToggleMenuGroup: checkOverflow,
|
|
415
|
+
linkComponent
|
|
371
416
|
}
|
|
372
417
|
),
|
|
373
|
-
otherMenuItems && otherMenuItems.length > 0 && /* @__PURE__ */ (0,
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
375
|
-
/* @__PURE__ */ (0,
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
418
|
+
otherMenuItems && otherMenuItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StyledDivider, {}),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
377
422
|
import_eds_core_react5.Typography,
|
|
378
423
|
{
|
|
379
424
|
variant: "label",
|
|
380
425
|
group: "navigation",
|
|
381
426
|
as: "h2",
|
|
382
427
|
style: {
|
|
383
|
-
color:
|
|
428
|
+
color: import_eds_tokens5.tokens.colors.interactive.secondary__resting.rgba,
|
|
384
429
|
padding: "12px 19px 4px 19px"
|
|
385
430
|
},
|
|
386
431
|
children: (_a = titleOtherMenuItems == null ? void 0 : titleOtherMenuItems.toUpperCase()) != null ? _a : "OTHER SOLUTIONS"
|
|
387
432
|
}
|
|
388
433
|
),
|
|
389
|
-
/* @__PURE__ */ (0,
|
|
434
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
390
435
|
MenuList,
|
|
391
436
|
{
|
|
392
437
|
items: otherMenuItems,
|
|
@@ -398,17 +443,17 @@ function SideMenu({
|
|
|
398
443
|
] })
|
|
399
444
|
] })
|
|
400
445
|
] }),
|
|
401
|
-
/* @__PURE__ */ (0,
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StyledDivider, {})
|
|
402
447
|
] }),
|
|
403
448
|
versionInfo
|
|
404
449
|
] }) });
|
|
405
450
|
}
|
|
406
|
-
var StyledDivider = (0,
|
|
451
|
+
var StyledDivider = (0, import_styled_components5.default)(import_eds_core_react5.Divider)`
|
|
407
452
|
background-color: var(--cpl-divider-color);
|
|
408
453
|
margin: 8px 0;
|
|
409
454
|
`;
|
|
410
|
-
var Sidebar =
|
|
411
|
-
width: ${(props) => props.$isOpen ? props
|
|
455
|
+
var Sidebar = import_styled_components5.default.div`
|
|
456
|
+
width: ${(props) => props.$isOpen ? props.$width : "0px"};
|
|
412
457
|
opacity: ${(props) => props.$isOpen ? 1 : 0};
|
|
413
458
|
transition:
|
|
414
459
|
width 0.5s,
|
|
@@ -430,12 +475,12 @@ var Sidebar = import_styled_components4.default.div`
|
|
|
430
475
|
box-sizing: border-box;
|
|
431
476
|
}
|
|
432
477
|
`;
|
|
433
|
-
var InnerWrapper =
|
|
478
|
+
var InnerWrapper = import_styled_components5.default.div`
|
|
434
479
|
overflow: auto;
|
|
435
480
|
background: var(--cpl-ui-background-temporary-nav);
|
|
436
481
|
padding: 0;
|
|
437
482
|
height: 100%;
|
|
438
|
-
width: ${(props) => props
|
|
483
|
+
width: ${(props) => props.$width};
|
|
439
484
|
position: fixed;
|
|
440
485
|
display: flex;
|
|
441
486
|
flex-direction: column;
|
|
@@ -443,13 +488,13 @@ var InnerWrapper = import_styled_components4.default.div`
|
|
|
443
488
|
border-right: 1px solid var(--cpl-sidebar-border-color);
|
|
444
489
|
border-bottom: 1px solid var(--cpl-sidebar-border-color);
|
|
445
490
|
`;
|
|
446
|
-
var StickyCloseButton =
|
|
491
|
+
var StickyCloseButton = import_styled_components5.default.div`
|
|
447
492
|
z-index: 10;
|
|
448
493
|
position: sticky;
|
|
449
494
|
top: 0;
|
|
450
495
|
display: flex;
|
|
451
496
|
justify-content: flex-end;
|
|
452
|
-
padding: ${
|
|
497
|
+
padding: ${import_eds_tokens5.tokens.spacings.comfortable.xx_small};
|
|
453
498
|
background-color: var(--cpl-ui-background-temporary-nav);
|
|
454
499
|
border-bottom: ${({ $showBorder }) => $showBorder ? "1px solid var(--cpl-divider-color)" : "0"};
|
|
455
500
|
`;
|
|
@@ -457,10 +502,10 @@ var StickyCloseButton = import_styled_components4.default.div`
|
|
|
457
502
|
// src/UserMenu/UserMenu.tsx
|
|
458
503
|
var import_eds_core_react6 = require("@equinor/eds-core-react");
|
|
459
504
|
var import_eds_icons5 = require("@equinor/eds-icons");
|
|
460
|
-
var
|
|
505
|
+
var import_eds_tokens6 = require("@equinor/eds-tokens");
|
|
461
506
|
var import_react2 = require("react");
|
|
462
|
-
var
|
|
463
|
-
var
|
|
507
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
508
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
464
509
|
function UserMenu({ user, logout, settingsLink, children }) {
|
|
465
510
|
var _a, _b, _c, _d, _e;
|
|
466
511
|
const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
|
|
@@ -473,20 +518,20 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
473
518
|
};
|
|
474
519
|
const LogOutMenuItem = () => {
|
|
475
520
|
if (typeof logout === "string") {
|
|
476
|
-
return /* @__PURE__ */ (0,
|
|
477
|
-
/* @__PURE__ */ (0,
|
|
478
|
-
/* @__PURE__ */ (0,
|
|
521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Menu.Item, { as: "a", href: logout, className: "menu-item", id: "logout-button", children: [
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons5.log_out }),
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Log out" })
|
|
479
524
|
] });
|
|
480
525
|
} else {
|
|
481
|
-
return /* @__PURE__ */ (0,
|
|
482
|
-
/* @__PURE__ */ (0,
|
|
483
|
-
/* @__PURE__ */ (0,
|
|
526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Menu.Item, { as: "button", onClick: logout, className: "menu-item", id: "logout-button", children: [
|
|
527
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons5.log_out }),
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Log out" })
|
|
484
529
|
] });
|
|
485
530
|
}
|
|
486
531
|
};
|
|
487
532
|
const firstLetter = (_c = (_b = (_a = user == null ? void 0 : user.email) == null ? void 0 : _a[0]) == null ? void 0 : _b.toUpperCase()) != null ? _c : "-";
|
|
488
|
-
return /* @__PURE__ */ (0,
|
|
489
|
-
/* @__PURE__ */ (0,
|
|
533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
534
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
490
535
|
StyledUserButton,
|
|
491
536
|
{
|
|
492
537
|
id: "user-button",
|
|
@@ -499,7 +544,7 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
499
544
|
children: firstLetter
|
|
500
545
|
}
|
|
501
546
|
),
|
|
502
|
-
/* @__PURE__ */ (0,
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
503
548
|
MenuWrapper,
|
|
504
549
|
{
|
|
505
550
|
id: "user-menu",
|
|
@@ -509,16 +554,16 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
509
554
|
anchorEl,
|
|
510
555
|
style: { padding: 0, paddingBottom: 2 },
|
|
511
556
|
children: [
|
|
512
|
-
/* @__PURE__ */ (0,
|
|
513
|
-
/* @__PURE__ */ (0,
|
|
514
|
-
isOpen && /* @__PURE__ */ (0,
|
|
515
|
-
/* @__PURE__ */ (0,
|
|
516
|
-
/* @__PURE__ */ (0,
|
|
557
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(IconAndTextWrapper, { children: [
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LetterCircle, { children: firstLetter }),
|
|
559
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { fontWeight: "bold", lineHeight: 0.9, marginBottom: 2 }, children: (_d = user == null ? void 0 : user.name) != null ? _d : "-" }),
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: (_e = user == null ? void 0 : user.email) != null ? _e : "-" })
|
|
517
562
|
] })
|
|
518
563
|
] }),
|
|
519
|
-
settingsLink && /* @__PURE__ */ (0,
|
|
520
|
-
/* @__PURE__ */ (0,
|
|
521
|
-
/* @__PURE__ */ (0,
|
|
564
|
+
settingsLink && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_eds_core_react6.Menu.Item, { as: "a", href: settingsLink, className: "menu-item", children: [
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_eds_core_react6.Icon, { data: import_eds_icons5.settings }),
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Settings" })
|
|
522
567
|
] }),
|
|
523
568
|
LogOutMenuItem(),
|
|
524
569
|
children
|
|
@@ -527,25 +572,25 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
527
572
|
)
|
|
528
573
|
] });
|
|
529
574
|
}
|
|
530
|
-
var MenuWrapper = (0,
|
|
531
|
-
border-radius: ${
|
|
532
|
-
margin-top: ${
|
|
533
|
-
margin-bottom: -${
|
|
534
|
-
padding-bottom: ${
|
|
575
|
+
var MenuWrapper = (0, import_styled_components6.default)(import_eds_core_react6.Menu)`
|
|
576
|
+
border-radius: ${import_eds_tokens6.tokens.shape.corners.borderRadius};
|
|
577
|
+
margin-top: ${import_eds_tokens6.tokens.spacings.comfortable.small};
|
|
578
|
+
margin-bottom: -${import_eds_tokens6.tokens.spacings.comfortable.small};
|
|
579
|
+
padding-bottom: ${import_eds_tokens6.tokens.spacings.comfortable.small};
|
|
535
580
|
padding-left: 0;
|
|
536
581
|
padding-right: 0;
|
|
537
|
-
padding-top: ${
|
|
582
|
+
padding-top: ${import_eds_tokens6.tokens.spacings.comfortable.small};
|
|
538
583
|
width: 315px;
|
|
539
584
|
|
|
540
585
|
background: var(--cpl-ui-background-temporary-nav, #fff);
|
|
541
|
-
color: ${
|
|
586
|
+
color: ${import_eds_tokens6.tokens.colors.text.static_icons__default.rgba};
|
|
542
587
|
|
|
543
588
|
.menu-item {
|
|
544
589
|
align-items: center;
|
|
545
590
|
display: flex;
|
|
546
|
-
gap: ${
|
|
591
|
+
gap: ${import_eds_tokens6.tokens.spacings.comfortable.medium};
|
|
547
592
|
opacity: 0.85;
|
|
548
|
-
padding: ${
|
|
593
|
+
padding: ${import_eds_tokens6.tokens.spacings.comfortable.small} ${import_eds_tokens6.tokens.spacings.comfortable.large};
|
|
549
594
|
|
|
550
595
|
svg {
|
|
551
596
|
opacity: 0.7;
|
|
@@ -560,7 +605,7 @@ var MenuWrapper = (0, import_styled_components5.default)(import_eds_core_react6.
|
|
|
560
605
|
}
|
|
561
606
|
}
|
|
562
607
|
`;
|
|
563
|
-
var LetterCircle =
|
|
608
|
+
var LetterCircle = import_styled_components6.default.span`
|
|
564
609
|
align-items: center;
|
|
565
610
|
border-radius: 1000px;
|
|
566
611
|
display: flex;
|
|
@@ -569,16 +614,16 @@ var LetterCircle = import_styled_components5.default.span`
|
|
|
569
614
|
height: 32px;
|
|
570
615
|
justify-content: center;
|
|
571
616
|
width: 32px;
|
|
572
|
-
background-color: ${
|
|
573
|
-
color: ${
|
|
617
|
+
background-color: ${import_eds_tokens6.tokens.colors.interactive.primary__resting.rgba};
|
|
618
|
+
color: ${import_eds_tokens6.tokens.colors.text.static_icons__primary_white.rgba};
|
|
574
619
|
`;
|
|
575
|
-
var StyledUserButton = (0,
|
|
620
|
+
var StyledUserButton = (0, import_styled_components6.default)(import_eds_core_react6.Button)`
|
|
576
621
|
margin-left: 12px;
|
|
577
622
|
font-weight: bold;
|
|
578
623
|
width: 32px;
|
|
579
624
|
height: 32px;
|
|
580
625
|
`;
|
|
581
|
-
var IconAndTextWrapper = (0,
|
|
626
|
+
var IconAndTextWrapper = (0, import_styled_components6.default)(import_eds_core_react6.Menu.Item)`
|
|
582
627
|
display: flex;
|
|
583
628
|
gap: 12px;
|
|
584
629
|
padding: 12px 20px;
|
|
@@ -594,8 +639,10 @@ var IconAndTextWrapper = (0, import_styled_components5.default)(import_eds_core_
|
|
|
594
639
|
// Annotate the CommonJS export names for ESM import in node:
|
|
595
640
|
0 && (module.exports = {
|
|
596
641
|
FeedbackLink,
|
|
642
|
+
MenuHeader,
|
|
597
643
|
SideMenu,
|
|
598
644
|
StyledLink,
|
|
599
645
|
TopBar,
|
|
600
|
-
UserMenu
|
|
646
|
+
UserMenu,
|
|
647
|
+
useAppUrlByNameAndEnvironment
|
|
601
648
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -95,24 +95,49 @@ function FeedbackLink({ link, subject, body }) {
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/SideMenu/components/MenuHeader.tsx
|
|
99
|
+
import { tokens as tokens2 } from "@equinor/eds-tokens";
|
|
100
|
+
import { styled as styled2 } from "styled-components";
|
|
101
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
102
|
+
function MenuHeader({ appName, icon }) {
|
|
103
|
+
return /* @__PURE__ */ jsx3(LogoWrapper, { children: /* @__PURE__ */ jsxs3(LogoStyle, { children: [
|
|
104
|
+
icon,
|
|
105
|
+
/* @__PURE__ */ jsx3("span", { children: appName })
|
|
106
|
+
] }) });
|
|
107
|
+
}
|
|
108
|
+
var LogoWrapper = styled2.div`
|
|
109
|
+
padding: 0 ${tokens2.spacings.comfortable.medium} ${tokens2.spacings.comfortable.small}
|
|
110
|
+
${tokens2.spacings.comfortable.medium};
|
|
111
|
+
text-align: center;
|
|
112
|
+
font-weight: 500;
|
|
113
|
+
`;
|
|
114
|
+
var LogoStyle = styled2.div`
|
|
115
|
+
align-items: center;
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
gap: ${tokens2.spacings.comfortable.small};
|
|
119
|
+
justify-content: center;
|
|
120
|
+
text-align: center;
|
|
121
|
+
`;
|
|
122
|
+
|
|
98
123
|
// src/SideMenu/SideMenu.tsx
|
|
99
124
|
import { Button as Button2, Divider, Icon as Icon4, Typography as Typography2 } from "@equinor/eds-core-react";
|
|
100
125
|
import { collapse } from "@equinor/eds-icons";
|
|
101
|
-
import { tokens as
|
|
126
|
+
import { tokens as tokens5 } from "@equinor/eds-tokens";
|
|
102
127
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
103
|
-
import
|
|
128
|
+
import styled5 from "styled-components";
|
|
104
129
|
|
|
105
130
|
// src/SideMenu/components/MenuList.tsx
|
|
106
131
|
import { Accordion } from "@equinor/eds-core-react";
|
|
107
|
-
import { tokens as
|
|
108
|
-
import { styled as
|
|
132
|
+
import { tokens as tokens4 } from "@equinor/eds-tokens";
|
|
133
|
+
import { styled as styled4 } from "styled-components";
|
|
109
134
|
|
|
110
135
|
// src/SideMenu/components/MenuLink.tsx
|
|
111
136
|
import { Icon as Icon3 } from "@equinor/eds-core-react";
|
|
112
137
|
import { external_link as external_link2 } from "@equinor/eds-icons";
|
|
113
|
-
import { tokens as
|
|
138
|
+
import { tokens as tokens3 } from "@equinor/eds-tokens";
|
|
114
139
|
import { usePathname } from "next/navigation";
|
|
115
|
-
import { styled as
|
|
140
|
+
import { styled as styled3 } from "styled-components";
|
|
116
141
|
|
|
117
142
|
// src/SideMenu/useAppUrlByNameAndEnvironment.ts
|
|
118
143
|
function useAppUrlByNameAndEnvironment(appName, currentEnvironment, appUrls) {
|
|
@@ -126,7 +151,7 @@ function useAppUrlByNameAndEnvironment(appName, currentEnvironment, appUrls) {
|
|
|
126
151
|
}
|
|
127
152
|
|
|
128
153
|
// src/SideMenu/components/MenuLink.tsx
|
|
129
|
-
import { jsx as
|
|
154
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
130
155
|
function MenuLink({
|
|
131
156
|
item,
|
|
132
157
|
environment,
|
|
@@ -138,15 +163,15 @@ function MenuLink({
|
|
|
138
163
|
const url = (_b = item == null ? void 0 : item.url) != null ? _b : urlByNameAndEnvironment;
|
|
139
164
|
const pathName = usePathname();
|
|
140
165
|
let isActive = !item.external && pathName == item.url;
|
|
141
|
-
const linkContent = /* @__PURE__ */
|
|
166
|
+
const linkContent = /* @__PURE__ */ jsxs4("span", { children: [
|
|
142
167
|
item.name,
|
|
143
|
-
item.external && /* @__PURE__ */
|
|
168
|
+
item.external && /* @__PURE__ */ jsx4(Icon3, { data: external_link2, size: 16 })
|
|
144
169
|
] });
|
|
145
170
|
if (item.external) {
|
|
146
|
-
return /* @__PURE__ */
|
|
171
|
+
return /* @__PURE__ */ jsx4(StyledLink2, { href: url, target: "_blank", rel: "noopener noreferrer", children: linkContent });
|
|
147
172
|
}
|
|
148
173
|
if (LinkComponent) {
|
|
149
|
-
return /* @__PURE__ */
|
|
174
|
+
return /* @__PURE__ */ jsx4(
|
|
150
175
|
StyledLink2,
|
|
151
176
|
{
|
|
152
177
|
as: LinkComponent,
|
|
@@ -158,16 +183,17 @@ function MenuLink({
|
|
|
158
183
|
);
|
|
159
184
|
}
|
|
160
185
|
isActive = typeof window !== "undefined" ? window.location.pathname === item.url : false;
|
|
161
|
-
return /* @__PURE__ */
|
|
186
|
+
return /* @__PURE__ */ jsx4(StyledLink2, { href: url, $active: isActive, children: linkContent });
|
|
162
187
|
}
|
|
163
|
-
var StyledLink2 =
|
|
188
|
+
var StyledLink2 = styled3.a`
|
|
164
189
|
text-decoration: none;
|
|
165
190
|
padding: 12px 16px 12px 19px;
|
|
166
191
|
display: inline-block;
|
|
167
192
|
width: 100%;
|
|
168
|
-
color: ${
|
|
169
|
-
background-color: ${({ $active }) => $active ?
|
|
193
|
+
color: ${tokens3.colors.interactive.secondary__resting.rgba};
|
|
194
|
+
background-color: ${({ $active }) => $active ? tokens3.colors.interactive.primary__selected_highlight.rgba : "transparent"};
|
|
170
195
|
font-weight: ${({ $active }) => $active ? 700 : 400};
|
|
196
|
+
font-size: 0.875rem;
|
|
171
197
|
|
|
172
198
|
&:hover {
|
|
173
199
|
//TODO: check hover color for dark theme with designer when back
|
|
@@ -177,50 +203,69 @@ var StyledLink2 = styled2.a`
|
|
|
177
203
|
&:focus-visible {
|
|
178
204
|
outline-offset: -2px;
|
|
179
205
|
}
|
|
206
|
+
|
|
207
|
+
span {
|
|
208
|
+
align-items: center;
|
|
209
|
+
display: flex;
|
|
210
|
+
gap: 1rem;
|
|
211
|
+
justify-content: space-between;
|
|
212
|
+
font-size: 0.875rem;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
span svg {
|
|
216
|
+
opacity: 60%;
|
|
217
|
+
}
|
|
180
218
|
`;
|
|
181
219
|
|
|
182
220
|
// src/SideMenu/components/MenuList.tsx
|
|
183
|
-
import { jsx as
|
|
184
|
-
function MenuList({
|
|
185
|
-
|
|
221
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
222
|
+
function MenuList({
|
|
223
|
+
items,
|
|
224
|
+
currentEnvironment,
|
|
225
|
+
appUrls,
|
|
226
|
+
onToggleMenuGroup,
|
|
227
|
+
linkComponent
|
|
228
|
+
}) {
|
|
229
|
+
return /* @__PURE__ */ jsx5("ul", { children: items.map((menuItem) => {
|
|
186
230
|
if (isMenuItemGroup(menuItem)) {
|
|
187
|
-
return /* @__PURE__ */
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
231
|
+
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(Accordion, { children: /* @__PURE__ */ jsxs5(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
232
|
+
/* @__PURE__ */ jsx5(Accordion.Header, { onToggle: onToggleMenuGroup, children: menuItem.title }),
|
|
233
|
+
/* @__PURE__ */ jsx5(Accordion.Panel, { "aria-label": `Links for ${menuItem.title}`, children: /* @__PURE__ */ jsx5("ul", { children: menuItem.items.map((item) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(
|
|
190
234
|
MenuLink,
|
|
191
235
|
{
|
|
192
236
|
item,
|
|
193
237
|
environment: currentEnvironment,
|
|
194
|
-
appUrls
|
|
238
|
+
appUrls,
|
|
239
|
+
linkComponent
|
|
195
240
|
}
|
|
196
241
|
) }, menuItem.title + "-" + item.name)) }) })
|
|
197
242
|
] }, menuItem.title) }, menuItem.title) }, menuItem.title);
|
|
198
243
|
} else {
|
|
199
|
-
return /* @__PURE__ */
|
|
244
|
+
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(
|
|
245
|
+
MenuLink,
|
|
246
|
+
{
|
|
247
|
+
item: menuItem,
|
|
248
|
+
environment: currentEnvironment,
|
|
249
|
+
appUrls,
|
|
250
|
+
linkComponent
|
|
251
|
+
}
|
|
252
|
+
) }, menuItem.name);
|
|
200
253
|
}
|
|
201
254
|
}) });
|
|
202
255
|
}
|
|
203
256
|
function isMenuItemGroup(item) {
|
|
204
257
|
return typeof item === "object" && "title" in item && "items" in item;
|
|
205
258
|
}
|
|
206
|
-
var AccordionItem =
|
|
259
|
+
var AccordionItem = styled4(Accordion.Item)`
|
|
207
260
|
a {
|
|
208
261
|
display: block;
|
|
209
|
-
padding: 12px ${
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
a span {
|
|
213
|
-
align-items: center;
|
|
214
|
-
display: flex;
|
|
215
|
-
gap: 1rem;
|
|
216
|
-
justify-content: space-between;
|
|
217
|
-
font-size: 0.875rem;
|
|
262
|
+
padding: 12px ${tokens4.spacings.comfortable.medium} 12px ${tokens4.spacings.comfortable.x_large};
|
|
218
263
|
}
|
|
219
264
|
|
|
220
265
|
h2 {
|
|
221
266
|
background: transparent;
|
|
222
267
|
border: 0;
|
|
223
|
-
color: ${
|
|
268
|
+
color: ${tokens4.colors.interactive.secondary__resting.rgba};
|
|
224
269
|
}
|
|
225
270
|
|
|
226
271
|
h2 + div {
|
|
@@ -233,13 +278,13 @@ var AccordionItem = styled3(Accordion.Item)`
|
|
|
233
278
|
h2 button svg {
|
|
234
279
|
width: 14px;
|
|
235
280
|
height: 14px;
|
|
236
|
-
margin-right: ${
|
|
281
|
+
margin-right: ${tokens4.spacings.comfortable.x_small};
|
|
237
282
|
transform: rotate(-90deg);
|
|
238
|
-
fill: ${
|
|
283
|
+
fill: ${tokens4.colors.interactive.secondary__resting.rgba};
|
|
239
284
|
}
|
|
240
285
|
|
|
241
286
|
h2 button span {
|
|
242
|
-
color: ${
|
|
287
|
+
color: ${tokens4.colors.interactive.secondary__resting.rgba};
|
|
243
288
|
font-weight: 700;
|
|
244
289
|
font-size: 0.875rem;
|
|
245
290
|
}
|
|
@@ -248,10 +293,6 @@ var AccordionItem = styled3(Accordion.Item)`
|
|
|
248
293
|
transform: rotate(180deg);
|
|
249
294
|
}
|
|
250
295
|
|
|
251
|
-
li a svg {
|
|
252
|
-
opacity: 60%;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
296
|
h2 button:hover,
|
|
256
297
|
li a:hover {
|
|
257
298
|
background-color: var(--cpl-sidebar-hover-color);
|
|
@@ -263,7 +304,7 @@ var AccordionItem = styled3(Accordion.Item)`
|
|
|
263
304
|
`;
|
|
264
305
|
|
|
265
306
|
// src/SideMenu/SideMenu.tsx
|
|
266
|
-
import { Fragment, jsx as
|
|
307
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
267
308
|
function SideMenu({
|
|
268
309
|
isOpen,
|
|
269
310
|
onToggle,
|
|
@@ -273,7 +314,8 @@ function SideMenu({
|
|
|
273
314
|
currentEnvironment,
|
|
274
315
|
titleOtherMenuItems,
|
|
275
316
|
otherMenuItems,
|
|
276
|
-
appUrls
|
|
317
|
+
appUrls,
|
|
318
|
+
linkComponent
|
|
277
319
|
}) {
|
|
278
320
|
var _a;
|
|
279
321
|
const width = "268px";
|
|
@@ -307,46 +349,47 @@ function SideMenu({
|
|
|
307
349
|
return () => element.removeEventListener("scroll", handleScroll);
|
|
308
350
|
}
|
|
309
351
|
}, [handleScroll]);
|
|
310
|
-
return /* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ jsx6(Sidebar, { $isOpen: isOpen, $width: isOpen ? width : "", children: /* @__PURE__ */ jsxs6(InnerWrapper, { ref: containerRef, $width: width, children: [
|
|
353
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
354
|
+
/* @__PURE__ */ jsx6(StickyCloseButton, { $showBorder: hasOverflow && scrolledDown, children: /* @__PURE__ */ jsx6(
|
|
313
355
|
Button2,
|
|
314
356
|
{
|
|
315
357
|
variant: "ghost_icon",
|
|
316
358
|
color: "secondary",
|
|
317
359
|
"aria-label": "Toggle side menu",
|
|
318
360
|
onClick: () => onToggle(!isOpen),
|
|
319
|
-
children: /* @__PURE__ */
|
|
361
|
+
children: /* @__PURE__ */ jsx6(Icon4, { data: collapse, size: 24 })
|
|
320
362
|
}
|
|
321
363
|
) }),
|
|
322
364
|
logoElement,
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
/* @__PURE__ */
|
|
365
|
+
/* @__PURE__ */ jsxs6("nav", { children: [
|
|
366
|
+
/* @__PURE__ */ jsx6(
|
|
325
367
|
MenuList,
|
|
326
368
|
{
|
|
327
369
|
items: mainMenuItems,
|
|
328
370
|
currentEnvironment,
|
|
329
371
|
appUrls,
|
|
330
|
-
onToggleMenuGroup: checkOverflow
|
|
372
|
+
onToggleMenuGroup: checkOverflow,
|
|
373
|
+
linkComponent
|
|
331
374
|
}
|
|
332
375
|
),
|
|
333
|
-
otherMenuItems && otherMenuItems.length > 0 && /* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
/* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
376
|
+
otherMenuItems && otherMenuItems.length > 0 && /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
377
|
+
/* @__PURE__ */ jsx6(StyledDivider, {}),
|
|
378
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
379
|
+
/* @__PURE__ */ jsx6(
|
|
337
380
|
Typography2,
|
|
338
381
|
{
|
|
339
382
|
variant: "label",
|
|
340
383
|
group: "navigation",
|
|
341
384
|
as: "h2",
|
|
342
385
|
style: {
|
|
343
|
-
color:
|
|
386
|
+
color: tokens5.colors.interactive.secondary__resting.rgba,
|
|
344
387
|
padding: "12px 19px 4px 19px"
|
|
345
388
|
},
|
|
346
389
|
children: (_a = titleOtherMenuItems == null ? void 0 : titleOtherMenuItems.toUpperCase()) != null ? _a : "OTHER SOLUTIONS"
|
|
347
390
|
}
|
|
348
391
|
),
|
|
349
|
-
/* @__PURE__ */
|
|
392
|
+
/* @__PURE__ */ jsx6(
|
|
350
393
|
MenuList,
|
|
351
394
|
{
|
|
352
395
|
items: otherMenuItems,
|
|
@@ -358,17 +401,17 @@ function SideMenu({
|
|
|
358
401
|
] })
|
|
359
402
|
] })
|
|
360
403
|
] }),
|
|
361
|
-
/* @__PURE__ */
|
|
404
|
+
/* @__PURE__ */ jsx6(StyledDivider, {})
|
|
362
405
|
] }),
|
|
363
406
|
versionInfo
|
|
364
407
|
] }) });
|
|
365
408
|
}
|
|
366
|
-
var StyledDivider =
|
|
409
|
+
var StyledDivider = styled5(Divider)`
|
|
367
410
|
background-color: var(--cpl-divider-color);
|
|
368
411
|
margin: 8px 0;
|
|
369
412
|
`;
|
|
370
|
-
var Sidebar =
|
|
371
|
-
width: ${(props) => props.$isOpen ? props
|
|
413
|
+
var Sidebar = styled5.div`
|
|
414
|
+
width: ${(props) => props.$isOpen ? props.$width : "0px"};
|
|
372
415
|
opacity: ${(props) => props.$isOpen ? 1 : 0};
|
|
373
416
|
transition:
|
|
374
417
|
width 0.5s,
|
|
@@ -390,12 +433,12 @@ var Sidebar = styled4.div`
|
|
|
390
433
|
box-sizing: border-box;
|
|
391
434
|
}
|
|
392
435
|
`;
|
|
393
|
-
var InnerWrapper =
|
|
436
|
+
var InnerWrapper = styled5.div`
|
|
394
437
|
overflow: auto;
|
|
395
438
|
background: var(--cpl-ui-background-temporary-nav);
|
|
396
439
|
padding: 0;
|
|
397
440
|
height: 100%;
|
|
398
|
-
width: ${(props) => props
|
|
441
|
+
width: ${(props) => props.$width};
|
|
399
442
|
position: fixed;
|
|
400
443
|
display: flex;
|
|
401
444
|
flex-direction: column;
|
|
@@ -403,13 +446,13 @@ var InnerWrapper = styled4.div`
|
|
|
403
446
|
border-right: 1px solid var(--cpl-sidebar-border-color);
|
|
404
447
|
border-bottom: 1px solid var(--cpl-sidebar-border-color);
|
|
405
448
|
`;
|
|
406
|
-
var StickyCloseButton =
|
|
449
|
+
var StickyCloseButton = styled5.div`
|
|
407
450
|
z-index: 10;
|
|
408
451
|
position: sticky;
|
|
409
452
|
top: 0;
|
|
410
453
|
display: flex;
|
|
411
454
|
justify-content: flex-end;
|
|
412
|
-
padding: ${
|
|
455
|
+
padding: ${tokens5.spacings.comfortable.xx_small};
|
|
413
456
|
background-color: var(--cpl-ui-background-temporary-nav);
|
|
414
457
|
border-bottom: ${({ $showBorder }) => $showBorder ? "1px solid var(--cpl-divider-color)" : "0"};
|
|
415
458
|
`;
|
|
@@ -417,10 +460,10 @@ var StickyCloseButton = styled4.div`
|
|
|
417
460
|
// src/UserMenu/UserMenu.tsx
|
|
418
461
|
import { Button as Button3, Icon as Icon5, Menu } from "@equinor/eds-core-react";
|
|
419
462
|
import { log_out, settings } from "@equinor/eds-icons";
|
|
420
|
-
import { tokens as
|
|
463
|
+
import { tokens as tokens6 } from "@equinor/eds-tokens";
|
|
421
464
|
import { useState as useState2 } from "react";
|
|
422
|
-
import
|
|
423
|
-
import { Fragment as Fragment2, jsx as
|
|
465
|
+
import styled6 from "styled-components";
|
|
466
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
424
467
|
function UserMenu({ user, logout, settingsLink, children }) {
|
|
425
468
|
var _a, _b, _c, _d, _e;
|
|
426
469
|
const [isOpen, setIsOpen] = useState2(false);
|
|
@@ -433,20 +476,20 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
433
476
|
};
|
|
434
477
|
const LogOutMenuItem = () => {
|
|
435
478
|
if (typeof logout === "string") {
|
|
436
|
-
return /* @__PURE__ */
|
|
437
|
-
/* @__PURE__ */
|
|
438
|
-
/* @__PURE__ */
|
|
479
|
+
return /* @__PURE__ */ jsxs7(Menu.Item, { as: "a", href: logout, className: "menu-item", id: "logout-button", children: [
|
|
480
|
+
/* @__PURE__ */ jsx7(Icon5, { data: log_out }),
|
|
481
|
+
/* @__PURE__ */ jsx7("span", { children: "Log out" })
|
|
439
482
|
] });
|
|
440
483
|
} else {
|
|
441
|
-
return /* @__PURE__ */
|
|
442
|
-
/* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */
|
|
484
|
+
return /* @__PURE__ */ jsxs7(Menu.Item, { as: "button", onClick: logout, className: "menu-item", id: "logout-button", children: [
|
|
485
|
+
/* @__PURE__ */ jsx7(Icon5, { data: log_out }),
|
|
486
|
+
/* @__PURE__ */ jsx7("span", { children: "Log out" })
|
|
444
487
|
] });
|
|
445
488
|
}
|
|
446
489
|
};
|
|
447
490
|
const firstLetter = (_c = (_b = (_a = user == null ? void 0 : user.email) == null ? void 0 : _a[0]) == null ? void 0 : _b.toUpperCase()) != null ? _c : "-";
|
|
448
|
-
return /* @__PURE__ */
|
|
449
|
-
/* @__PURE__ */
|
|
491
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
492
|
+
/* @__PURE__ */ jsx7(
|
|
450
493
|
StyledUserButton,
|
|
451
494
|
{
|
|
452
495
|
id: "user-button",
|
|
@@ -459,7 +502,7 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
459
502
|
children: firstLetter
|
|
460
503
|
}
|
|
461
504
|
),
|
|
462
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ jsxs7(
|
|
463
506
|
MenuWrapper,
|
|
464
507
|
{
|
|
465
508
|
id: "user-menu",
|
|
@@ -469,16 +512,16 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
469
512
|
anchorEl,
|
|
470
513
|
style: { padding: 0, paddingBottom: 2 },
|
|
471
514
|
children: [
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
-
/* @__PURE__ */
|
|
474
|
-
isOpen && /* @__PURE__ */
|
|
475
|
-
/* @__PURE__ */
|
|
476
|
-
/* @__PURE__ */
|
|
515
|
+
/* @__PURE__ */ jsxs7(IconAndTextWrapper, { children: [
|
|
516
|
+
/* @__PURE__ */ jsx7(LetterCircle, { children: firstLetter }),
|
|
517
|
+
isOpen && /* @__PURE__ */ jsxs7("div", { children: [
|
|
518
|
+
/* @__PURE__ */ jsx7("div", { style: { fontWeight: "bold", lineHeight: 0.9, marginBottom: 2 }, children: (_d = user == null ? void 0 : user.name) != null ? _d : "-" }),
|
|
519
|
+
/* @__PURE__ */ jsx7("div", { children: (_e = user == null ? void 0 : user.email) != null ? _e : "-" })
|
|
477
520
|
] })
|
|
478
521
|
] }),
|
|
479
|
-
settingsLink && /* @__PURE__ */
|
|
480
|
-
/* @__PURE__ */
|
|
481
|
-
/* @__PURE__ */
|
|
522
|
+
settingsLink && /* @__PURE__ */ jsxs7(Menu.Item, { as: "a", href: settingsLink, className: "menu-item", children: [
|
|
523
|
+
/* @__PURE__ */ jsx7(Icon5, { data: settings }),
|
|
524
|
+
/* @__PURE__ */ jsx7("span", { children: "Settings" })
|
|
482
525
|
] }),
|
|
483
526
|
LogOutMenuItem(),
|
|
484
527
|
children
|
|
@@ -487,25 +530,25 @@ function UserMenu({ user, logout, settingsLink, children }) {
|
|
|
487
530
|
)
|
|
488
531
|
] });
|
|
489
532
|
}
|
|
490
|
-
var MenuWrapper =
|
|
491
|
-
border-radius: ${
|
|
492
|
-
margin-top: ${
|
|
493
|
-
margin-bottom: -${
|
|
494
|
-
padding-bottom: ${
|
|
533
|
+
var MenuWrapper = styled6(Menu)`
|
|
534
|
+
border-radius: ${tokens6.shape.corners.borderRadius};
|
|
535
|
+
margin-top: ${tokens6.spacings.comfortable.small};
|
|
536
|
+
margin-bottom: -${tokens6.spacings.comfortable.small};
|
|
537
|
+
padding-bottom: ${tokens6.spacings.comfortable.small};
|
|
495
538
|
padding-left: 0;
|
|
496
539
|
padding-right: 0;
|
|
497
|
-
padding-top: ${
|
|
540
|
+
padding-top: ${tokens6.spacings.comfortable.small};
|
|
498
541
|
width: 315px;
|
|
499
542
|
|
|
500
543
|
background: var(--cpl-ui-background-temporary-nav, #fff);
|
|
501
|
-
color: ${
|
|
544
|
+
color: ${tokens6.colors.text.static_icons__default.rgba};
|
|
502
545
|
|
|
503
546
|
.menu-item {
|
|
504
547
|
align-items: center;
|
|
505
548
|
display: flex;
|
|
506
|
-
gap: ${
|
|
549
|
+
gap: ${tokens6.spacings.comfortable.medium};
|
|
507
550
|
opacity: 0.85;
|
|
508
|
-
padding: ${
|
|
551
|
+
padding: ${tokens6.spacings.comfortable.small} ${tokens6.spacings.comfortable.large};
|
|
509
552
|
|
|
510
553
|
svg {
|
|
511
554
|
opacity: 0.7;
|
|
@@ -520,7 +563,7 @@ var MenuWrapper = styled5(Menu)`
|
|
|
520
563
|
}
|
|
521
564
|
}
|
|
522
565
|
`;
|
|
523
|
-
var LetterCircle =
|
|
566
|
+
var LetterCircle = styled6.span`
|
|
524
567
|
align-items: center;
|
|
525
568
|
border-radius: 1000px;
|
|
526
569
|
display: flex;
|
|
@@ -529,16 +572,16 @@ var LetterCircle = styled5.span`
|
|
|
529
572
|
height: 32px;
|
|
530
573
|
justify-content: center;
|
|
531
574
|
width: 32px;
|
|
532
|
-
background-color: ${
|
|
533
|
-
color: ${
|
|
575
|
+
background-color: ${tokens6.colors.interactive.primary__resting.rgba};
|
|
576
|
+
color: ${tokens6.colors.text.static_icons__primary_white.rgba};
|
|
534
577
|
`;
|
|
535
|
-
var StyledUserButton =
|
|
578
|
+
var StyledUserButton = styled6(Button3)`
|
|
536
579
|
margin-left: 12px;
|
|
537
580
|
font-weight: bold;
|
|
538
581
|
width: 32px;
|
|
539
582
|
height: 32px;
|
|
540
583
|
`;
|
|
541
|
-
var IconAndTextWrapper =
|
|
584
|
+
var IconAndTextWrapper = styled6(Menu.Item)`
|
|
542
585
|
display: flex;
|
|
543
586
|
gap: 12px;
|
|
544
587
|
padding: 12px 20px;
|
|
@@ -553,8 +596,10 @@ var IconAndTextWrapper = styled5(Menu.Item)`
|
|
|
553
596
|
`;
|
|
554
597
|
export {
|
|
555
598
|
FeedbackLink,
|
|
599
|
+
MenuHeader,
|
|
556
600
|
SideMenu,
|
|
557
601
|
StyledLink,
|
|
558
602
|
TopBar,
|
|
559
|
-
UserMenu
|
|
603
|
+
UserMenu,
|
|
604
|
+
useAppUrlByNameAndEnvironment
|
|
560
605
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/cpl-top-bar-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@equinor/eds-icons": "^0.21.0",
|
|
13
13
|
"@equinor/eds-tokens": "^0.9.2",
|
|
14
|
-
"@equinor/cpl-env-meta-bar-react": "0.1.
|
|
14
|
+
"@equinor/cpl-env-meta-bar-react": "0.1.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@equinor/eds-core-react": "^0.42.5",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"react-dom": "^18.2.0",
|
|
25
25
|
"styled-components": "^6.1.14",
|
|
26
26
|
"tsup": "^8.3.6",
|
|
27
|
-
"@equinor/cpl-
|
|
28
|
-
"@equinor/cpl-
|
|
27
|
+
"@equinor/cpl-typescript-config": "0.0.2",
|
|
28
|
+
"@equinor/cpl-eslint-config": "0.0.8"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@equinor/eds-core-react": ">=0.42.1",
|