@equinor/cpl-top-bar-react 0.1.0 → 0.2.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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +24 -13
- package/dist/index.mjs +24 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -13,15 +13,15 @@ interface TopBarProps {
|
|
|
13
13
|
declare function TopBar({ appName, logoLink, documentationLink, documentationName, userMenu, darkMode, logoPath, logoAlt, }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
interface UserMenuProps {
|
|
16
|
-
|
|
17
|
-
darkMode?: boolean;
|
|
16
|
+
logout: string | (() => void);
|
|
18
17
|
user: {
|
|
19
18
|
name: string;
|
|
20
19
|
email: string;
|
|
21
20
|
};
|
|
21
|
+
darkMode?: boolean;
|
|
22
22
|
settingsLink?: string;
|
|
23
23
|
children?: React.ReactNode;
|
|
24
24
|
}
|
|
25
|
-
declare function UserMenu({ user,
|
|
25
|
+
declare function UserMenu({ user, logout, darkMode, settingsLink, children, }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
26
26
|
|
|
27
27
|
export { TopBar, UserMenu };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,15 @@ interface TopBarProps {
|
|
|
13
13
|
declare function TopBar({ appName, logoLink, documentationLink, documentationName, userMenu, darkMode, logoPath, logoAlt, }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
14
14
|
|
|
15
15
|
interface UserMenuProps {
|
|
16
|
-
|
|
17
|
-
darkMode?: boolean;
|
|
16
|
+
logout: string | (() => void);
|
|
18
17
|
user: {
|
|
19
18
|
name: string;
|
|
20
19
|
email: string;
|
|
21
20
|
};
|
|
21
|
+
darkMode?: boolean;
|
|
22
22
|
settingsLink?: string;
|
|
23
23
|
children?: React.ReactNode;
|
|
24
24
|
}
|
|
25
|
-
declare function UserMenu({ user,
|
|
25
|
+
declare function UserMenu({ user, logout, darkMode, settingsLink, children, }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
26
26
|
|
|
27
27
|
export { TopBar, UserMenu };
|
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ var import_styled_components2 = __toESM(require("styled-components"));
|
|
|
110
110
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
111
111
|
function UserMenu({
|
|
112
112
|
user,
|
|
113
|
-
|
|
113
|
+
logout,
|
|
114
114
|
darkMode = false,
|
|
115
115
|
settingsLink,
|
|
116
116
|
children
|
|
@@ -124,6 +124,19 @@ function UserMenu({
|
|
|
124
124
|
const closeMenu = () => {
|
|
125
125
|
setIsOpen(false);
|
|
126
126
|
};
|
|
127
|
+
const LogOutMenuItem = () => {
|
|
128
|
+
if (typeof logout === "string") {
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_eds_core_react2.Menu.Item, { as: "a", href: logout, className: "menu-item", children: [
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_eds_core_react2.Icon, { data: import_eds_icons2.log_out }),
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Log out" })
|
|
132
|
+
] });
|
|
133
|
+
} else {
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_eds_core_react2.Menu.Item, { as: "button", onClick: logout, className: "menu-item", children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_eds_core_react2.Icon, { data: import_eds_icons2.log_out }),
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Log out" })
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
};
|
|
127
140
|
const firstLetter = (_c = (_b = (_a = user == null ? void 0 : user.email) == null ? void 0 : _a[0]) == null ? void 0 : _b.toUpperCase()) != null ? _c : "-";
|
|
128
141
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
129
142
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -162,10 +175,7 @@ function UserMenu({
|
|
|
162
175
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_eds_core_react2.Icon, { data: import_eds_icons2.settings }),
|
|
163
176
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Settings" })
|
|
164
177
|
] }),
|
|
165
|
-
|
|
166
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_eds_core_react2.Icon, { data: import_eds_icons2.log_out }),
|
|
167
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Log out" })
|
|
168
|
-
] }),
|
|
178
|
+
LogOutMenuItem(),
|
|
169
179
|
children
|
|
170
180
|
]
|
|
171
181
|
}
|
|
@@ -199,7 +209,7 @@ var MenuWrapper = (0, import_styled_components2.default)(import_eds_core_react2.
|
|
|
199
209
|
}
|
|
200
210
|
}
|
|
201
211
|
${({ $darkMode }) => $darkMode ? import_styled_components2.css`
|
|
202
|
-
background: #3e4f5c;
|
|
212
|
+
background: #3e4f5c; //TODO: get color from token in the future
|
|
203
213
|
color: #fff;
|
|
204
214
|
.menu-item {
|
|
205
215
|
color: #fff;
|
|
@@ -218,10 +228,12 @@ var LetterCircle = import_styled_components2.default.span`
|
|
|
218
228
|
height: 32px;
|
|
219
229
|
justify-content: center;
|
|
220
230
|
width: 32px;
|
|
231
|
+
background-color: ${import_eds_tokens2.tokens.colors.interactive.primary__resting.hex};
|
|
232
|
+
color: #fff;
|
|
221
233
|
${({ $darkMode }) => $darkMode ? import_styled_components2.css`
|
|
222
234
|
background: ${import_eds_tokens2.tokens.colors.interactive.link_in_snackbars.hex};
|
|
223
235
|
color: ${import_eds_tokens2.tokens.colors.interactive.table__cell__fill_resting.hex};
|
|
224
|
-
` : ``}
|
|
236
|
+
` : ``};
|
|
225
237
|
`;
|
|
226
238
|
var StyledUserButton = (0, import_styled_components2.default)(import_eds_core_react2.Button)`
|
|
227
239
|
margin: 10px 12px;
|
|
@@ -243,13 +255,12 @@ var IconAndTextWrapper = (0, import_styled_components2.default)(import_eds_core_
|
|
|
243
255
|
padding: 12px 20px;
|
|
244
256
|
width: 315px;
|
|
245
257
|
color: inherit;
|
|
246
|
-
&:hover
|
|
258
|
+
&:hover,
|
|
259
|
+
&:focus,
|
|
260
|
+
&:active {
|
|
261
|
+
background-color: transparent;
|
|
262
|
+
cursor: default;
|
|
247
263
|
}
|
|
248
|
-
${({ $darkMode }) => $darkMode ? import_styled_components2.css`
|
|
249
|
-
&:hover {
|
|
250
|
-
background: #305c75; //TODO: get color from token in the future
|
|
251
|
-
}
|
|
252
|
-
` : ""}
|
|
253
264
|
`;
|
|
254
265
|
// Annotate the CommonJS export names for ESM import in node:
|
|
255
266
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -73,7 +73,7 @@ import styled2, { css as css2 } from "styled-components";
|
|
|
73
73
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
74
74
|
function UserMenu({
|
|
75
75
|
user,
|
|
76
|
-
|
|
76
|
+
logout,
|
|
77
77
|
darkMode = false,
|
|
78
78
|
settingsLink,
|
|
79
79
|
children
|
|
@@ -87,6 +87,19 @@ function UserMenu({
|
|
|
87
87
|
const closeMenu = () => {
|
|
88
88
|
setIsOpen(false);
|
|
89
89
|
};
|
|
90
|
+
const LogOutMenuItem = () => {
|
|
91
|
+
if (typeof logout === "string") {
|
|
92
|
+
return /* @__PURE__ */ jsxs2(Menu.Item, { as: "a", href: logout, className: "menu-item", children: [
|
|
93
|
+
/* @__PURE__ */ jsx2(Icon2, { data: log_out }),
|
|
94
|
+
/* @__PURE__ */ jsx2("span", { children: "Log out" })
|
|
95
|
+
] });
|
|
96
|
+
} else {
|
|
97
|
+
return /* @__PURE__ */ jsxs2(Menu.Item, { as: "button", onClick: logout, className: "menu-item", children: [
|
|
98
|
+
/* @__PURE__ */ jsx2(Icon2, { data: log_out }),
|
|
99
|
+
/* @__PURE__ */ jsx2("span", { children: "Log out" })
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
102
|
+
};
|
|
90
103
|
const firstLetter = (_c = (_b = (_a = user == null ? void 0 : user.email) == null ? void 0 : _a[0]) == null ? void 0 : _b.toUpperCase()) != null ? _c : "-";
|
|
91
104
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
92
105
|
/* @__PURE__ */ jsx2(
|
|
@@ -125,10 +138,7 @@ function UserMenu({
|
|
|
125
138
|
/* @__PURE__ */ jsx2(Icon2, { data: settings }),
|
|
126
139
|
/* @__PURE__ */ jsx2("span", { children: "Settings" })
|
|
127
140
|
] }),
|
|
128
|
-
|
|
129
|
-
/* @__PURE__ */ jsx2(Icon2, { data: log_out }),
|
|
130
|
-
/* @__PURE__ */ jsx2("span", { children: "Log out" })
|
|
131
|
-
] }),
|
|
141
|
+
LogOutMenuItem(),
|
|
132
142
|
children
|
|
133
143
|
]
|
|
134
144
|
}
|
|
@@ -162,7 +172,7 @@ var MenuWrapper = styled2(Menu)`
|
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
174
|
${({ $darkMode }) => $darkMode ? css2`
|
|
165
|
-
background: #3e4f5c;
|
|
175
|
+
background: #3e4f5c; //TODO: get color from token in the future
|
|
166
176
|
color: #fff;
|
|
167
177
|
.menu-item {
|
|
168
178
|
color: #fff;
|
|
@@ -181,10 +191,12 @@ var LetterCircle = styled2.span`
|
|
|
181
191
|
height: 32px;
|
|
182
192
|
justify-content: center;
|
|
183
193
|
width: 32px;
|
|
194
|
+
background-color: ${tokens2.colors.interactive.primary__resting.hex};
|
|
195
|
+
color: #fff;
|
|
184
196
|
${({ $darkMode }) => $darkMode ? css2`
|
|
185
197
|
background: ${tokens2.colors.interactive.link_in_snackbars.hex};
|
|
186
198
|
color: ${tokens2.colors.interactive.table__cell__fill_resting.hex};
|
|
187
|
-
` : ``}
|
|
199
|
+
` : ``};
|
|
188
200
|
`;
|
|
189
201
|
var StyledUserButton = styled2(Button)`
|
|
190
202
|
margin: 10px 12px;
|
|
@@ -206,13 +218,12 @@ var IconAndTextWrapper = styled2(Menu.Item)`
|
|
|
206
218
|
padding: 12px 20px;
|
|
207
219
|
width: 315px;
|
|
208
220
|
color: inherit;
|
|
209
|
-
&:hover
|
|
221
|
+
&:hover,
|
|
222
|
+
&:focus,
|
|
223
|
+
&:active {
|
|
224
|
+
background-color: transparent;
|
|
225
|
+
cursor: default;
|
|
210
226
|
}
|
|
211
|
-
${({ $darkMode }) => $darkMode ? css2`
|
|
212
|
-
&:hover {
|
|
213
|
-
background: #305c75; //TODO: get color from token in the future
|
|
214
|
-
}
|
|
215
|
-
` : ""}
|
|
216
227
|
`;
|
|
217
228
|
export {
|
|
218
229
|
TopBar,
|