@instructure/ui-navigation 8.56.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +2 -23
- package/es/index.js +1 -2
- package/lib/index.js +1 -14
- package/package.json +24 -24
- package/src/index.ts +0 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +1 -1
- package/es/Navigation/NavigationItem/NavigationItemLocator.js +0 -33
- package/es/Navigation/NavigationItem/index.js +0 -106
- package/es/Navigation/NavigationItem/locator.js +0 -26
- package/es/Navigation/NavigationItem/props.js +0 -36
- package/es/Navigation/NavigationItem/styles.js +0 -93
- package/es/Navigation/NavigationItem/theme.js +0 -73
- package/es/Navigation/NavigationLocator.js +0 -37
- package/es/Navigation/index.js +0 -129
- package/es/Navigation/locator.js +0 -27
- package/es/Navigation/props.js +0 -42
- package/es/Navigation/styles.js +0 -77
- package/es/Navigation/theme.js +0 -61
- package/lib/Navigation/NavigationItem/NavigationItemLocator.js +0 -40
- package/lib/Navigation/NavigationItem/index.js +0 -112
- package/lib/Navigation/NavigationItem/locator.js +0 -37
- package/lib/Navigation/NavigationItem/props.js +0 -43
- package/lib/Navigation/NavigationItem/styles.js +0 -99
- package/lib/Navigation/NavigationItem/theme.js +0 -79
- package/lib/Navigation/NavigationLocator.js +0 -48
- package/lib/Navigation/index.js +0 -145
- package/lib/Navigation/locator.js +0 -43
- package/lib/Navigation/props.js +0 -49
- package/lib/Navigation/styles.js +0 -83
- package/lib/Navigation/theme.js +0 -67
- package/src/Navigation/NavigationItem/NavigationItemLocator.ts +0 -34
- package/src/Navigation/NavigationItem/index.tsx +0 -117
- package/src/Navigation/NavigationItem/locator.ts +0 -27
- package/src/Navigation/NavigationItem/props.ts +0 -102
- package/src/Navigation/NavigationItem/styles.ts +0 -103
- package/src/Navigation/NavigationItem/theme.ts +0 -82
- package/src/Navigation/NavigationLocator.ts +0 -40
- package/src/Navigation/README.md +0 -85
- package/src/Navigation/index.tsx +0 -168
- package/src/Navigation/locator.ts +0 -29
- package/src/Navigation/props.ts +0 -118
- package/src/Navigation/styles.ts +0 -83
- package/src/Navigation/theme.ts +0 -66
- package/types/Navigation/NavigationItem/NavigationItemLocator.d.ts +0 -576
- package/types/Navigation/NavigationItem/NavigationItemLocator.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/index.d.ts +0 -47
- package/types/Navigation/NavigationItem/index.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/locator.d.ts +0 -4
- package/types/Navigation/NavigationItem/locator.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/props.d.ts +0 -46
- package/types/Navigation/NavigationItem/props.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/styles.d.ts +0 -15
- package/types/Navigation/NavigationItem/styles.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/theme.d.ts +0 -10
- package/types/Navigation/NavigationItem/theme.d.ts.map +0 -1
- package/types/Navigation/NavigationLocator.d.ts +0 -1983
- package/types/Navigation/NavigationLocator.d.ts.map +0 -1
- package/types/Navigation/index.d.ts +0 -58
- package/types/Navigation/index.d.ts.map +0 -1
- package/types/Navigation/locator.d.ts +0 -5
- package/types/Navigation/locator.d.ts.map +0 -1
- package/types/Navigation/props.d.ts +0 -49
- package/types/Navigation/props.d.ts.map +0 -1
- package/types/Navigation/styles.d.ts +0 -15
- package/types/Navigation/styles.d.ts.map +0 -1
- package/types/Navigation/theme.d.ts +0 -10
- package/types/Navigation/theme.d.ts.map +0 -1
|
@@ -1,103 +0,0 @@
|
|
|
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 { NavigationItemTheme } from '@instructure/shared-types'
|
|
26
|
-
import type { NavigationItemProps, NavigationItemStyle } from './props'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* ---
|
|
30
|
-
* private: true
|
|
31
|
-
* ---
|
|
32
|
-
* Generates the style object from the theme and provided additional information
|
|
33
|
-
* @param {Object} componentTheme The theme variable object.
|
|
34
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
36
|
-
* @return {Object} The final style object, which will be used in the component
|
|
37
|
-
*/
|
|
38
|
-
const generateStyle = (
|
|
39
|
-
componentTheme: NavigationItemTheme,
|
|
40
|
-
props: NavigationItemProps
|
|
41
|
-
): NavigationItemStyle => {
|
|
42
|
-
const { selected } = props
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
navigationItem: {
|
|
46
|
-
label: 'navigationItem',
|
|
47
|
-
fontFamily: componentTheme.fontFamily,
|
|
48
|
-
fontWeight: componentTheme.fontWeight,
|
|
49
|
-
display: 'block',
|
|
50
|
-
width: '100%',
|
|
51
|
-
textAlign: 'center',
|
|
52
|
-
padding: componentTheme.contentPadding,
|
|
53
|
-
cursor: 'pointer',
|
|
54
|
-
border: 'none',
|
|
55
|
-
boxSizing: 'border-box',
|
|
56
|
-
textDecoration: componentTheme.linkTextDecoration,
|
|
57
|
-
overflowWrap: 'break-word',
|
|
58
|
-
wordWrap: 'break-word',
|
|
59
|
-
hyphens: 'auto',
|
|
60
|
-
...(selected
|
|
61
|
-
? {
|
|
62
|
-
backgroundColor: componentTheme.selectedBackgroundColor,
|
|
63
|
-
fill: componentTheme.selectedIconColor,
|
|
64
|
-
color: componentTheme.selectedFontColor,
|
|
65
|
-
'&:active, &:hover': {
|
|
66
|
-
backgroundColor: componentTheme.selectedBackgroundColor
|
|
67
|
-
},
|
|
68
|
-
'&:focus': {
|
|
69
|
-
backgroundColor: componentTheme.selectedBackgroundColor,
|
|
70
|
-
boxShadow: `${componentTheme.selectedOuterFocusOutline}, ${componentTheme.selectedInnerFocusOutline}`,
|
|
71
|
-
outline: 'none'
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
: {
|
|
75
|
-
backgroundColor: componentTheme.backgroundColor,
|
|
76
|
-
color: componentTheme.fontColor,
|
|
77
|
-
'&:active': {
|
|
78
|
-
backgroundColor: componentTheme.hoverBackgroundColor
|
|
79
|
-
},
|
|
80
|
-
'&:hover': {
|
|
81
|
-
backgroundColor: componentTheme.hoverBackgroundColor
|
|
82
|
-
},
|
|
83
|
-
'&:focus': {
|
|
84
|
-
backgroundColor: componentTheme.hoverBackgroundColor,
|
|
85
|
-
boxShadow: `${componentTheme.outerFocusOutline}, ${componentTheme.innerFocusOutline}`,
|
|
86
|
-
outline: 'none'
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
},
|
|
90
|
-
icon: {
|
|
91
|
-
label: 'navigationItem__icon',
|
|
92
|
-
fontSize: componentTheme.iconSize,
|
|
93
|
-
fill: componentTheme.iconColor
|
|
94
|
-
},
|
|
95
|
-
label: {
|
|
96
|
-
label: 'navigationItem__label',
|
|
97
|
-
fontSize: componentTheme.fontSize,
|
|
98
|
-
lineHeight: componentTheme.lineHeight
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default generateStyle
|
|
@@ -1,82 +0,0 @@
|
|
|
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 { Theme, ThemeSpecificStyle } from '@instructure/ui-themes'
|
|
26
|
-
import { NavigationItemTheme } from '@instructure/shared-types'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
30
|
-
* @param {Object} theme The actual theme object.
|
|
31
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
32
|
-
*/
|
|
33
|
-
const generateComponentTheme = (theme: Theme): NavigationItemTheme => {
|
|
34
|
-
const { colors, spacing, typography, key: themeName } = theme
|
|
35
|
-
|
|
36
|
-
const themeSpecificStyle: ThemeSpecificStyle<NavigationItemTheme> = {
|
|
37
|
-
canvas: {
|
|
38
|
-
fontColor: theme['ic-brand-global-nav-menu-item__text-color'],
|
|
39
|
-
iconColor: theme['ic-brand-global-nav-ic-icon-svg-fill'],
|
|
40
|
-
backgroundColor: theme['ic-brand-global-nav-bgd'],
|
|
41
|
-
hoverBackgroundColor: theme['ic-global-nav-link-hover'],
|
|
42
|
-
selectedFontColor:
|
|
43
|
-
theme['ic-brand-global-nav-menu-item__text-color--active'],
|
|
44
|
-
selectedIconColor: theme['ic-brand-global-nav-ic-icon-svg-fill--active']
|
|
45
|
-
},
|
|
46
|
-
'canvas-high-contrast': {
|
|
47
|
-
linkTextDecoration: 'underline'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const componentVariables: NavigationItemTheme = {
|
|
52
|
-
fontSize: typography?.fontSizeSmall,
|
|
53
|
-
fontFamily: typography?.fontFamily,
|
|
54
|
-
fontWeight: typography?.fontWeightLight,
|
|
55
|
-
|
|
56
|
-
fontColor: colors?.textLightest,
|
|
57
|
-
iconSize: '1.625rem',
|
|
58
|
-
iconColor: colors?.textLightest,
|
|
59
|
-
lineHeight: typography?.lineHeight,
|
|
60
|
-
backgroundColor: 'transparent',
|
|
61
|
-
linkTextDecoration: 'none',
|
|
62
|
-
|
|
63
|
-
hoverBackgroundColor: colors?.backgroundDarkest,
|
|
64
|
-
outerFocusOutline: `inset 0 0 0 0.125rem ${colors?.borderDarkest}`,
|
|
65
|
-
innerFocusOutline: `inset 0 0 0 0.25rem ${colors?.borderLightest}`,
|
|
66
|
-
|
|
67
|
-
selectedFontColor: colors?.textBrand,
|
|
68
|
-
selectedIconColor: colors?.textBrand,
|
|
69
|
-
selectedBackgroundColor: colors?.backgroundLightest,
|
|
70
|
-
selectedOuterFocusOutline: `inset 0 0 0 0.125rem ${colors?.borderLightest}`,
|
|
71
|
-
selectedInnerFocusOutline: `inset 0 0 0 0.25rem ${colors?.borderBrand}`,
|
|
72
|
-
|
|
73
|
-
contentPadding: spacing?.xxSmall
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
...componentVariables,
|
|
78
|
-
...themeSpecificStyle[themeName]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default generateComponentTheme
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
import { locator } from '@instructure/ui-test-locator'
|
|
25
|
-
|
|
26
|
-
import { Navigation } from './index'
|
|
27
|
-
import { NavigationItemLocator } from './NavigationItem/NavigationItemLocator'
|
|
28
|
-
|
|
29
|
-
export { NavigationItemLocator }
|
|
30
|
-
|
|
31
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
32
|
-
export const NavigationLocator = locator(Navigation.selector, {
|
|
33
|
-
findAllItems: (...args: any[]) => {
|
|
34
|
-
return NavigationItemLocator.findAll(...args)
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
findItem: (...args: any[]) => {
|
|
38
|
-
return NavigationItemLocator.find(...args)
|
|
39
|
-
}
|
|
40
|
-
})
|
package/src/Navigation/README.md
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
describes: Navigation
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
A top-level `Navigation` component.
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
---
|
|
9
|
-
type: embed
|
|
10
|
-
---
|
|
11
|
-
<ToggleBlockquote
|
|
12
|
-
summary="DEPRECATED"
|
|
13
|
-
>
|
|
14
|
-
<ToggleBlockquote.Paragraph>
|
|
15
|
-
This component is deprecated. Please use <Link href="#SideNavBar">SideNavBar</Link> instead.
|
|
16
|
-
</ToggleBlockquote.Paragraph>
|
|
17
|
-
</ToggleBlockquote>
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
---
|
|
22
|
-
type: example
|
|
23
|
-
---
|
|
24
|
-
<div style={{height: '35rem'}}>
|
|
25
|
-
<Navigation
|
|
26
|
-
label="Main navigation"
|
|
27
|
-
toggleLabel={{
|
|
28
|
-
expandedLabel: 'Minimize Navigation',
|
|
29
|
-
minimizedLabel: 'Expand Navigation'
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
<Navigation.Item
|
|
33
|
-
icon={<IconUserLine />}
|
|
34
|
-
label={<ScreenReaderContent>Home</ScreenReaderContent>}
|
|
35
|
-
href="#"
|
|
36
|
-
themeOverride={{
|
|
37
|
-
backgroundColor: 'red',
|
|
38
|
-
hoverBackgroundColor: 'blue'
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
<Navigation.Item
|
|
42
|
-
icon={<Avatar name="Ziggy Marley" size="x-small"/>}
|
|
43
|
-
label="Account"
|
|
44
|
-
onClick={() => { this.loadSubNav('account') }}
|
|
45
|
-
/>
|
|
46
|
-
<Navigation.Item
|
|
47
|
-
icon={<IconAdminLine />}
|
|
48
|
-
label="Admin"
|
|
49
|
-
href="#"
|
|
50
|
-
/>
|
|
51
|
-
<Navigation.Item selected
|
|
52
|
-
icon={<IconDashboardLine />}
|
|
53
|
-
label="Dashboard"
|
|
54
|
-
href="#"
|
|
55
|
-
/>
|
|
56
|
-
<Navigation.Item
|
|
57
|
-
icon={<Badge count={99}><IconInboxLine /></Badge>}
|
|
58
|
-
label="Inbox"
|
|
59
|
-
href="#"
|
|
60
|
-
/>
|
|
61
|
-
<Navigation.Item
|
|
62
|
-
icon={<IconUserLine />}
|
|
63
|
-
label="Supercalifragilistic"
|
|
64
|
-
href="#"
|
|
65
|
-
/>
|
|
66
|
-
</Navigation>
|
|
67
|
-
</div>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Guidelines
|
|
71
|
-
|
|
72
|
-
```js
|
|
73
|
-
---
|
|
74
|
-
type: embed
|
|
75
|
-
---
|
|
76
|
-
<Guidelines>
|
|
77
|
-
<Figure recommendation="yes" title="Do">
|
|
78
|
-
<Figure.Item>Use for top-level Navigation</Figure.Item>
|
|
79
|
-
<Figure.Item>Remember that Navigation can be themed by the institution</Figure.Item>
|
|
80
|
-
</Figure>
|
|
81
|
-
<Figure recommendation="no" title="Don't">
|
|
82
|
-
<Figure.Item>Add LTI links to the main area</Figure.Item>
|
|
83
|
-
</Figure>
|
|
84
|
-
</Guidelines>
|
|
85
|
-
```
|
package/src/Navigation/index.tsx
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
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
|
-
/** @jsx jsx */
|
|
25
|
-
import React, { Component, Children, ReactElement } from 'react'
|
|
26
|
-
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
omitProps,
|
|
31
|
-
safeCloneElement,
|
|
32
|
-
deprecated
|
|
33
|
-
} from '@instructure/ui-react-utils'
|
|
34
|
-
import { IconMoveStartLine } from '@instructure/ui-icons'
|
|
35
|
-
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
36
|
-
import { withStyle, jsx } from '@instructure/emotion'
|
|
37
|
-
|
|
38
|
-
import { NavigationItem } from './NavigationItem'
|
|
39
|
-
|
|
40
|
-
import generateStyle from './styles'
|
|
41
|
-
import generateComponentTheme from './theme'
|
|
42
|
-
import type { NavigationProps, NavigationState } from './props'
|
|
43
|
-
import { allowedProps, propTypes } from './props'
|
|
44
|
-
|
|
45
|
-
const navMinimized = ({ minimized }: { minimized: boolean }) => ({
|
|
46
|
-
minimized: !minimized
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
---
|
|
51
|
-
category: components/deprecated
|
|
52
|
-
---
|
|
53
|
-
**/
|
|
54
|
-
|
|
55
|
-
@withStyle(generateStyle, generateComponentTheme)
|
|
56
|
-
@testable()
|
|
57
|
-
@deprecated(
|
|
58
|
-
'9.0.0',
|
|
59
|
-
null,
|
|
60
|
-
'This component is deprecated and will be removed in a later version. Use <SideNavBar /> instead.'
|
|
61
|
-
)
|
|
62
|
-
class Navigation extends Component<NavigationProps, NavigationState> {
|
|
63
|
-
static readonly componentId = 'Navigation'
|
|
64
|
-
|
|
65
|
-
static allowedProps = allowedProps
|
|
66
|
-
static propTypes = propTypes
|
|
67
|
-
|
|
68
|
-
static defaultProps = {
|
|
69
|
-
children: null,
|
|
70
|
-
defaultMinimized: false,
|
|
71
|
-
// TODO we should investigate later if it used or not
|
|
72
|
-
onClick: function (_e: React.MouseEvent) {}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static Item = NavigationItem
|
|
76
|
-
|
|
77
|
-
ref: Element | null = null
|
|
78
|
-
|
|
79
|
-
constructor(props: NavigationProps) {
|
|
80
|
-
super(props)
|
|
81
|
-
|
|
82
|
-
this.state = {
|
|
83
|
-
minimized: this.isControlled(props)
|
|
84
|
-
? !!props.minimized
|
|
85
|
-
: !!props.defaultMinimized
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
componentDidMount() {
|
|
90
|
-
this.props.makeStyles?.({ minimized: this.minimized })
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
componentDidUpdate() {
|
|
94
|
-
this.props.makeStyles?.({ minimized: this.minimized })
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get minimized() {
|
|
98
|
-
if (this.isControlled()) {
|
|
99
|
-
return !!this.props.minimized
|
|
100
|
-
}
|
|
101
|
-
return !!this.state.minimized
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
isControlled(props = this.props) {
|
|
105
|
-
return typeof props.minimized === 'boolean'
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
handleNavToggle = (event: React.SyntheticEvent) => {
|
|
109
|
-
if (!this.isControlled()) {
|
|
110
|
-
this.setState(navMinimized)
|
|
111
|
-
}
|
|
112
|
-
if (typeof this.props.onMinimized === 'function') {
|
|
113
|
-
this.props.onMinimized(event, !this.minimized)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
renderChildren() {
|
|
118
|
-
return Children.map(this.props.children, (child) => {
|
|
119
|
-
const navItem = safeCloneElement(child as ReactElement, {
|
|
120
|
-
minimized: this.state.minimized
|
|
121
|
-
})
|
|
122
|
-
return <li css={this.props.styles?.list}>{navItem}</li>
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
toggleMessage() {
|
|
127
|
-
return this.state.minimized
|
|
128
|
-
? this.props.toggleLabel.minimizedLabel
|
|
129
|
-
: this.props.toggleLabel.expandedLabel
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
render() {
|
|
133
|
-
const { label } = this.props
|
|
134
|
-
|
|
135
|
-
const props = omitProps(this.props, Navigation.allowedProps, ['minimized'])
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<nav
|
|
139
|
-
{...props}
|
|
140
|
-
css={this.props.styles?.navigation}
|
|
141
|
-
aria-label={label}
|
|
142
|
-
ref={(element) => {
|
|
143
|
-
this.ref = element
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
<ul css={this.props.styles?.content}>{this.renderChildren()}</ul>
|
|
147
|
-
<div css={this.props.styles?.toggle}>
|
|
148
|
-
<NavigationItem
|
|
149
|
-
aria-expanded={!this.minimized}
|
|
150
|
-
onClick={this.handleNavToggle}
|
|
151
|
-
icon={
|
|
152
|
-
<IconMoveStartLine
|
|
153
|
-
css={this.props.styles?.toggleIcon}
|
|
154
|
-
inline={false}
|
|
155
|
-
/>
|
|
156
|
-
}
|
|
157
|
-
label={
|
|
158
|
-
<ScreenReaderContent>{this.toggleMessage()}</ScreenReaderContent>
|
|
159
|
-
}
|
|
160
|
-
></NavigationItem>
|
|
161
|
-
</div>
|
|
162
|
-
</nav>
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export default Navigation
|
|
168
|
-
export { Navigation, NavigationItem }
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
import { NavigationLocator } from './NavigationLocator'
|
|
25
|
-
|
|
26
|
-
export { NavigationItemLocator } from './NavigationLocator'
|
|
27
|
-
|
|
28
|
-
export { NavigationLocator }
|
|
29
|
-
export default NavigationLocator
|
package/src/Navigation/props.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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
|
-
import React from 'react'
|
|
25
|
-
import PropTypes from 'prop-types'
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
controllable,
|
|
29
|
-
Children as ChildrenPropTypes
|
|
30
|
-
} from '@instructure/ui-prop-types'
|
|
31
|
-
|
|
32
|
-
import { NavigationItem } from './NavigationItem'
|
|
33
|
-
|
|
34
|
-
import type {
|
|
35
|
-
PropValidators,
|
|
36
|
-
NavigationTheme,
|
|
37
|
-
OtherHTMLAttributes
|
|
38
|
-
} from '@instructure/shared-types'
|
|
39
|
-
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
40
|
-
|
|
41
|
-
type NavigationOwnProps = {
|
|
42
|
-
/**
|
|
43
|
-
* When minimized is set to true, the `<Navigation />` shows icons only while the text becomes a tooltip. When it is set to false, the `<Navigation />` shows text in addition to the icons
|
|
44
|
-
*/
|
|
45
|
-
minimized?: boolean
|
|
46
|
-
/**
|
|
47
|
-
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
48
|
-
*/
|
|
49
|
-
defaultMinimized?: boolean
|
|
50
|
-
onMinimized?: (event: React.SyntheticEvent, minimized: boolean) => void
|
|
51
|
-
/**
|
|
52
|
-
* Screen reader label for the main Navigation
|
|
53
|
-
*/
|
|
54
|
-
label: string
|
|
55
|
-
/**
|
|
56
|
-
* Screen reader label for the toggle button expanded/minimized state
|
|
57
|
-
*/
|
|
58
|
-
toggleLabel: {
|
|
59
|
-
expandedLabel?: string
|
|
60
|
-
minimizedLabel?: string
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
64
|
-
*/
|
|
65
|
-
href?: string
|
|
66
|
-
/**
|
|
67
|
-
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
68
|
-
*/
|
|
69
|
-
onClick?: (event: React.MouseEvent) => void
|
|
70
|
-
/**
|
|
71
|
-
* children of type Navigation.Item
|
|
72
|
-
*/
|
|
73
|
-
children?: React.ReactNode
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type NavigationState = {
|
|
77
|
-
minimized: boolean
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
type PropKeys = keyof NavigationOwnProps
|
|
81
|
-
|
|
82
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
83
|
-
|
|
84
|
-
type NavigationProps = NavigationOwnProps &
|
|
85
|
-
WithStyleProps<NavigationTheme, NavigationStyle> &
|
|
86
|
-
OtherHTMLAttributes<NavigationOwnProps>
|
|
87
|
-
|
|
88
|
-
type NavigationStyle = ComponentStyle<
|
|
89
|
-
'navigation' | 'list' | 'content' | 'toggle' | 'toggleIcon'
|
|
90
|
-
>
|
|
91
|
-
|
|
92
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
93
|
-
children: ChildrenPropTypes.oneOf([NavigationItem]),
|
|
94
|
-
minimized: controllable(PropTypes.bool, 'onMinimized', 'defaultMinimized'),
|
|
95
|
-
defaultMinimized: PropTypes.bool,
|
|
96
|
-
onMinimized: PropTypes.func,
|
|
97
|
-
label: PropTypes.string.isRequired,
|
|
98
|
-
toggleLabel: PropTypes.shape({
|
|
99
|
-
expandedLabel: PropTypes.string,
|
|
100
|
-
minimizedLabel: PropTypes.string
|
|
101
|
-
}).isRequired,
|
|
102
|
-
href: PropTypes.string,
|
|
103
|
-
onClick: PropTypes.func
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const allowedProps: AllowedPropKeys = [
|
|
107
|
-
'children',
|
|
108
|
-
'minimized',
|
|
109
|
-
'defaultMinimized',
|
|
110
|
-
'onMinimized',
|
|
111
|
-
'label',
|
|
112
|
-
'toggleLabel',
|
|
113
|
-
'href',
|
|
114
|
-
'onClick'
|
|
115
|
-
]
|
|
116
|
-
|
|
117
|
-
export type { NavigationProps, NavigationState, NavigationStyle }
|
|
118
|
-
export { propTypes, allowedProps }
|