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