@instructure/ui-global-nav 11.7.11-snapshot-34 → 11.7.11-snapshot-36
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/CHANGELOG.md +2 -1
- package/es/GlobalNav/v1/AccountItem/index.js +131 -0
- package/es/GlobalNav/v1/AccountItem/props.js +1 -0
- package/es/GlobalNav/v1/AccountItem/styles.js +132 -0
- package/es/GlobalNav/v1/AccountPanel/index.js +189 -0
- package/es/GlobalNav/v1/AccountPanel/props.js +1 -0
- package/es/GlobalNav/v1/AccountPanel/styles.js +156 -0
- package/es/GlobalNav/v1/SubNavItem/index.js +12 -5
- package/es/GlobalNav/v1/SubNavItem/styles.js +10 -4
- package/es/GlobalNav/v1/index.js +54 -19
- package/es/GlobalNav/v1/styles.js +8 -0
- package/lib/GlobalNav/v1/AccountItem/index.js +136 -0
- package/lib/GlobalNav/v1/AccountItem/props.js +5 -0
- package/lib/GlobalNav/v1/AccountItem/styles.js +138 -0
- package/lib/GlobalNav/v1/AccountPanel/index.js +194 -0
- package/lib/GlobalNav/v1/AccountPanel/props.js +5 -0
- package/lib/GlobalNav/v1/AccountPanel/styles.js +162 -0
- package/lib/GlobalNav/v1/SubNavItem/index.js +11 -4
- package/lib/GlobalNav/v1/SubNavItem/styles.js +10 -4
- package/lib/GlobalNav/v1/index.js +62 -27
- package/lib/GlobalNav/v1/styles.js +8 -0
- package/package.json +20 -15
- package/src/GlobalNav/v1/AccountItem/index.tsx +147 -0
- package/src/GlobalNav/v1/AccountItem/props.ts +68 -0
- package/src/GlobalNav/v1/AccountItem/styles.ts +157 -0
- package/src/GlobalNav/v1/AccountPanel/index.tsx +203 -0
- package/src/GlobalNav/v1/AccountPanel/props.ts +60 -0
- package/src/GlobalNav/v1/AccountPanel/styles.ts +167 -0
- package/src/GlobalNav/v1/README.md +83 -2
- package/src/GlobalNav/v1/SubNavItem/index.tsx +14 -5
- package/src/GlobalNav/v1/SubNavItem/props.ts +12 -5
- package/src/GlobalNav/v1/SubNavItem/styles.ts +15 -3
- package/src/GlobalNav/v1/index.tsx +66 -20
- package/src/GlobalNav/v1/props.ts +67 -10
- package/src/GlobalNav/v1/styles.ts +8 -0
- package/src/exports/a.ts +2 -0
- package/tsconfig.build.json +15 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/GlobalNav/v1/AccountItem/index.d.ts +11 -0
- package/types/GlobalNav/v1/AccountItem/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/AccountItem/props.d.ts +32 -0
- package/types/GlobalNav/v1/AccountItem/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/AccountItem/styles.d.ts +19 -0
- package/types/GlobalNav/v1/AccountItem/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/AccountPanel/index.d.ts +11 -0
- package/types/GlobalNav/v1/AccountPanel/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/AccountPanel/props.d.ts +12 -0
- package/types/GlobalNav/v1/AccountPanel/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/AccountPanel/styles.d.ts +18 -0
- package/types/GlobalNav/v1/AccountPanel/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/index.d.ts.map +1 -1
- package/types/GlobalNav/v1/SubNavItem/props.d.ts +9 -5
- package/types/GlobalNav/v1/SubNavItem/props.d.ts.map +1 -1
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts +1 -0
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts.map +1 -1
- package/types/GlobalNav/v1/index.d.ts.map +1 -1
- package/types/GlobalNav/v1/props.d.ts +59 -11
- package/types/GlobalNav/v1/props.d.ts.map +1 -1
- package/types/GlobalNav/v1/styles.d.ts.map +1 -1
- package/types/exports/a.d.ts +1 -1
- package/types/exports/a.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.7.11-snapshot-
|
|
6
|
+
## [11.7.11-snapshot-36](https://github.com/instructure/instructure-ui/compare/v11.7.10...v11.7.11-snapshot-36) (2026-11-30)
|
|
7
7
|
|
|
8
8
|
### Features
|
|
9
9
|
|
|
10
10
|
* **ui-global-nav:** add GlobalNav package scaffolding ([#2759](https://github.com/instructure/instructure-ui/issues/2759)) ([0441b0d](https://github.com/instructure/instructure-ui/commit/0441b0d8278614206289f20d9c771bc282e68352))
|
|
11
|
+
* **ui-global-nav:** add the account menu ([#2821](https://github.com/instructure/instructure-ui/issues/2821)) ([8ab62d2](https://github.com/instructure/instructure-ui/commit/8ab62d22f29ef5c1f2322701edd02455063e4c97)), closes [#2820](https://github.com/instructure/instructure-ui/issues/2820) [#2819](https://github.com/instructure/instructure-ui/issues/2819) [#2786](https://github.com/instructure/instructure-ui/issues/2786)
|
|
11
12
|
* **ui-global-nav:** add the GlobalNav API types, the collapsible rail, its items and the logo ([#2768](https://github.com/instructure/instructure-ui/issues/2768)) ([5cca5e2](https://github.com/instructure/instructure-ui/commit/5cca5e2e80b4c8a66d7aff309f76535cf596c3d2))
|
|
12
13
|
* **ui-global-nav:** add the SubNav panel ([#2775](https://github.com/instructure/instructure-ui/issues/2775)) ([9c5d56e](https://github.com/instructure/instructure-ui/commit/9c5d56eadc27abd333d475ffdb40494f6c46ec40))
|
|
13
14
|
* **ui-global-nav:** use the design tokens v2.7.0 ([#2820](https://github.com/instructure/instructure-ui/issues/2820)) ([04ed5ea](https://github.com/instructure/instructure-ui/commit/04ed5ea0a520986517f60b8c968c08d8d40bd5d4)), closes [#2786](https://github.com/instructure/instructure-ui/issues/2786) [#2819](https://github.com/instructure/instructure-ui/issues/2819)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useStyleNew } from '@instructure/emotion';
|
|
26
|
+
import { AccessibleContent, ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
27
|
+
import { Avatar } from '@instructure/ui-avatar/latest';
|
|
28
|
+
import { Badge } from '@instructure/ui-badge/latest';
|
|
29
|
+
import { SettingsInstUIIcon, ShieldAlertInstUIIcon } from '@instructure/ui-icons';
|
|
30
|
+
import { Pill } from '@instructure/ui-pill/latest';
|
|
31
|
+
import { Tooltip } from '@instructure/ui-tooltip/latest';
|
|
32
|
+
import generateStyle from './styles.js';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
private: true
|
|
37
|
+
id: GlobalNav.AccountItem
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
41
|
+
const AccountItem = props => {
|
|
42
|
+
const {
|
|
43
|
+
account,
|
|
44
|
+
collapsed,
|
|
45
|
+
open,
|
|
46
|
+
panelId,
|
|
47
|
+
onActivate,
|
|
48
|
+
elementRef
|
|
49
|
+
} = props;
|
|
50
|
+
const current = !!account.current;
|
|
51
|
+
const styles = useStyleNew({
|
|
52
|
+
generateStyle,
|
|
53
|
+
params: {
|
|
54
|
+
collapsed,
|
|
55
|
+
current,
|
|
56
|
+
open
|
|
57
|
+
},
|
|
58
|
+
componentId: 'MainNavAccountItem'
|
|
59
|
+
});
|
|
60
|
+
const badgeCount = account.badgeCount ?? 0;
|
|
61
|
+
const badgeLabel = typeof account.badgeLabel === 'function' ? account.badgeLabel(badgeCount) : account.badgeLabel;
|
|
62
|
+
const formatBadge = formattedCount => badgeLabel ? _jsx(AccessibleContent, {
|
|
63
|
+
alt: badgeLabel,
|
|
64
|
+
children: formattedCount
|
|
65
|
+
}) : formattedCount;
|
|
66
|
+
const avatar = _jsxs("span", {
|
|
67
|
+
css: styles?.avatar,
|
|
68
|
+
children: [_jsx(Avatar, {
|
|
69
|
+
name: account.name,
|
|
70
|
+
src: account.avatarSrc,
|
|
71
|
+
size: "small"
|
|
72
|
+
}), account.verification && _jsx("span", {
|
|
73
|
+
css: styles?.verification,
|
|
74
|
+
children: _jsx(ShieldAlertInstUIIcon, {
|
|
75
|
+
title: account.verification.badgeLabel,
|
|
76
|
+
color: "onColor",
|
|
77
|
+
size: "sm"
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
const content = collapsed ? _jsxs(_Fragment, {
|
|
82
|
+
children: [_jsx(ScreenReaderContent, {
|
|
83
|
+
children: [account.label, account.name, account.userType].filter(Boolean).join(' ')
|
|
84
|
+
}), badgeCount > 0 ? _jsx(Badge, {
|
|
85
|
+
count: badgeCount,
|
|
86
|
+
formatOutput: formatBadge,
|
|
87
|
+
children: avatar
|
|
88
|
+
}) : avatar]
|
|
89
|
+
}) : _jsxs(_Fragment, {
|
|
90
|
+
children: [_jsx(ScreenReaderContent, {
|
|
91
|
+
children: account.label
|
|
92
|
+
}), avatar, _jsx("span", {
|
|
93
|
+
css: styles?.name,
|
|
94
|
+
children: account.name
|
|
95
|
+
}), account.userType && _jsx("span", {
|
|
96
|
+
css: styles?.pill,
|
|
97
|
+
children: _jsx(Pill, {
|
|
98
|
+
color: "info",
|
|
99
|
+
children: account.userType
|
|
100
|
+
})
|
|
101
|
+
}), _jsxs("span", {
|
|
102
|
+
css: styles?.end,
|
|
103
|
+
children: [badgeCount > 0 && _jsx(Badge, {
|
|
104
|
+
standalone: true,
|
|
105
|
+
count: badgeCount,
|
|
106
|
+
formatOutput: formatBadge
|
|
107
|
+
}), _jsx(SettingsInstUIIcon, {})]
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
const element = _jsx("button", {
|
|
111
|
+
...account.elementProps,
|
|
112
|
+
type: "button",
|
|
113
|
+
ref: elementRef,
|
|
114
|
+
css: styles?.item,
|
|
115
|
+
"aria-expanded": open,
|
|
116
|
+
"aria-controls": panelId,
|
|
117
|
+
"aria-current": current ? 'page' : undefined,
|
|
118
|
+
onClick: onActivate,
|
|
119
|
+
children: content
|
|
120
|
+
});
|
|
121
|
+
return collapsed ? _jsx(Tooltip, {
|
|
122
|
+
renderTip: account.name,
|
|
123
|
+
placement: "end",
|
|
124
|
+
children: _jsx("span", {
|
|
125
|
+
css: styles?.tooltipTrigger,
|
|
126
|
+
children: element
|
|
127
|
+
})
|
|
128
|
+
}) : element;
|
|
129
|
+
};
|
|
130
|
+
export default AccountItem;
|
|
131
|
+
export { AccountItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { calcBandFocusStyles } from '../utils/calcBandFocusStyles.js';
|
|
26
|
+
/**
|
|
27
|
+
* ---
|
|
28
|
+
* private: true
|
|
29
|
+
* ---
|
|
30
|
+
* Generates the style object from the theme and provided additional information
|
|
31
|
+
* @param componentTheme The theme variable object.
|
|
32
|
+
* @param params Additional parameters to customize the style.
|
|
33
|
+
* @return The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, params) => {
|
|
36
|
+
const {
|
|
37
|
+
collapsed,
|
|
38
|
+
current,
|
|
39
|
+
open
|
|
40
|
+
} = params;
|
|
41
|
+
return {
|
|
42
|
+
item: {
|
|
43
|
+
label: 'accountItem',
|
|
44
|
+
boxSizing: 'border-box',
|
|
45
|
+
margin: 0,
|
|
46
|
+
...(collapsed ? {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
width: componentTheme.minimizedItemSize,
|
|
51
|
+
height: componentTheme.minimizedItemSize,
|
|
52
|
+
padding: 0,
|
|
53
|
+
border: 'none'
|
|
54
|
+
} : {
|
|
55
|
+
display: 'grid',
|
|
56
|
+
// the DOM order puts the name before the role, for screen readers
|
|
57
|
+
gridTemplateColumns: '1fr auto',
|
|
58
|
+
gridTemplateAreas: '"avatar pill" "name end"',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
gap: componentTheme.padding,
|
|
61
|
+
width: '100%',
|
|
62
|
+
padding: componentTheme.padding,
|
|
63
|
+
// MainNavAccountItem has no border width token
|
|
64
|
+
border: `0.0625rem solid ${componentTheme.borderColor}`
|
|
65
|
+
}),
|
|
66
|
+
borderRadius: componentTheme.borderRadius,
|
|
67
|
+
backgroundColor: current ? componentTheme.currentBackgroundColor : open ? componentTheme.selectedBackgroundColor : componentTheme.backgroundColor,
|
|
68
|
+
color: current ? componentTheme.currentTextColor : componentTheme.textColor,
|
|
69
|
+
fontFamily: componentTheme.titleFontFamily,
|
|
70
|
+
fontSize: componentTheme.titleFontSize,
|
|
71
|
+
fontWeight: componentTheme.fontWeight,
|
|
72
|
+
lineHeight: componentTheme.lineHeight,
|
|
73
|
+
textAlign: 'start',
|
|
74
|
+
cursor: 'pointer',
|
|
75
|
+
...(!current && !open && {
|
|
76
|
+
'&:hover': {
|
|
77
|
+
backgroundColor: componentTheme.hoverBackgroundColor
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
...(current ? calcBandFocusStyles(componentTheme.selectedOuterFocusOutlineColor, componentTheme.selectedInnerFocusOutlineColor) : calcBandFocusStyles(componentTheme.outerFocusOutlineColor, componentTheme.innerFocusOutlineColor))
|
|
81
|
+
},
|
|
82
|
+
avatar: {
|
|
83
|
+
label: 'accountItem__avatar',
|
|
84
|
+
gridArea: 'avatar',
|
|
85
|
+
justifySelf: 'start',
|
|
86
|
+
position: 'relative',
|
|
87
|
+
display: 'flex'
|
|
88
|
+
},
|
|
89
|
+
verification: {
|
|
90
|
+
label: 'accountItem__verification',
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
// overlaps the top end corner of the avatar
|
|
93
|
+
top: '-0.25rem',
|
|
94
|
+
insetInlineEnd: '-0.375rem',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
boxSizing: 'border-box',
|
|
99
|
+
width: componentTheme.verificationBadgeSize,
|
|
100
|
+
height: componentTheme.verificationBadgeSize,
|
|
101
|
+
// MainNavAccountItem has no badge border width token
|
|
102
|
+
border: `0.0625rem solid ${componentTheme.verificationBadgeBorderColor}`,
|
|
103
|
+
borderRadius: componentTheme.verificationBadgeborderRadius,
|
|
104
|
+
backgroundColor: componentTheme.verificationBadgeBackgroundColor
|
|
105
|
+
},
|
|
106
|
+
pill: {
|
|
107
|
+
label: 'accountItem__pill',
|
|
108
|
+
gridArea: 'pill',
|
|
109
|
+
alignSelf: 'start',
|
|
110
|
+
display: 'flex'
|
|
111
|
+
},
|
|
112
|
+
name: {
|
|
113
|
+
label: 'accountItem__name',
|
|
114
|
+
gridArea: 'name',
|
|
115
|
+
minWidth: 0,
|
|
116
|
+
overflowWrap: 'anywhere'
|
|
117
|
+
},
|
|
118
|
+
end: {
|
|
119
|
+
label: 'accountItem__end',
|
|
120
|
+
gridArea: 'end',
|
|
121
|
+
justifySelf: 'end',
|
|
122
|
+
display: 'flex',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
gap: componentTheme.padding
|
|
125
|
+
},
|
|
126
|
+
tooltipTrigger: {
|
|
127
|
+
label: 'accountItem__tooltipTrigger',
|
|
128
|
+
display: 'block'
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export default generateStyle;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useStyleNew } from '@instructure/emotion';
|
|
26
|
+
import { Avatar } from '@instructure/ui-avatar/latest';
|
|
27
|
+
import { IconButton } from '@instructure/ui-buttons/latest';
|
|
28
|
+
import { Checkbox } from '@instructure/ui-checkbox/latest';
|
|
29
|
+
import { ChevronsUpDownInstUIIcon, LogOutInstUIIcon, renderIconWithProps, ShieldAlertInstUIIcon } from '@instructure/ui-icons';
|
|
30
|
+
import { Link } from '@instructure/ui-link/latest';
|
|
31
|
+
import { Menu, MenuItem } from '@instructure/ui-menu/latest';
|
|
32
|
+
import { Pill } from '@instructure/ui-pill/latest';
|
|
33
|
+
import { callRenderProp } from '@instructure/ui-react-utils';
|
|
34
|
+
import { Text } from '@instructure/ui-text/latest';
|
|
35
|
+
import { SubNavItem } from '../SubNavItem/index.js';
|
|
36
|
+
import generateStyle, { generateVerificationStyle } from './styles.js';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
---
|
|
40
|
+
private: true
|
|
41
|
+
id: GlobalNav.AccountPanel
|
|
42
|
+
---
|
|
43
|
+
**/
|
|
44
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
45
|
+
const AccountPanel = props => {
|
|
46
|
+
const {
|
|
47
|
+
account
|
|
48
|
+
} = props;
|
|
49
|
+
const {
|
|
50
|
+
verification,
|
|
51
|
+
switcher,
|
|
52
|
+
items = [],
|
|
53
|
+
toggles,
|
|
54
|
+
logout
|
|
55
|
+
} = account;
|
|
56
|
+
const styles = useStyleNew({
|
|
57
|
+
generateStyle,
|
|
58
|
+
componentId: 'SubNav'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// the badge tokens are in MainNavAccountItem, and useStyleNew reads one set per call
|
|
62
|
+
const verificationStyles = useStyleNew({
|
|
63
|
+
generateStyle: generateVerificationStyle,
|
|
64
|
+
componentId: 'SubNav',
|
|
65
|
+
useTokensFrom: 'MainNavAccountItem'
|
|
66
|
+
});
|
|
67
|
+
return _jsxs("div", {
|
|
68
|
+
css: styles?.panel,
|
|
69
|
+
children: [_jsxs("div", {
|
|
70
|
+
css: styles?.card,
|
|
71
|
+
children: [_jsxs("div", {
|
|
72
|
+
css: styles?.cardHeader,
|
|
73
|
+
children: [_jsxs("span", {
|
|
74
|
+
css: styles?.avatar,
|
|
75
|
+
children: [_jsx(Avatar, {
|
|
76
|
+
name: account.name,
|
|
77
|
+
src: account.avatarSrc
|
|
78
|
+
}), verification && _jsx("span", {
|
|
79
|
+
css: verificationStyles?.verification,
|
|
80
|
+
children: _jsx(ShieldAlertInstUIIcon, {
|
|
81
|
+
title: verification.badgeLabel,
|
|
82
|
+
color: "onColor",
|
|
83
|
+
size: "sm"
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
}), account.userType && _jsx(Pill, {
|
|
87
|
+
color: "info",
|
|
88
|
+
children: account.userType
|
|
89
|
+
})]
|
|
90
|
+
}), _jsxs("div", {
|
|
91
|
+
css: styles?.cardBody,
|
|
92
|
+
children: [_jsxs("div", {
|
|
93
|
+
css: styles?.cardText,
|
|
94
|
+
children: [_jsx(Text, {
|
|
95
|
+
weight: "bold",
|
|
96
|
+
children: account.name
|
|
97
|
+
}), account.institution && _jsx(Text, {
|
|
98
|
+
size: "small",
|
|
99
|
+
children: account.institution
|
|
100
|
+
}), verification && _jsx(Link, {
|
|
101
|
+
href: verification.href,
|
|
102
|
+
variant: "standalone",
|
|
103
|
+
size: "small",
|
|
104
|
+
renderIcon: _jsx(ShieldAlertInstUIIcon, {}),
|
|
105
|
+
iconPlacement: "end"
|
|
106
|
+
// Link types the event target as ViewProps, at runtime it is the DOM link or button
|
|
107
|
+
,
|
|
108
|
+
onClick: event => verification.onClick?.(event),
|
|
109
|
+
children: verification.linkLabel
|
|
110
|
+
})]
|
|
111
|
+
}), switcher && _jsx(Menu, {
|
|
112
|
+
label: switcher.label,
|
|
113
|
+
placement: "bottom start",
|
|
114
|
+
trigger: _jsx(IconButton, {
|
|
115
|
+
screenReaderLabel: switcher.label,
|
|
116
|
+
renderIcon: ChevronsUpDownInstUIIcon,
|
|
117
|
+
size: "small"
|
|
118
|
+
}),
|
|
119
|
+
children: switcher.accounts.map(option => _jsx(MenuItem, {
|
|
120
|
+
href: option.href
|
|
121
|
+
// MenuItem types the event for any element, at runtime it is the link or button
|
|
122
|
+
,
|
|
123
|
+
onClick: event => option.onClick?.(event),
|
|
124
|
+
children: _jsxs("span", {
|
|
125
|
+
css: styles?.option,
|
|
126
|
+
children: [_jsx(Avatar
|
|
127
|
+
// the accounts belong to the same user, so their initials are the user's
|
|
128
|
+
, {
|
|
129
|
+
name: account.name,
|
|
130
|
+
src: option.avatarSrc,
|
|
131
|
+
size: "x-small"
|
|
132
|
+
}), option.label]
|
|
133
|
+
})
|
|
134
|
+
}, option.itemID))
|
|
135
|
+
})]
|
|
136
|
+
})]
|
|
137
|
+
}), _jsx("div", {
|
|
138
|
+
css: styles?.divider
|
|
139
|
+
}), account.renderContent !== undefined && _jsx("div", {
|
|
140
|
+
css: styles?.content,
|
|
141
|
+
children: callRenderProp(account.renderContent)
|
|
142
|
+
}), items.length > 0 && _jsx("ul", {
|
|
143
|
+
css: styles?.items,
|
|
144
|
+
children: items.map(item => _jsx(SubNavItem, {
|
|
145
|
+
item: item
|
|
146
|
+
}, item.itemID))
|
|
147
|
+
}), _jsxs("div", {
|
|
148
|
+
css: styles?.footer,
|
|
149
|
+
children: [toggles && _jsxs("div", {
|
|
150
|
+
css: styles?.toggles,
|
|
151
|
+
children: [_jsx("h3", {
|
|
152
|
+
css: styles?.togglesTitle,
|
|
153
|
+
children: _jsx(Text, {
|
|
154
|
+
weight: "bold",
|
|
155
|
+
children: toggles.label
|
|
156
|
+
})
|
|
157
|
+
}), _jsx("ul", {
|
|
158
|
+
css: styles?.toggleItems,
|
|
159
|
+
children: toggles.items.map(toggle => _jsx("li", {
|
|
160
|
+
children: _jsx(Checkbox, {
|
|
161
|
+
variant: "toggle",
|
|
162
|
+
size: "small",
|
|
163
|
+
labelPlacement: "start-stretch",
|
|
164
|
+
label: _jsxs("span", {
|
|
165
|
+
css: styles?.toggleLabel,
|
|
166
|
+
children: [toggle.icon && renderIconWithProps(toggle.icon, 'md', undefined), toggle.label]
|
|
167
|
+
}),
|
|
168
|
+
checked: toggle.checked,
|
|
169
|
+
disabled: toggle.disabled,
|
|
170
|
+
onChange: event => toggle.onChange(event, event.target.checked)
|
|
171
|
+
})
|
|
172
|
+
}, toggle.itemID))
|
|
173
|
+
})]
|
|
174
|
+
}), logout && _jsx("ul", {
|
|
175
|
+
css: styles?.items,
|
|
176
|
+
children: _jsx(SubNavItem, {
|
|
177
|
+
logout: true,
|
|
178
|
+
item: {
|
|
179
|
+
itemID: 'logout',
|
|
180
|
+
icon: _jsx(LogOutInstUIIcon, {}),
|
|
181
|
+
...logout
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
})]
|
|
185
|
+
})]
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
export default AccountPanel;
|
|
189
|
+
export { AccountPanel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param componentTheme The theme variable object.
|
|
31
|
+
* @return The final style object, which will be used in the component
|
|
32
|
+
*/
|
|
33
|
+
const generateStyle = componentTheme => {
|
|
34
|
+
return {
|
|
35
|
+
panel: {
|
|
36
|
+
label: 'accountPanel',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
gap: componentTheme.gap,
|
|
40
|
+
minHeight: '100%'
|
|
41
|
+
},
|
|
42
|
+
card: {
|
|
43
|
+
label: 'accountPanel__card',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'column'
|
|
46
|
+
},
|
|
47
|
+
cardHeader: {
|
|
48
|
+
label: 'accountPanel__cardHeader',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
alignItems: 'flex-start',
|
|
51
|
+
justifyContent: 'space-between',
|
|
52
|
+
marginBlockEnd: componentTheme.gap
|
|
53
|
+
},
|
|
54
|
+
avatar: {
|
|
55
|
+
label: 'accountPanel__avatar',
|
|
56
|
+
position: 'relative',
|
|
57
|
+
display: 'flex'
|
|
58
|
+
},
|
|
59
|
+
cardBody: {
|
|
60
|
+
label: 'accountPanel__cardBody',
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
gap: componentTheme.gap
|
|
64
|
+
},
|
|
65
|
+
cardText: {
|
|
66
|
+
label: 'accountPanel__cardText',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
flexDirection: 'column',
|
|
69
|
+
flex: 1,
|
|
70
|
+
minWidth: 0
|
|
71
|
+
},
|
|
72
|
+
option: {
|
|
73
|
+
label: 'accountPanel__option',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
gap: componentTheme.gap
|
|
77
|
+
},
|
|
78
|
+
divider: {
|
|
79
|
+
label: 'accountPanel__divider',
|
|
80
|
+
// SubNav has no divider width token
|
|
81
|
+
borderTop: `0.0625rem solid ${componentTheme.strokeColor}`
|
|
82
|
+
},
|
|
83
|
+
content: {
|
|
84
|
+
label: 'accountPanel__content'
|
|
85
|
+
},
|
|
86
|
+
items: {
|
|
87
|
+
label: 'accountPanel__items',
|
|
88
|
+
display: 'flex',
|
|
89
|
+
flexDirection: 'column',
|
|
90
|
+
gap: componentTheme.navItemsGap,
|
|
91
|
+
listStyle: 'none',
|
|
92
|
+
margin: 0,
|
|
93
|
+
padding: 0
|
|
94
|
+
},
|
|
95
|
+
footer: {
|
|
96
|
+
label: 'accountPanel__footer',
|
|
97
|
+
display: 'flex',
|
|
98
|
+
flexDirection: 'column',
|
|
99
|
+
gap: componentTheme.gap,
|
|
100
|
+
// pushes the toggles and log out to the end of the panel
|
|
101
|
+
marginBlockStart: 'auto'
|
|
102
|
+
},
|
|
103
|
+
toggles: {
|
|
104
|
+
label: 'accountPanel__toggles',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexDirection: 'column',
|
|
107
|
+
gap: componentTheme.gap
|
|
108
|
+
},
|
|
109
|
+
togglesTitle: {
|
|
110
|
+
label: 'accountPanel__togglesTitle',
|
|
111
|
+
margin: 0
|
|
112
|
+
},
|
|
113
|
+
toggleItems: {
|
|
114
|
+
label: 'accountPanel__toggleItems',
|
|
115
|
+
display: 'flex',
|
|
116
|
+
flexDirection: 'column',
|
|
117
|
+
gap: componentTheme.gap,
|
|
118
|
+
listStyle: 'none',
|
|
119
|
+
margin: 0,
|
|
120
|
+
padding: 0
|
|
121
|
+
},
|
|
122
|
+
toggleLabel: {
|
|
123
|
+
label: 'accountPanel__toggleLabel',
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
gap: componentTheme.gap
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Generates the verification badge style from the `MainNavAccountItem` tokens
|
|
133
|
+
*/
|
|
134
|
+
const generateVerificationStyle = componentTheme => {
|
|
135
|
+
return {
|
|
136
|
+
verification: {
|
|
137
|
+
label: 'accountPanel__verification',
|
|
138
|
+
position: 'absolute',
|
|
139
|
+
// overlaps the top end corner of the avatar
|
|
140
|
+
top: '-0.25rem',
|
|
141
|
+
insetInlineEnd: '-0.375rem',
|
|
142
|
+
display: 'flex',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
boxSizing: 'border-box',
|
|
146
|
+
width: componentTheme.verificationBadgeSize,
|
|
147
|
+
height: componentTheme.verificationBadgeSize,
|
|
148
|
+
// MainNavAccountItem has no badge border width token
|
|
149
|
+
border: `0.0625rem solid ${componentTheme.verificationBadgeBorderColor}`,
|
|
150
|
+
borderRadius: componentTheme.verificationBadgeborderRadius,
|
|
151
|
+
backgroundColor: componentTheme.verificationBadgeBackgroundColor
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export default generateStyle;
|
|
156
|
+
export { generateVerificationStyle };
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { useStyleNew } from '@instructure/emotion';
|
|
26
|
-
import { ChevronRightInstUIIcon } from '@instructure/ui-icons';
|
|
26
|
+
import { ChevronRightInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
|
|
27
27
|
import { getItemElementProps } from '../utils/getItemElementProps.js';
|
|
28
28
|
import generateStyle from './styles.js';
|
|
29
29
|
|
|
@@ -37,27 +37,34 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/reac
|
|
|
37
37
|
const SubNavItem = props => {
|
|
38
38
|
const {
|
|
39
39
|
item,
|
|
40
|
+
logout = false,
|
|
40
41
|
elementRef,
|
|
41
42
|
onDrillIn
|
|
42
43
|
} = props;
|
|
43
44
|
const styles = useStyleNew({
|
|
44
45
|
generateStyle,
|
|
45
46
|
params: {
|
|
46
|
-
current: !!item.current
|
|
47
|
+
current: !!item.current,
|
|
48
|
+
logout
|
|
47
49
|
},
|
|
48
50
|
componentId: 'SubNavItem'
|
|
49
51
|
});
|
|
50
52
|
const {
|
|
51
53
|
isLink,
|
|
52
54
|
props: elementProps
|
|
53
|
-
} = getItemElementProps(item, item.subNav ? event => onDrillIn(event, item) : undefined);
|
|
55
|
+
} = getItemElementProps(item, item.subNav ? event => onDrillIn?.(event, item) : undefined);
|
|
54
56
|
const content = _jsxs(_Fragment, {
|
|
55
|
-
children: [_jsx("span", {
|
|
57
|
+
children: [item.icon && _jsx("span", {
|
|
58
|
+
css: styles?.icon,
|
|
59
|
+
children: renderIconWithProps(item.icon, logout ? 'md' : 'sm', undefined)
|
|
60
|
+
}), _jsx("span", {
|
|
56
61
|
css: styles?.label,
|
|
57
62
|
children: item.label
|
|
58
63
|
}), item.subNav && _jsx("span", {
|
|
59
64
|
css: styles?.chevron,
|
|
60
|
-
children: _jsx(ChevronRightInstUIIcon, {
|
|
65
|
+
children: _jsx(ChevronRightInstUIIcon, {
|
|
66
|
+
size: "md"
|
|
67
|
+
})
|
|
61
68
|
})]
|
|
62
69
|
});
|
|
63
70
|
return _jsx("li", {
|