@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
|
@@ -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
|
+
import type { SyntheticEvent } from 'react'
|
|
26
|
+
|
|
27
|
+
import type { ComponentStyle } from '@instructure/emotion'
|
|
28
|
+
import type { NewComponentTypes } from '@instructure/ui-themes'
|
|
29
|
+
|
|
30
|
+
type CollapseButtonProps = {
|
|
31
|
+
/**
|
|
32
|
+
* Whether the rail is collapsed.
|
|
33
|
+
*/
|
|
34
|
+
collapsed: boolean
|
|
35
|
+
/**
|
|
36
|
+
* Screen reader text when the rail is expanded.
|
|
37
|
+
*/
|
|
38
|
+
collapseLabel: string
|
|
39
|
+
/**
|
|
40
|
+
* Screen reader text when the rail is collapsed.
|
|
41
|
+
*/
|
|
42
|
+
expandLabel: string
|
|
43
|
+
/**
|
|
44
|
+
* Called when the user clicks the button, with the new `collapsed` value.
|
|
45
|
+
*/
|
|
46
|
+
onCollapse: (event: SyntheticEvent, collapsed: boolean) => void
|
|
47
|
+
/**
|
|
48
|
+
* Provides a reference to the underlying HTML element.
|
|
49
|
+
*/
|
|
50
|
+
elementRef: (element: Element | null) => void
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type CollapseButtonIconStyle = {
|
|
54
|
+
iconButtonThemeOverride: Partial<ReturnType<NewComponentTypes['BaseButton']>>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type CollapseButtonStyle = ComponentStyle<'collapseButton'> &
|
|
58
|
+
CollapseButtonIconStyle
|
|
59
|
+
|
|
60
|
+
export type {
|
|
61
|
+
CollapseButtonProps,
|
|
62
|
+
CollapseButtonStyle,
|
|
63
|
+
CollapseButtonIconStyle
|
|
64
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 type { NewComponentTypes } from '@instructure/ui-themes'
|
|
26
|
+
import type { CollapseButtonIconStyle, CollapseButtonStyle } from './props.js'
|
|
27
|
+
|
|
28
|
+
type StyleParams = {
|
|
29
|
+
collapsed: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param componentTheme The theme variable object.
|
|
38
|
+
* @param params Additional parameters to customize the style.
|
|
39
|
+
* @return The final style object, which will be used in the component
|
|
40
|
+
*/
|
|
41
|
+
const generateStyle = (
|
|
42
|
+
componentTheme: ReturnType<NewComponentTypes['CollapseButton']>,
|
|
43
|
+
params: StyleParams
|
|
44
|
+
): CollapseButtonStyle => {
|
|
45
|
+
const { collapsed } = params
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
collapseButton: {
|
|
49
|
+
label: 'collapseButton',
|
|
50
|
+
// the collapsed rail centers the button
|
|
51
|
+
marginInlineEnd: collapsed ? 0 : componentTheme.rightMargin
|
|
52
|
+
},
|
|
53
|
+
iconButtonThemeOverride: {
|
|
54
|
+
secondaryGhostHoverBackground: componentTheme.hoverBackgroundColor,
|
|
55
|
+
secondaryGhostActiveBackground: componentTheme.activeBackgroundColor
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generates the icon color from the `MainNavItem` tokens
|
|
62
|
+
*/
|
|
63
|
+
const generateIconStyle = (
|
|
64
|
+
componentTheme: ReturnType<NewComponentTypes['MainNavItem']>
|
|
65
|
+
): CollapseButtonIconStyle => {
|
|
66
|
+
return {
|
|
67
|
+
// the default IconButton icon is unreadable on the dark legacy rail, and the
|
|
68
|
+
// CollapseButton tokens have no icon color
|
|
69
|
+
iconButtonThemeOverride: {
|
|
70
|
+
secondaryGhostColor: componentTheme.fontColor
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default generateStyle
|
|
76
|
+
export { generateIconStyle }
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
|
|
28
|
+
import type { CollapsedSubNavProps } from './props.js'
|
|
29
|
+
import generateStyle from './styles.js'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
---
|
|
33
|
+
private: true
|
|
34
|
+
id: GlobalNav.CollapsedSubNav
|
|
35
|
+
---
|
|
36
|
+
**/
|
|
37
|
+
const CollapsedSubNav = (props: CollapsedSubNavProps) => {
|
|
38
|
+
const { label, onExpand } = props
|
|
39
|
+
|
|
40
|
+
const styles = useStyleNew({
|
|
41
|
+
generateStyle,
|
|
42
|
+
componentId: 'SubNav'
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
aria-label={label}
|
|
49
|
+
css={styles?.collapsedSubNav}
|
|
50
|
+
onClick={onExpand}
|
|
51
|
+
>
|
|
52
|
+
<span css={styles?.icon}>
|
|
53
|
+
<PanelLeftOpenInstUIIcon size="sm" />
|
|
54
|
+
</span>
|
|
55
|
+
</button>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default CollapsedSubNav
|
|
60
|
+
export { CollapsedSubNav }
|
|
@@ -0,0 +1,42 @@
|
|
|
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 type { SyntheticEvent } from 'react'
|
|
26
|
+
|
|
27
|
+
import type { ComponentStyle } from '@instructure/emotion'
|
|
28
|
+
|
|
29
|
+
type CollapsedSubNavProps = {
|
|
30
|
+
/**
|
|
31
|
+
* Screen reader text of the button that opens the SubNav again.
|
|
32
|
+
*/
|
|
33
|
+
label: string
|
|
34
|
+
/**
|
|
35
|
+
* Called when the user clicks the strip.
|
|
36
|
+
*/
|
|
37
|
+
onExpand: (event: SyntheticEvent) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type CollapsedSubNavStyle = ComponentStyle<'collapsedSubNav' | 'icon'>
|
|
41
|
+
|
|
42
|
+
export type { CollapsedSubNavProps, CollapsedSubNavStyle }
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
27
|
+
import type { CollapsedSubNavStyle } from './props.js'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ---
|
|
31
|
+
* private: true
|
|
32
|
+
* ---
|
|
33
|
+
* Generates the style object from the theme and provided additional information
|
|
34
|
+
* @param componentTheme The theme variable object.
|
|
35
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
36
|
+
* @return The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (
|
|
39
|
+
componentTheme: ReturnType<NewComponentTypes['SubNav']>,
|
|
40
|
+
_params: undefined,
|
|
41
|
+
sharedTokens: SharedTokens
|
|
42
|
+
): CollapsedSubNavStyle => {
|
|
43
|
+
// SubNav has no border width token
|
|
44
|
+
const borderWidth = '0.0625rem'
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
collapsedSubNav: {
|
|
48
|
+
label: 'collapsedSubNav',
|
|
49
|
+
width: componentTheme.minimizedWidth,
|
|
50
|
+
flexShrink: 0,
|
|
51
|
+
boxSizing: 'border-box',
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
// the strip widens on hover, and the icon moves out with its outer edge
|
|
55
|
+
alignItems: 'flex-end',
|
|
56
|
+
margin: 0,
|
|
57
|
+
padding: 0,
|
|
58
|
+
paddingTop: `var(--globalNav-collapseButtonTop, ${componentTheme.minimizedVerticalPadding})`,
|
|
59
|
+
border: 'none',
|
|
60
|
+
borderInlineStart: `${borderWidth} solid ${componentTheme.borderColor}`,
|
|
61
|
+
// the strip is the end of the rail card, so it takes the card's end corners
|
|
62
|
+
borderStartEndRadius: 'inherit',
|
|
63
|
+
borderEndEndRadius: 'inherit',
|
|
64
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
65
|
+
color: componentTheme.textColor,
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
...calcFocusOutlineStyles(
|
|
68
|
+
{
|
|
69
|
+
...sharedTokens.focusOutline,
|
|
70
|
+
// an outside ring would cover the main nav divider and the card border
|
|
71
|
+
inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
|
|
72
|
+
},
|
|
73
|
+
{ focusPosition: 'inset' }
|
|
74
|
+
),
|
|
75
|
+
'&:hover': {
|
|
76
|
+
width: componentTheme.minimizedHoverWidth
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
icon: {
|
|
80
|
+
label: 'collapsedSubNav__icon',
|
|
81
|
+
display: 'flex',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
// the width of the strip at rest, so the icon is centered until the strip widens
|
|
85
|
+
width: `calc(${componentTheme.minimizedWidth} - ${borderWidth})`,
|
|
86
|
+
// the height of the rail's collapse button, so both icons share a center line
|
|
87
|
+
height: 'var(--globalNav-collapseButtonHeight)'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default generateStyle
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
|
|
29
|
+
import type { InstitutionLogoProps } from './props.js'
|
|
30
|
+
import generateStyle from './styles.js'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
private: true
|
|
35
|
+
id: GlobalNav.InstitutionLogo
|
|
36
|
+
---
|
|
37
|
+
**/
|
|
38
|
+
const InstitutionLogo = (props: InstitutionLogoProps) => {
|
|
39
|
+
const { logo, collapsed } = props
|
|
40
|
+
const isLink = !!logo.href
|
|
41
|
+
const { showName: showNameProp = true } = logo
|
|
42
|
+
const showName = !collapsed && showNameProp
|
|
43
|
+
|
|
44
|
+
const styles = useStyleNew({
|
|
45
|
+
generateStyle,
|
|
46
|
+
params: { collapsed, isLink, wordmark: !showNameProp },
|
|
47
|
+
componentId: 'MainNavInstitutionLogo'
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (!logo.src && !showName) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const content = (
|
|
55
|
+
<>
|
|
56
|
+
{logo.src && (
|
|
57
|
+
<img
|
|
58
|
+
css={styles?.mark}
|
|
59
|
+
src={logo.src}
|
|
60
|
+
// the visible name labels the logo when it shows
|
|
61
|
+
alt={showName ? '' : logo.name}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
{showName && (
|
|
65
|
+
<Text color="inherit" weight="bold">
|
|
66
|
+
{logo.name}
|
|
67
|
+
</Text>
|
|
68
|
+
)}
|
|
69
|
+
</>
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if (isLink) {
|
|
73
|
+
// drops unsafe hrefs, for example javascript: URLs that would run code on click
|
|
74
|
+
const { href } = safeLinkProps({ href: logo.href, tag: 'a', attr: 'href' })
|
|
75
|
+
return (
|
|
76
|
+
<a css={styles?.logo} href={href}>
|
|
77
|
+
{content}
|
|
78
|
+
</a>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return <div css={styles?.logo}>{content}</div>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default InstitutionLogo
|
|
86
|
+
export { InstitutionLogo }
|
|
@@ -0,0 +1,42 @@
|
|
|
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 type { ComponentStyle } from '@instructure/emotion'
|
|
26
|
+
|
|
27
|
+
import type { GlobalNavLogo } from '../props.js'
|
|
28
|
+
|
|
29
|
+
type InstitutionLogoProps = {
|
|
30
|
+
/**
|
|
31
|
+
* The logo data.
|
|
32
|
+
*/
|
|
33
|
+
logo: GlobalNavLogo
|
|
34
|
+
/**
|
|
35
|
+
* Whether the rail is collapsed.
|
|
36
|
+
*/
|
|
37
|
+
collapsed: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type InstitutionLogoStyle = ComponentStyle<'logo' | 'mark'>
|
|
41
|
+
|
|
42
|
+
export type { InstitutionLogoProps, InstitutionLogoStyle }
|
|
@@ -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
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
27
|
+
import type { InstitutionLogoStyle } from './props.js'
|
|
28
|
+
|
|
29
|
+
type StyleParams = {
|
|
30
|
+
collapsed: boolean
|
|
31
|
+
isLink: boolean
|
|
32
|
+
wordmark: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* ---
|
|
37
|
+
* private: true
|
|
38
|
+
* ---
|
|
39
|
+
* Generates the style object from the theme and provided additional information
|
|
40
|
+
* @param componentTheme The theme variable object.
|
|
41
|
+
* @param params Additional parameters to customize the style.
|
|
42
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
43
|
+
* @return The final style object, which will be used in the component
|
|
44
|
+
*/
|
|
45
|
+
const generateStyle = (
|
|
46
|
+
componentTheme: ReturnType<NewComponentTypes['MainNavInstitutionLogo']>,
|
|
47
|
+
params: StyleParams,
|
|
48
|
+
sharedTokens: SharedTokens
|
|
49
|
+
): InstitutionLogoStyle => {
|
|
50
|
+
const { collapsed, isLink, wordmark } = params
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
logo: {
|
|
54
|
+
label: 'institutionLogo',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
gap: componentTheme.gap,
|
|
58
|
+
padding: collapsed ? 0 : componentTheme.padding,
|
|
59
|
+
flex: collapsed ? undefined : 1,
|
|
60
|
+
...(collapsed && {
|
|
61
|
+
width: componentTheme.minimizedWidth,
|
|
62
|
+
height: componentTheme.minimizedHeight,
|
|
63
|
+
justifyContent: 'center'
|
|
64
|
+
}),
|
|
65
|
+
color: componentTheme.textColor,
|
|
66
|
+
textDecoration: 'none',
|
|
67
|
+
...(isLink && calcFocusOutlineStyles(sharedTokens.focusOutline))
|
|
68
|
+
},
|
|
69
|
+
mark: {
|
|
70
|
+
label: 'institutionLogo__mark',
|
|
71
|
+
// the mark has the collapsed logo size in both rail states
|
|
72
|
+
width: wordmark ? 'auto' : componentTheme.minimizedWidth,
|
|
73
|
+
height: wordmark
|
|
74
|
+
? componentTheme.wordmarkHeight
|
|
75
|
+
: componentTheme.minimizedHeight,
|
|
76
|
+
objectFit: 'contain',
|
|
77
|
+
flexShrink: 0
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default generateStyle
|
|
@@ -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 { useStyleNew } from '@instructure/emotion'
|
|
26
|
+
import {
|
|
27
|
+
AccessibleContent,
|
|
28
|
+
ScreenReaderContent
|
|
29
|
+
} from '@instructure/ui-a11y-content'
|
|
30
|
+
import { Badge } from '@instructure/ui-badge/latest'
|
|
31
|
+
import { ChevronRightInstUIIcon } from '@instructure/ui-icons'
|
|
32
|
+
import { callRenderProp } from '@instructure/ui-react-utils'
|
|
33
|
+
import { Tooltip } from '@instructure/ui-tooltip/latest'
|
|
34
|
+
|
|
35
|
+
import { getItemElementProps } from '../utils/getItemElementProps.js'
|
|
36
|
+
import type { MainNavItemProps } from './props.js'
|
|
37
|
+
import generateStyle from './styles.js'
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
---
|
|
41
|
+
private: true
|
|
42
|
+
id: GlobalNav.MainNavItem
|
|
43
|
+
---
|
|
44
|
+
**/
|
|
45
|
+
const MainNavItem = (props: MainNavItemProps) => {
|
|
46
|
+
const { item, collapsed, open, subNavId, onActivate, elementRef } = props
|
|
47
|
+
const current = !!item.current
|
|
48
|
+
|
|
49
|
+
const styles = useStyleNew({
|
|
50
|
+
generateStyle,
|
|
51
|
+
params: { collapsed, current, open },
|
|
52
|
+
componentId: 'MainNavItem'
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const label = item.label
|
|
56
|
+
|
|
57
|
+
const badgeCount = item.badgeCount ?? 0
|
|
58
|
+
const badgeLabel =
|
|
59
|
+
typeof item.badgeLabel === 'function'
|
|
60
|
+
? item.badgeLabel(badgeCount)
|
|
61
|
+
: item.badgeLabel
|
|
62
|
+
const formatBadge = (formattedCount: string) =>
|
|
63
|
+
badgeLabel ? (
|
|
64
|
+
<AccessibleContent alt={badgeLabel}>{formattedCount}</AccessibleContent>
|
|
65
|
+
) : (
|
|
66
|
+
formattedCount
|
|
67
|
+
)
|
|
68
|
+
const badge = badgeCount > 0 && (
|
|
69
|
+
<Badge standalone count={badgeCount} formatOutput={formatBadge} />
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const content = collapsed ? (
|
|
73
|
+
<>
|
|
74
|
+
{/* before the icon, so the name reads the label first and then the badge */}
|
|
75
|
+
<ScreenReaderContent>{label}</ScreenReaderContent>
|
|
76
|
+
<span css={styles?.icon}>
|
|
77
|
+
{callRenderProp(item.icon)}
|
|
78
|
+
{badge && <span css={styles?.badge}>{badge}</span>}
|
|
79
|
+
</span>
|
|
80
|
+
</>
|
|
81
|
+
) : (
|
|
82
|
+
<>
|
|
83
|
+
<span css={styles?.icon}>{callRenderProp(item.icon)}</span>
|
|
84
|
+
<span css={styles?.label}>{label}</span>
|
|
85
|
+
{badge}
|
|
86
|
+
{item.subNav && (
|
|
87
|
+
<span css={styles?.chevron}>
|
|
88
|
+
<ChevronRightInstUIIcon />
|
|
89
|
+
</span>
|
|
90
|
+
)}
|
|
91
|
+
</>
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
const { isLink, props: mergedProps } = getItemElementProps(
|
|
95
|
+
item,
|
|
96
|
+
(event) => onActivate(event, item),
|
|
97
|
+
item.subNav
|
|
98
|
+
? { 'aria-expanded': open, 'aria-controls': subNavId }
|
|
99
|
+
: undefined
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
let element
|
|
103
|
+
if (isLink) {
|
|
104
|
+
element = (
|
|
105
|
+
<a {...mergedProps} ref={elementRef} css={styles?.item}>
|
|
106
|
+
{content}
|
|
107
|
+
</a>
|
|
108
|
+
)
|
|
109
|
+
} else {
|
|
110
|
+
element = (
|
|
111
|
+
<button {...mergedProps} ref={elementRef} css={styles?.item}>
|
|
112
|
+
{content}
|
|
113
|
+
</button>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<li>
|
|
119
|
+
{collapsed ? (
|
|
120
|
+
<Tooltip renderTip={label} placement="end">
|
|
121
|
+
{/* Tooltip overwrites the aria-expanded of its trigger, so the span is the trigger */}
|
|
122
|
+
<span css={styles?.tooltipTrigger}>{element}</span>
|
|
123
|
+
</Tooltip>
|
|
124
|
+
) : (
|
|
125
|
+
element
|
|
126
|
+
)}
|
|
127
|
+
</li>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default MainNavItem
|
|
132
|
+
export { MainNavItem }
|