@learningpool/ui 1.6.0-beta.5 → 1.6.0-beta.6
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/components/navigation/VerticalNavigation/VerticalNavigation.d.ts +12 -0
- package/components/navigation/VerticalNavigation/VerticalNavigation.js +14 -3
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatar.d.ts +24 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatar.js +84 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.d.ts +827 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.js +31 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItem.d.ts +1 -1
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenuStyles.js +12 -9
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemStyles.js +12 -13
- package/components/navigation/VerticalNavigation/VerticalNavigationMotion.d.ts +141 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationMotion.js +109 -0
- package/components/navigation/VerticalNavigation/VerticalNavigationStyles.js +16 -15
- package/package.json +1 -1
- package/components/navigation/VerticalNavigation/AvatarPanel.d.ts +0 -8
- package/components/navigation/VerticalNavigation/AvatarPanel.js +0 -97
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IVerticalNavigationItemProps } from './VerticalNavigationItem/VerticalNavigationItem';
|
|
3
|
+
import { IAvatarMenuItemProps } from './VerticalNavigationAvatar';
|
|
3
4
|
interface VerticalNavigationProps {
|
|
4
5
|
logo?: string;
|
|
5
6
|
logoText?: string;
|
|
@@ -15,6 +16,17 @@ interface VerticalNavigationProps {
|
|
|
15
16
|
isPersistent?: boolean;
|
|
16
17
|
setIsPersistent?: any;
|
|
17
18
|
appRootID?: string;
|
|
19
|
+
hasAvatar?: boolean;
|
|
20
|
+
avatarPanelOnClickSwitchDirection?: any;
|
|
21
|
+
avatarPanelOnClickLogout?: any;
|
|
22
|
+
avatarPanelOnClickViewProfile?: any;
|
|
23
|
+
avatarPanelViewProfileString?: string;
|
|
24
|
+
avatarPanelOnClickEditProfile?: any;
|
|
25
|
+
avatarPanelEditProfileString?: string;
|
|
26
|
+
avatarPanelMenuItems?: Array<IAvatarMenuItemProps>;
|
|
27
|
+
avatarPanelOnClickMainAction?: any;
|
|
28
|
+
avatarPanelMainActionString?: string;
|
|
29
|
+
avatarPanelSettingItems?: Array<IAvatarMenuItemProps>;
|
|
18
30
|
}
|
|
19
31
|
declare const VerticalNavigation: (props: VerticalNavigationProps) => React.ReactElement;
|
|
20
32
|
export default VerticalNavigation;
|
|
@@ -9,6 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
24
|
import React, { useEffect } from 'react';
|
|
14
25
|
import { useTheme } from '@mui/material/styles';
|
|
@@ -20,14 +31,14 @@ import { ChevronLeft, ChevronRight, PushPin } from '@mui/icons-material';
|
|
|
20
31
|
import VerticalNavigationItem from './VerticalNavigationItem/VerticalNavigationItem';
|
|
21
32
|
import { DRAWER_WIDTH, DrawerHeader, DrawerToggle, DrawerToggleHitboxContent, StyledDivider, StyledNav, StyledNavSecondary, DrawerShadow, StyledAside, NotchContainer, NotchBackground, NotchBackgroundClip, NotchSeemMask, StyledDrawer } from './VerticalNavigationStyles';
|
|
22
33
|
import { ListItem, ListItemButton, ListItemIcon, ListItemText } from './VerticalNavigationItem/VerticalNavigationItemStyles';
|
|
23
|
-
import AvatarPanel from './
|
|
34
|
+
import AvatarPanel from './VerticalNavigationAvatar';
|
|
24
35
|
import { motion } from '../../../utils/theme';
|
|
25
36
|
import { handleAvatarInitials } from '../../../utils/helpers';
|
|
26
37
|
import { DEFAULT_REACT_APP_ID } from '../../../utils/constants';
|
|
27
38
|
var VerticalNavigation = function (props) {
|
|
28
39
|
var _a, _b;
|
|
29
40
|
var theme = useTheme();
|
|
30
|
-
var items = props.items, secondaryItems = props.secondaryItems, logo = props.logo, logoText = props.logoText, logoOnClick = props.logoOnClick, appRootID = props.appRootID, hasStreamHome = props.hasStreamHome, streamHomeApiKey = props.streamHomeApiKey, streamHomeBaseUrl = props.streamHomeBaseUrl, streamHomeAccessToken = props.streamHomeAccessToken;
|
|
41
|
+
var items = props.items, secondaryItems = props.secondaryItems, logo = props.logo, logoText = props.logoText, logoOnClick = props.logoOnClick, appRootID = props.appRootID, hasStreamHome = props.hasStreamHome, streamHomeApiKey = props.streamHomeApiKey, streamHomeBaseUrl = props.streamHomeBaseUrl, streamHomeAccessToken = props.streamHomeAccessToken, rest = __rest(props, ["items", "secondaryItems", "logo", "logoText", "logoOnClick", "appRootID", "hasStreamHome", "streamHomeApiKey", "streamHomeBaseUrl", "streamHomeAccessToken"]);
|
|
31
42
|
var propIsDrawerOpen = typeof (props === null || props === void 0 ? void 0 : props.isDrawerOpen) === 'boolean' ? props.isDrawerOpen : undefined;
|
|
32
43
|
var propIsPersistent = typeof (props === null || props === void 0 ? void 0 : props.isPersistent) === 'boolean' ? props.isPersistent : undefined;
|
|
33
44
|
var avatarName = (_a = props === null || props === void 0 ? void 0 : props.avatarName) !== null && _a !== void 0 ? _a : 'Avatar name';
|
|
@@ -200,7 +211,7 @@ var VerticalNavigation = function (props) {
|
|
|
200
211
|
padding: 0,
|
|
201
212
|
minHeight: 52,
|
|
202
213
|
transition: "max-height 225ms ".concat(motion.easeInOut, " 0ms !important")
|
|
203
|
-
}, hasFlyout: true, fullHeightFlyout: true, content: _jsx(AvatarPanel, { avatarName: avatarName }), isDrawerOpen: isDrawerOpen }))
|
|
214
|
+
}, hasFlyout: true, fullHeightFlyout: true, content: _jsx(AvatarPanel, __assign({ avatarName: avatarName }, rest)), isDrawerOpen: isDrawerOpen }))
|
|
204
215
|
: null] }))] })) }))] }))); };
|
|
205
216
|
return (_jsxs(StyledAside, __assign({ "aria-label": "Site navigation" }, { children: [_jsx(DrawerShadow, { className: 'drawerShadow', "aria-hidden": 'true', isDrawerOpen: isDrawerOpen || isPersistent, style: {
|
|
206
217
|
display: isPersistent ? 'none' : 'block'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IAvatarMenuItemProps {
|
|
3
|
+
label: string;
|
|
4
|
+
icon: any;
|
|
5
|
+
onClick: any;
|
|
6
|
+
}
|
|
7
|
+
export interface IAvatarPanelProps {
|
|
8
|
+
avatarName: string;
|
|
9
|
+
editProfileText?: string;
|
|
10
|
+
logoutText?: string;
|
|
11
|
+
avatarPanelOnClickSwitchDirection?: any;
|
|
12
|
+
avatarPanelOnClickLogout?: any;
|
|
13
|
+
avatarPanelOnClickViewProfile?: any;
|
|
14
|
+
avatarPanelViewProfileString?: string;
|
|
15
|
+
avatarPanelOnClickEditProfile?: any;
|
|
16
|
+
avatarPanelEditProfileString?: string;
|
|
17
|
+
avatarPanelMenuItems?: Array<IAvatarMenuItemProps>;
|
|
18
|
+
avatarPanelOnClickMainAction?: any;
|
|
19
|
+
avatarPanelMainActionString?: string;
|
|
20
|
+
avatarPanelSettingItems?: Array<IAvatarMenuItemProps>;
|
|
21
|
+
avatarPanelInvertNavString?: string;
|
|
22
|
+
}
|
|
23
|
+
declare const AvatarPanel: (props: IAvatarPanelProps) => React.ReactElement;
|
|
24
|
+
export default AvatarPanel;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import React, { useEffect } from 'react';
|
|
14
|
+
import { Box, ButtonGroup, Button, Link, List, ListItem, ListItemIcon, ListItemText } from '../../../index';
|
|
15
|
+
import { StyledBox, StyledBoxProfile, StyledAvatarName, StyledAvatar, StyledOutlineButton, StyledBoxProfileEdit, StyledListItemButton } from './VerticalNavigationAvatarStyles';
|
|
16
|
+
import { useTheme } from '@mui/material/styles';
|
|
17
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
18
|
+
import LogoutIcon from '@mui/icons-material/Logout';
|
|
19
|
+
import { motion } from 'framer-motion';
|
|
20
|
+
import { motionParent, motionFadeIn, motionFadeInUp, motionWhileHover, motionWhileTap } from './VerticalNavigationMotion';
|
|
21
|
+
import { handleAvatarInitials } from '../../../utils/helpers';
|
|
22
|
+
import { Person, Settings } from '@mui/icons-material';
|
|
23
|
+
var AvatarPanel = function (props) {
|
|
24
|
+
var _a;
|
|
25
|
+
var theme = useTheme();
|
|
26
|
+
var avatarName = props.avatarName, avatarPanelOnClickLogout = props.avatarPanelOnClickLogout, logoutText = props.logoutText, avatarPanelOnClickViewProfile = props.avatarPanelOnClickViewProfile, avatarPanelViewProfileString = props.avatarPanelViewProfileString, avatarPanelOnClickEditProfile = props.avatarPanelOnClickEditProfile, avatarPanelEditProfileString = props.avatarPanelEditProfileString, avatarPanelMenuItems = props.avatarPanelMenuItems, avatarPanelOnClickMainAction = props.avatarPanelOnClickMainAction, avatarPanelMainActionString = props.avatarPanelMainActionString, avatarPanelSettingItems = props.avatarPanelSettingItems;
|
|
27
|
+
useEffect(function () { return setAvatarInitials(handleAvatarInitials(avatarName)); }, [
|
|
28
|
+
avatarName
|
|
29
|
+
]);
|
|
30
|
+
var _b = React.useState((_a = handleAvatarInitials(avatarName)) !== null && _a !== void 0 ? _a : 'AN'), avatarInitials = _b[0], setAvatarInitials = _b[1];
|
|
31
|
+
return (_jsxs(StyledBox
|
|
32
|
+
// TODO: add check for isAvatarOpen to trigger animation effects
|
|
33
|
+
// animate={ isAvatarOpen ? 'open' : 'closed' }
|
|
34
|
+
, __assign({
|
|
35
|
+
// TODO: add check for isAvatarOpen to trigger animation effects
|
|
36
|
+
// animate={ isAvatarOpen ? 'open' : 'closed' }
|
|
37
|
+
variants: motionParent }, { children: [avatarPanelOnClickLogout && (_jsx(Button
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
, __assign({
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
component: motion.button, variants: motionFadeIn, style: {
|
|
42
|
+
left: theme.direction === 'rtl' ? theme.spacing(1) : 'auto',
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
right: theme.direction === 'rtl' ? 'auto' : theme.spacing(1),
|
|
45
|
+
top: theme.spacing(1)
|
|
46
|
+
}, onClick: avatarPanelOnClickLogout, startIcon: _jsx(LogoutIcon, {}), variant: 'text', color: 'inherit' }, { children: logoutText !== null && logoutText !== void 0 ? logoutText : 'Logout' }))), _jsxs(Box, __assign({ style: {
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexDirection: 'column'
|
|
50
|
+
} }, { children: [_jsxs(StyledBoxProfile, __assign({ variants: motionFadeInUp }, { children: [_jsx(StyledAvatar, __assign({ style: { marginRight: '0.5rem' } }, { children: avatarInitials })), _jsxs(StyledAvatarName, { children: [_jsx("span", __assign({ style: { fontWeight: 300 } }, { children: "Hi," })), " ", _jsx("strong", { children: avatarName.split(' ')[0] })] })] })), avatarPanelOnClickViewProfile && (_jsx(StyledBoxProfileEdit, __assign({ variants: motionFadeInUp, style: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
marginBottom: theme.spacing(1)
|
|
53
|
+
} }, { children: _jsxs(ButtonGroup, __assign({ variant: "contained", "aria-label": "split button" }, { children: [_jsx(Button, __assign({ variant: 'contained', color: 'primary', size: 'medium', onClick: avatarPanelOnClickViewProfile, startIcon: _jsx(Person, {}) }, { children: avatarPanelViewProfileString !== null && avatarPanelViewProfileString !== void 0 ? avatarPanelViewProfileString : 'View Profile' })), avatarPanelOnClickEditProfile && (_jsx(Button, __assign({ size: 'medium', "aria-label": avatarPanelEditProfileString !== null && avatarPanelEditProfileString !== void 0 ? avatarPanelEditProfileString : 'Edit Profile', onClick: avatarPanelOnClickEditProfile }, { children: _jsx(EditIcon, {}) })))] })) })))] })), _jsxs(Box, __assign({ style: {
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
flexDirection: 'column'
|
|
57
|
+
} }, { children: [avatarPanelMenuItems && avatarPanelMenuItems.length > 0 && (_jsx(List, __assign({ style: {
|
|
58
|
+
marginBottom: theme.spacing(2),
|
|
59
|
+
maxWidth: '14rem'
|
|
60
|
+
} }, { children: avatarPanelMenuItems.map(function (avatarMenuItem) { return (_jsx(ListItem, __assign({ component: motion.div, variants: motionFadeInUp, whileHover: motionWhileHover, whileTap: motionWhileTap, disablePadding: true }, { children: _jsxs(StyledListItemButton
|
|
61
|
+
// TODO: figure out if these are links or buttons
|
|
62
|
+
// @ts-expect-error
|
|
63
|
+
, __assign({
|
|
64
|
+
// TODO: figure out if these are links or buttons
|
|
65
|
+
// @ts-expect-error
|
|
66
|
+
component: Link, role: 'link', onClick: avatarMenuItem.onClick }, { children: [_jsx(ListItemIcon, __assign({ "aria-hidden": true, style: {
|
|
67
|
+
minWidth: theme.spacing(5)
|
|
68
|
+
} }, { children: avatarMenuItem.icon })), _jsx(ListItemText, { primary: avatarMenuItem.label })] })) }))); }) }))), avatarPanelOnClickMainAction && _jsx(StyledOutlineButton
|
|
69
|
+
// @ts-expect-error
|
|
70
|
+
, __assign({
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
component: motion.button, variants: motionFadeInUp, disablePadding: true, variant: 'outlined', color: 'primary', size: 'medium', onClick: avatarPanelOnClickMainAction, startIcon: _jsx(Settings, {}) }, { children: avatarPanelMainActionString })), _jsx(List, __assign({ style: { marginBottom: theme.spacing(2) } }, { children: avatarPanelSettingItems &&
|
|
73
|
+
avatarPanelSettingItems.length > 0 &&
|
|
74
|
+
avatarPanelSettingItems.map(function (avatarMenuItem) { return (_jsx(ListItem, __assign({ component: motion.div, variants: motionFadeInUp, whileHover: motionWhileHover, whileTap: motionWhileTap, disablePadding: true }, { children: _jsxs(StyledListItemButton
|
|
75
|
+
// TODO: figure out if these are links or buttons
|
|
76
|
+
// @ts-expect-error
|
|
77
|
+
, __assign({
|
|
78
|
+
// TODO: figure out if these are links or buttons
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
component: Link, role: 'link', onClick: avatarMenuItem.onClick }, { children: [_jsx(ListItemIcon, __assign({ "aria-hidden": true, style: {
|
|
81
|
+
minWidth: theme.spacing(5)
|
|
82
|
+
} }, { children: avatarMenuItem.icon })), _jsx(ListItemText, { primary: avatarMenuItem.label })] })) }))); }) }))] }))] })));
|
|
83
|
+
};
|
|
84
|
+
export default AvatarPanel;
|