@instructure/ui-global-nav 0.0.0-stage → 11.7.10
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 +0 -0
- package/LICENSE.md +28 -0
- package/README.md +25 -2
- package/es/GlobalNav/v1/CollapseButton/index.js +80 -0
- package/es/GlobalNav/v1/CollapseButton/props.js +1 -0
- package/es/GlobalNav/v1/CollapseButton/styles.js +64 -0
- package/es/GlobalNav/v1/CollapsedSubNav/index.js +59 -0
- package/es/GlobalNav/v1/CollapsedSubNav/props.js +1 -0
- package/es/GlobalNav/v1/CollapsedSubNav/styles.js +82 -0
- package/es/GlobalNav/v1/InstitutionLogo/index.js +93 -0
- package/es/GlobalNav/v1/InstitutionLogo/props.js +1 -0
- package/es/GlobalNav/v1/InstitutionLogo/styles.js +69 -0
- package/es/GlobalNav/v1/MainNavItem/index.js +129 -0
- package/es/GlobalNav/v1/MainNavItem/props.js +1 -0
- package/es/GlobalNav/v1/MainNavItem/styles.js +117 -0
- package/es/GlobalNav/v1/SubNav/index.js +121 -0
- package/es/GlobalNav/v1/SubNav/props.js +1 -0
- package/es/GlobalNav/v1/SubNav/styles.js +52 -0
- package/es/GlobalNav/v1/SubNavItem/index.js +78 -0
- package/es/GlobalNav/v1/SubNavItem/props.js +1 -0
- package/es/GlobalNav/v1/SubNavItem/styles.js +94 -0
- package/es/GlobalNav/v1/SubNavLevel/index.js +160 -0
- package/es/GlobalNav/v1/SubNavLevel/props.js +1 -0
- package/es/GlobalNav/v1/SubNavLevel/styles.js +94 -0
- package/es/GlobalNav/v1/index.js +222 -0
- package/es/GlobalNav/v1/props.js +28 -0
- package/es/GlobalNav/v1/styles.js +110 -0
- package/es/GlobalNav/v1/utils/getItemElementProps.js +64 -0
- package/es/exports/a.js +24 -0
- package/lib/GlobalNav/v1/CollapseButton/index.js +85 -0
- package/lib/GlobalNav/v1/CollapseButton/props.js +5 -0
- package/lib/GlobalNav/v1/CollapseButton/styles.js +70 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/index.js +64 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/props.js +5 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/styles.js +88 -0
- package/lib/GlobalNav/v1/InstitutionLogo/index.js +98 -0
- package/lib/GlobalNav/v1/InstitutionLogo/props.js +5 -0
- package/lib/GlobalNav/v1/InstitutionLogo/styles.js +75 -0
- package/lib/GlobalNav/v1/MainNavItem/index.js +134 -0
- package/lib/GlobalNav/v1/MainNavItem/props.js +5 -0
- package/lib/GlobalNav/v1/MainNavItem/styles.js +123 -0
- package/lib/GlobalNav/v1/SubNav/index.js +128 -0
- package/lib/GlobalNav/v1/SubNav/props.js +5 -0
- package/lib/GlobalNav/v1/SubNav/styles.js +58 -0
- package/lib/GlobalNav/v1/SubNavItem/index.js +83 -0
- package/lib/GlobalNav/v1/SubNavItem/props.js +5 -0
- package/lib/GlobalNav/v1/SubNavItem/styles.js +100 -0
- package/lib/GlobalNav/v1/SubNavLevel/index.js +165 -0
- package/lib/GlobalNav/v1/SubNavLevel/props.js +5 -0
- package/lib/GlobalNav/v1/SubNavLevel/styles.js +100 -0
- package/lib/GlobalNav/v1/index.js +228 -0
- package/lib/GlobalNav/v1/props.js +33 -0
- package/lib/GlobalNav/v1/styles.js +116 -0
- package/lib/GlobalNav/v1/utils/getItemElementProps.js +70 -0
- package/lib/exports/a.js +12 -0
- package/lib/package.json +1 -0
- package/package.json +77 -3
- package/src/GlobalNav/v1/CollapseButton/index.tsx +87 -0
- package/src/GlobalNav/v1/CollapseButton/props.ts +64 -0
- package/src/GlobalNav/v1/CollapseButton/styles.ts +76 -0
- package/src/GlobalNav/v1/CollapsedSubNav/index.tsx +60 -0
- package/src/GlobalNav/v1/CollapsedSubNav/props.ts +42 -0
- package/src/GlobalNav/v1/CollapsedSubNav/styles.ts +92 -0
- package/src/GlobalNav/v1/InstitutionLogo/index.tsx +86 -0
- package/src/GlobalNav/v1/InstitutionLogo/props.ts +42 -0
- package/src/GlobalNav/v1/InstitutionLogo/styles.ts +82 -0
- package/src/GlobalNav/v1/MainNavItem/index.tsx +132 -0
- package/src/GlobalNav/v1/MainNavItem/props.ts +65 -0
- package/src/GlobalNav/v1/MainNavItem/styles.ts +137 -0
- package/src/GlobalNav/v1/README.md +234 -0
- package/src/GlobalNav/v1/SubNav/index.tsx +132 -0
- package/src/GlobalNav/v1/SubNav/props.ts +81 -0
- package/src/GlobalNav/v1/SubNav/styles.ts +58 -0
- package/src/GlobalNav/v1/SubNavItem/index.tsx +79 -0
- package/src/GlobalNav/v1/SubNavItem/props.ts +48 -0
- package/src/GlobalNav/v1/SubNavItem/styles.ts +110 -0
- package/src/GlobalNav/v1/SubNavLevel/index.tsx +193 -0
- package/src/GlobalNav/v1/SubNavLevel/props.ts +75 -0
- package/src/GlobalNav/v1/SubNavLevel/styles.ts +103 -0
- package/src/GlobalNav/v1/index.tsx +256 -0
- package/src/GlobalNav/v1/props.ts +328 -0
- package/src/GlobalNav/v1/styles.ts +132 -0
- package/src/GlobalNav/v1/utils/getItemElementProps.ts +80 -0
- package/src/exports/a.ts +35 -0
- package/tsconfig.build.json +53 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/GlobalNav/v1/CollapseButton/index.d.ts +11 -0
- package/types/GlobalNav/v1/CollapseButton/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapseButton/props.d.ts +31 -0
- package/types/GlobalNav/v1/CollapseButton/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts +22 -0
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts +11 -0
- package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts +15 -0
- package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts +14 -0
- package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/index.d.ts +11 -0
- package/types/GlobalNav/v1/InstitutionLogo/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts +15 -0
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts +20 -0
- package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/index.d.ts +11 -0
- package/types/GlobalNav/v1/MainNavItem/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/props.d.ts +32 -0
- package/types/GlobalNav/v1/MainNavItem/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/styles.d.ts +19 -0
- package/types/GlobalNav/v1/MainNavItem/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNav/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/props.d.ts +52 -0
- package/types/GlobalNav/v1/SubNav/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/styles.d.ts +13 -0
- package/types/GlobalNav/v1/SubNav/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNavItem/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/props.d.ts +20 -0
- package/types/GlobalNav/v1/SubNavItem/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts +18 -0
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNavLevel/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/props.d.ts +45 -0
- package/types/GlobalNav/v1/SubNavLevel/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/styles.d.ts +14 -0
- package/types/GlobalNav/v1/SubNavLevel/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/index.d.ts +59 -0
- package/types/GlobalNav/v1/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/props.d.ts +247 -0
- package/types/GlobalNav/v1/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/styles.d.ts +23 -0
- package/types/GlobalNav/v1/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/utils/getItemElementProps.d.ts +37 -0
- package/types/GlobalNav/v1/utils/getItemElementProps.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
package/CHANGELOG.md
ADDED
|
File without changes
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The MIT License (MIT)
|
|
3
|
+
category: Getting Started
|
|
4
|
+
order: 9
|
|
5
|
+
isWIP: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# The MIT License (MIT)
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2015 Instructure, Inc.
|
|
11
|
+
|
|
12
|
+
**Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions.**
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
## ui-global-nav
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![npm][npm]][npm-url]
|
|
4
|
+
[![MIT License][license-badge]][license]
|
|
5
|
+
[![Code of Conduct][coc-badge]][coc]
|
|
6
|
+
|
|
7
|
+
Main navigation of an app: a rail with items, sub navigation and an account menu.
|
|
8
|
+
|
|
9
|
+
### Components
|
|
10
|
+
|
|
11
|
+
The `ui-global-nav` package contains the following:
|
|
12
|
+
|
|
13
|
+
- [GlobalNav](GlobalNav)
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @instructure/ui-global-nav
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
[npm]: https://img.shields.io/npm/v/@instructure/ui-global-nav.svg
|
|
22
|
+
[npm-url]: https://npmjs.com/package/@instructure/ui-global-nav
|
|
23
|
+
[license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
|
|
24
|
+
[license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE.md
|
|
25
|
+
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
|
|
26
|
+
[coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { IconButton } from '@instructure/ui-buttons/latest';
|
|
27
|
+
import { PanelRightCloseInstUIIcon, PanelRightOpenInstUIIcon } from '@instructure/ui-icons';
|
|
28
|
+
import generateStyle, { generateIconStyle } from './styles.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
---
|
|
32
|
+
private: true
|
|
33
|
+
id: GlobalNav.CollapseButton
|
|
34
|
+
---
|
|
35
|
+
**/
|
|
36
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
37
|
+
const CollapseButton = props => {
|
|
38
|
+
const {
|
|
39
|
+
collapsed,
|
|
40
|
+
collapseLabel,
|
|
41
|
+
expandLabel,
|
|
42
|
+
onCollapse,
|
|
43
|
+
elementRef
|
|
44
|
+
} = props;
|
|
45
|
+
const styles = useStyleNew({
|
|
46
|
+
generateStyle,
|
|
47
|
+
params: {
|
|
48
|
+
collapsed
|
|
49
|
+
},
|
|
50
|
+
componentId: 'CollapseButton'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// MainNavItem is a separate token set, and useStyleNew reads one set per call
|
|
54
|
+
const iconStyles = useStyleNew({
|
|
55
|
+
generateStyle: generateIconStyle,
|
|
56
|
+
componentId: 'CollapseButton',
|
|
57
|
+
useTokensFrom: 'MainNavItem'
|
|
58
|
+
});
|
|
59
|
+
const label = collapsed ? expandLabel : collapseLabel;
|
|
60
|
+
return _jsx("div", {
|
|
61
|
+
css: styles?.collapseButton,
|
|
62
|
+
children: _jsx(IconButton, {
|
|
63
|
+
screenReaderLabel: label,
|
|
64
|
+
renderIcon: collapsed ? PanelRightCloseInstUIIcon : PanelRightOpenInstUIIcon,
|
|
65
|
+
withBackground: false,
|
|
66
|
+
withBorder: false,
|
|
67
|
+
size: "small",
|
|
68
|
+
elementRef: elementRef
|
|
69
|
+
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
70
|
+
,
|
|
71
|
+
onClick: event => onCollapse(event, !collapsed),
|
|
72
|
+
themeOverride: {
|
|
73
|
+
...styles?.iconButtonThemeOverride,
|
|
74
|
+
...iconStyles?.iconButtonThemeOverride
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export default CollapseButton;
|
|
80
|
+
export { CollapseButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
* @param params Additional parameters to customize the style.
|
|
32
|
+
* @return The final style object, which will be used in the component
|
|
33
|
+
*/
|
|
34
|
+
const generateStyle = (componentTheme, params) => {
|
|
35
|
+
const {
|
|
36
|
+
collapsed
|
|
37
|
+
} = params;
|
|
38
|
+
return {
|
|
39
|
+
collapseButton: {
|
|
40
|
+
label: 'collapseButton',
|
|
41
|
+
// the collapsed rail centers the button
|
|
42
|
+
marginInlineEnd: collapsed ? 0 : componentTheme.rightMargin
|
|
43
|
+
},
|
|
44
|
+
iconButtonThemeOverride: {
|
|
45
|
+
secondaryGhostHoverBackground: componentTheme.hoverBackgroundColor,
|
|
46
|
+
secondaryGhostActiveBackground: componentTheme.activeBackgroundColor
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generates the icon color from the `MainNavItem` tokens
|
|
53
|
+
*/
|
|
54
|
+
const generateIconStyle = componentTheme => {
|
|
55
|
+
return {
|
|
56
|
+
// the default IconButton icon is unreadable on the dark legacy rail, and the
|
|
57
|
+
// CollapseButton tokens have no icon color
|
|
58
|
+
iconButtonThemeOverride: {
|
|
59
|
+
secondaryGhostColor: componentTheme.fontColor
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export default generateStyle;
|
|
64
|
+
export { generateIconStyle };
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { PanelLeftOpenInstUIIcon } from '@instructure/ui-icons';
|
|
27
|
+
import generateStyle from './styles.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
---
|
|
31
|
+
private: true
|
|
32
|
+
id: GlobalNav.CollapsedSubNav
|
|
33
|
+
---
|
|
34
|
+
**/
|
|
35
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
36
|
+
const CollapsedSubNav = props => {
|
|
37
|
+
const {
|
|
38
|
+
label,
|
|
39
|
+
onExpand
|
|
40
|
+
} = props;
|
|
41
|
+
const styles = useStyleNew({
|
|
42
|
+
generateStyle,
|
|
43
|
+
componentId: 'SubNav'
|
|
44
|
+
});
|
|
45
|
+
return _jsx("button", {
|
|
46
|
+
type: "button",
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
css: styles?.collapsedSubNav,
|
|
49
|
+
onClick: onExpand,
|
|
50
|
+
children: _jsx("span", {
|
|
51
|
+
css: styles?.icon,
|
|
52
|
+
children: _jsx(PanelLeftOpenInstUIIcon, {
|
|
53
|
+
size: "sm"
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export default CollapsedSubNav;
|
|
59
|
+
export { CollapsedSubNav };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
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 { calcFocusOutlineStyles } from '@instructure/emotion';
|
|
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 sharedTokens Shared token object that stores common values for the theme.
|
|
33
|
+
* @return The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, _params, sharedTokens) => {
|
|
36
|
+
// SubNav has no border width token
|
|
37
|
+
const borderWidth = '0.0625rem';
|
|
38
|
+
return {
|
|
39
|
+
collapsedSubNav: {
|
|
40
|
+
label: 'collapsedSubNav',
|
|
41
|
+
width: componentTheme.minimizedWidth,
|
|
42
|
+
flexShrink: 0,
|
|
43
|
+
boxSizing: 'border-box',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
// the strip widens on hover, and the icon moves out with its outer edge
|
|
47
|
+
alignItems: 'flex-end',
|
|
48
|
+
margin: 0,
|
|
49
|
+
padding: 0,
|
|
50
|
+
paddingTop: `var(--globalNav-collapseButtonTop, ${componentTheme.minimizedVerticalPadding})`,
|
|
51
|
+
border: 'none',
|
|
52
|
+
borderInlineStart: `${borderWidth} solid ${componentTheme.borderColor}`,
|
|
53
|
+
// the strip is the end of the rail card, so it takes the card's end corners
|
|
54
|
+
borderStartEndRadius: 'inherit',
|
|
55
|
+
borderEndEndRadius: 'inherit',
|
|
56
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
57
|
+
color: componentTheme.textColor,
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
...calcFocusOutlineStyles({
|
|
60
|
+
...sharedTokens.focusOutline,
|
|
61
|
+
// an outside ring would cover the main nav divider and the card border
|
|
62
|
+
inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
|
|
63
|
+
}, {
|
|
64
|
+
focusPosition: 'inset'
|
|
65
|
+
}),
|
|
66
|
+
'&:hover': {
|
|
67
|
+
width: componentTheme.minimizedHoverWidth
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
icon: {
|
|
71
|
+
label: 'collapsedSubNav__icon',
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
// the width of the strip at rest, so the icon is centered until the strip widens
|
|
76
|
+
width: `calc(${componentTheme.minimizedWidth} - ${borderWidth})`,
|
|
77
|
+
// the height of the rail's collapse button, so both icons share a center line
|
|
78
|
+
height: 'var(--globalNav-collapseButtonHeight)'
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export default generateStyle;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { Text } from '@instructure/ui-text/latest';
|
|
27
|
+
import { safeLinkProps } from '@instructure/ui-utils';
|
|
28
|
+
import generateStyle from './styles.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
---
|
|
32
|
+
private: true
|
|
33
|
+
id: GlobalNav.InstitutionLogo
|
|
34
|
+
---
|
|
35
|
+
**/
|
|
36
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
37
|
+
const InstitutionLogo = props => {
|
|
38
|
+
const {
|
|
39
|
+
logo,
|
|
40
|
+
collapsed
|
|
41
|
+
} = props;
|
|
42
|
+
const isLink = !!logo.href;
|
|
43
|
+
const {
|
|
44
|
+
showName: showNameProp = true
|
|
45
|
+
} = logo;
|
|
46
|
+
const showName = !collapsed && showNameProp;
|
|
47
|
+
const styles = useStyleNew({
|
|
48
|
+
generateStyle,
|
|
49
|
+
params: {
|
|
50
|
+
collapsed,
|
|
51
|
+
isLink,
|
|
52
|
+
wordmark: !showNameProp
|
|
53
|
+
},
|
|
54
|
+
componentId: 'MainNavInstitutionLogo'
|
|
55
|
+
});
|
|
56
|
+
if (!logo.src && !showName) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const content = _jsxs(_Fragment, {
|
|
60
|
+
children: [logo.src && _jsx("img", {
|
|
61
|
+
css: styles?.mark,
|
|
62
|
+
src: logo.src
|
|
63
|
+
// the visible name labels the logo when it shows
|
|
64
|
+
,
|
|
65
|
+
alt: showName ? '' : logo.name
|
|
66
|
+
}), showName && _jsx(Text, {
|
|
67
|
+
color: "inherit",
|
|
68
|
+
weight: "bold",
|
|
69
|
+
children: logo.name
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
if (isLink) {
|
|
73
|
+
// drops unsafe hrefs, for example javascript: URLs that would run code on click
|
|
74
|
+
const {
|
|
75
|
+
href
|
|
76
|
+
} = safeLinkProps({
|
|
77
|
+
href: logo.href,
|
|
78
|
+
tag: 'a',
|
|
79
|
+
attr: 'href'
|
|
80
|
+
});
|
|
81
|
+
return _jsx("a", {
|
|
82
|
+
css: styles?.logo,
|
|
83
|
+
href: href,
|
|
84
|
+
children: content
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return _jsx("div", {
|
|
88
|
+
css: styles?.logo,
|
|
89
|
+
children: content
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
export default InstitutionLogo;
|
|
93
|
+
export { InstitutionLogo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { calcFocusOutlineStyles } from '@instructure/emotion';
|
|
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
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
34
|
+
* @return The final style object, which will be used in the component
|
|
35
|
+
*/
|
|
36
|
+
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
37
|
+
const {
|
|
38
|
+
collapsed,
|
|
39
|
+
isLink,
|
|
40
|
+
wordmark
|
|
41
|
+
} = params;
|
|
42
|
+
return {
|
|
43
|
+
logo: {
|
|
44
|
+
label: 'institutionLogo',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
gap: componentTheme.gap,
|
|
48
|
+
padding: collapsed ? 0 : componentTheme.padding,
|
|
49
|
+
flex: collapsed ? undefined : 1,
|
|
50
|
+
...(collapsed && {
|
|
51
|
+
width: componentTheme.minimizedWidth,
|
|
52
|
+
height: componentTheme.minimizedHeight,
|
|
53
|
+
justifyContent: 'center'
|
|
54
|
+
}),
|
|
55
|
+
color: componentTheme.textColor,
|
|
56
|
+
textDecoration: 'none',
|
|
57
|
+
...(isLink && calcFocusOutlineStyles(sharedTokens.focusOutline))
|
|
58
|
+
},
|
|
59
|
+
mark: {
|
|
60
|
+
label: 'institutionLogo__mark',
|
|
61
|
+
// the mark has the collapsed logo size in both rail states
|
|
62
|
+
width: wordmark ? 'auto' : componentTheme.minimizedWidth,
|
|
63
|
+
height: wordmark ? componentTheme.wordmarkHeight : componentTheme.minimizedHeight,
|
|
64
|
+
objectFit: 'contain',
|
|
65
|
+
flexShrink: 0
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export default generateStyle;
|
|
@@ -0,0 +1,129 @@
|
|
|
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 { Badge } from '@instructure/ui-badge/latest';
|
|
28
|
+
import { ChevronRightInstUIIcon } from '@instructure/ui-icons';
|
|
29
|
+
import { callRenderProp } from '@instructure/ui-react-utils';
|
|
30
|
+
import { Tooltip } from '@instructure/ui-tooltip/latest';
|
|
31
|
+
import { getItemElementProps } from '../utils/getItemElementProps.js';
|
|
32
|
+
import generateStyle from './styles.js';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
private: true
|
|
37
|
+
id: GlobalNav.MainNavItem
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
41
|
+
const MainNavItem = props => {
|
|
42
|
+
const {
|
|
43
|
+
item,
|
|
44
|
+
collapsed,
|
|
45
|
+
open,
|
|
46
|
+
subNavId,
|
|
47
|
+
onActivate,
|
|
48
|
+
elementRef
|
|
49
|
+
} = props;
|
|
50
|
+
const current = !!item.current;
|
|
51
|
+
const styles = useStyleNew({
|
|
52
|
+
generateStyle,
|
|
53
|
+
params: {
|
|
54
|
+
collapsed,
|
|
55
|
+
current,
|
|
56
|
+
open
|
|
57
|
+
},
|
|
58
|
+
componentId: 'MainNavItem'
|
|
59
|
+
});
|
|
60
|
+
const label = item.label;
|
|
61
|
+
const badgeCount = item.badgeCount ?? 0;
|
|
62
|
+
const badgeLabel = typeof item.badgeLabel === 'function' ? item.badgeLabel(badgeCount) : item.badgeLabel;
|
|
63
|
+
const formatBadge = formattedCount => badgeLabel ? _jsx(AccessibleContent, {
|
|
64
|
+
alt: badgeLabel,
|
|
65
|
+
children: formattedCount
|
|
66
|
+
}) : formattedCount;
|
|
67
|
+
const badge = badgeCount > 0 && _jsx(Badge, {
|
|
68
|
+
standalone: true,
|
|
69
|
+
count: badgeCount,
|
|
70
|
+
formatOutput: formatBadge
|
|
71
|
+
});
|
|
72
|
+
const content = collapsed ? _jsxs(_Fragment, {
|
|
73
|
+
children: [_jsx(ScreenReaderContent, {
|
|
74
|
+
children: label
|
|
75
|
+
}), _jsxs("span", {
|
|
76
|
+
css: styles?.icon,
|
|
77
|
+
children: [callRenderProp(item.icon), badge && _jsx("span", {
|
|
78
|
+
css: styles?.badge,
|
|
79
|
+
children: badge
|
|
80
|
+
})]
|
|
81
|
+
})]
|
|
82
|
+
}) : _jsxs(_Fragment, {
|
|
83
|
+
children: [_jsx("span", {
|
|
84
|
+
css: styles?.icon,
|
|
85
|
+
children: callRenderProp(item.icon)
|
|
86
|
+
}), _jsx("span", {
|
|
87
|
+
css: styles?.label,
|
|
88
|
+
children: label
|
|
89
|
+
}), badge, item.subNav && _jsx("span", {
|
|
90
|
+
css: styles?.chevron,
|
|
91
|
+
children: _jsx(ChevronRightInstUIIcon, {})
|
|
92
|
+
})]
|
|
93
|
+
});
|
|
94
|
+
const {
|
|
95
|
+
isLink,
|
|
96
|
+
props: mergedProps
|
|
97
|
+
} = getItemElementProps(item, event => onActivate(event, item), item.subNav ? {
|
|
98
|
+
'aria-expanded': open,
|
|
99
|
+
'aria-controls': subNavId
|
|
100
|
+
} : undefined);
|
|
101
|
+
let element;
|
|
102
|
+
if (isLink) {
|
|
103
|
+
element = _jsx("a", {
|
|
104
|
+
...mergedProps,
|
|
105
|
+
ref: elementRef,
|
|
106
|
+
css: styles?.item,
|
|
107
|
+
children: content
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
element = _jsx("button", {
|
|
111
|
+
...mergedProps,
|
|
112
|
+
ref: elementRef,
|
|
113
|
+
css: styles?.item,
|
|
114
|
+
children: content
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return _jsx("li", {
|
|
118
|
+
children: collapsed ? _jsx(Tooltip, {
|
|
119
|
+
renderTip: label,
|
|
120
|
+
placement: "end",
|
|
121
|
+
children: _jsx("span", {
|
|
122
|
+
css: styles?.tooltipTrigger,
|
|
123
|
+
children: element
|
|
124
|
+
})
|
|
125
|
+
}) : element
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
export default MainNavItem;
|
|
129
|
+
export { MainNavItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|