@instructure/ui-side-nav-bar 8.38.2-snapshot-11
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 +53 -0
- package/es/SideNavBar/SideNavBarItem/SideNavBarItemLocator.js +33 -0
- package/es/SideNavBar/SideNavBarItem/index.js +107 -0
- package/es/SideNavBar/SideNavBarItem/locator.js +26 -0
- package/es/SideNavBar/SideNavBarItem/props.js +36 -0
- package/es/SideNavBar/SideNavBarItem/styles.js +93 -0
- package/es/SideNavBar/SideNavBarItem/theme.js +73 -0
- package/es/SideNavBar/SideNavBarLocator.js +37 -0
- package/es/SideNavBar/index.js +130 -0
- package/es/SideNavBar/locator.js +27 -0
- package/es/SideNavBar/props.js +42 -0
- package/es/SideNavBar/styles.js +77 -0
- package/es/SideNavBar/theme.js +61 -0
- package/es/index.js +25 -0
- package/lib/SideNavBar/SideNavBarItem/SideNavBarItemLocator.js +41 -0
- package/lib/SideNavBar/SideNavBarItem/index.js +115 -0
- package/lib/SideNavBar/SideNavBarItem/locator.js +38 -0
- package/lib/SideNavBar/SideNavBarItem/props.js +45 -0
- package/lib/SideNavBar/SideNavBarItem/styles.js +100 -0
- package/lib/SideNavBar/SideNavBarItem/theme.js +80 -0
- package/lib/SideNavBar/SideNavBarLocator.js +49 -0
- package/lib/SideNavBar/index.js +147 -0
- package/lib/SideNavBar/locator.js +44 -0
- package/lib/SideNavBar/props.js +51 -0
- package/lib/SideNavBar/styles.js +84 -0
- package/lib/SideNavBar/theme.js +68 -0
- package/lib/index.js +18 -0
- package/lib/package.json +1 -0
- package/package.json +61 -0
- package/src/SideNavBar/README.md +74 -0
- package/src/SideNavBar/SideNavBarItem/SideNavBarItemLocator.ts +34 -0
- package/src/SideNavBar/SideNavBarItem/index.tsx +118 -0
- package/src/SideNavBar/SideNavBarItem/locator.ts +27 -0
- package/src/SideNavBar/SideNavBarItem/props.ts +102 -0
- package/src/SideNavBar/SideNavBarItem/styles.ts +103 -0
- package/src/SideNavBar/SideNavBarItem/theme.ts +82 -0
- package/src/SideNavBar/SideNavBarLocator.ts +40 -0
- package/src/SideNavBar/index.tsx +160 -0
- package/src/SideNavBar/locator.ts +29 -0
- package/src/SideNavBar/props.ts +118 -0
- package/src/SideNavBar/styles.ts +83 -0
- package/src/SideNavBar/theme.ts +66 -0
- package/src/index.ts +28 -0
- package/tsconfig.build.json +34 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/SideNavBar/SideNavBarItem/SideNavBarItemLocator.d.ts +576 -0
- package/types/SideNavBar/SideNavBarItem/SideNavBarItemLocator.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarItem/index.d.ts +48 -0
- package/types/SideNavBar/SideNavBarItem/index.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarItem/locator.d.ts +4 -0
- package/types/SideNavBar/SideNavBarItem/locator.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarItem/props.d.ts +46 -0
- package/types/SideNavBar/SideNavBarItem/props.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarItem/styles.d.ts +15 -0
- package/types/SideNavBar/SideNavBarItem/styles.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarItem/theme.d.ts +10 -0
- package/types/SideNavBar/SideNavBarItem/theme.d.ts.map +1 -0
- package/types/SideNavBar/SideNavBarLocator.d.ts +1983 -0
- package/types/SideNavBar/SideNavBarLocator.d.ts.map +1 -0
- package/types/SideNavBar/index.d.ts +59 -0
- package/types/SideNavBar/index.d.ts.map +1 -0
- package/types/SideNavBar/locator.d.ts +5 -0
- package/types/SideNavBar/locator.d.ts.map +1 -0
- package/types/SideNavBar/props.d.ts +49 -0
- package/types/SideNavBar/props.d.ts.map +1 -0
- package/types/SideNavBar/styles.d.ts +15 -0
- package/types/SideNavBar/styles.d.ts.map +1 -0
- package/types/SideNavBar/theme.d.ts +10 -0
- package/types/SideNavBar/theme.d.ts.map +1 -0
- package/types/index.d.ts +4 -0
- package/types/index.d.ts.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [8.38.2-snapshot-11](https://github.com/instructure/instructure-ui/compare/v8.38.1...v8.38.2-snapshot-11) (2023-07-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **instui-config,shared-types,ui-navigation,ui-side-nav-bar,ui:** add side-nav-bar component and deprecate navigation ([45848bf](https://github.com/instructure/instructure-ui/commit/45848bf5feea16e05c19e559c03e53e4b0637412))
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: packages
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## ui-side-nav-bar
|
|
6
|
+
|
|
7
|
+
[![npm][npm]][npm-url]
|
|
8
|
+
[![MIT License][license-badge]][license]
|
|
9
|
+
[![Code of Conduct][coc-badge]][coc]
|
|
10
|
+
|
|
11
|
+
Main and application level navigational components.
|
|
12
|
+
|
|
13
|
+
### Components
|
|
14
|
+
|
|
15
|
+
The `ui-side-nav-bar` package contains the following:
|
|
16
|
+
|
|
17
|
+
- [SideNavBar](#SideNavBar)
|
|
18
|
+
- [AppNav](#AppNav)
|
|
19
|
+
|
|
20
|
+
### Installation
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
yarn add @instructure/ui-side-nav-bar
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Usage
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import React from 'react'
|
|
30
|
+
import { SideNavBar } from '@instructure/ui-side-nav-bar'
|
|
31
|
+
import { Avatar } from '@instructure/ui-avatar'
|
|
32
|
+
|
|
33
|
+
const MySideNavBar = () => {
|
|
34
|
+
return (
|
|
35
|
+
<SideNavBar label="My SideNavBar">
|
|
36
|
+
<SideNavBar.Item
|
|
37
|
+
icon={<Avatar name="Joel Andrews" size="x-small" />}
|
|
38
|
+
label="My Account"
|
|
39
|
+
href="http://example.com"
|
|
40
|
+
/>
|
|
41
|
+
</SideNavBar>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For detailed usage and documentation, see individual component examples.
|
|
47
|
+
|
|
48
|
+
[npm]: https://img.shields.io/npm/v/@instructure/ui-side-nav-bar.svg
|
|
49
|
+
[npm-url]: https://npmjs.com/package/@instructure/ui-side-nav-bar
|
|
50
|
+
[license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
|
|
51
|
+
[license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE
|
|
52
|
+
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
|
|
53
|
+
[coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
26
|
+
// eslint-disable-next-line no-restricted-imports
|
|
27
|
+
import { TooltipLocator } from '@instructure/ui-tooltip/es/Tooltip/TooltipLocator';
|
|
28
|
+
import { SideNavBarItem } from './index';
|
|
29
|
+
|
|
30
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
31
|
+
export const SideNavBarItemLocator = locator(SideNavBarItem.selector, {
|
|
32
|
+
findTooltipContent: (...args) => TooltipLocator.findContent(...args)
|
|
33
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var _dec, _dec2, _class, _class2;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
/** @jsx jsx */
|
|
26
|
+
import { Component } from 'react';
|
|
27
|
+
import { testable } from '@instructure/ui-testable';
|
|
28
|
+
import { omitProps, getElementType } from '@instructure/ui-react-utils';
|
|
29
|
+
import { Tooltip } from '@instructure/ui-tooltip';
|
|
30
|
+
import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
31
|
+
import { withStyle, jsx } from '@instructure/emotion';
|
|
32
|
+
import generateStyle from './styles';
|
|
33
|
+
import generateComponentTheme from './theme';
|
|
34
|
+
import { allowedProps, propTypes } from './props';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
---
|
|
38
|
+
parent: SideNavBar
|
|
39
|
+
id: SideNavBar.Item
|
|
40
|
+
---
|
|
41
|
+
@tsProps
|
|
42
|
+
**/
|
|
43
|
+
let SideNavBarItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class SideNavBarItem extends Component {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this.handleRef = el => {
|
|
48
|
+
const elementRef = this.props.elementRef;
|
|
49
|
+
this.ref = el;
|
|
50
|
+
if (typeof elementRef === 'function') {
|
|
51
|
+
elementRef(el);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
var _this$props$makeStyle, _this$props;
|
|
57
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
58
|
+
minimized: this.props.minimized
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
componentDidUpdate() {
|
|
62
|
+
var _this$props$makeStyle2, _this$props2;
|
|
63
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
64
|
+
minimized: this.props.minimized
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
renderLink(addRef) {
|
|
68
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
69
|
+
const ElementType = getElementType(SideNavBarItem, this.props);
|
|
70
|
+
const _this$props3 = this.props,
|
|
71
|
+
href = _this$props3.href,
|
|
72
|
+
onClick = _this$props3.onClick,
|
|
73
|
+
icon = _this$props3.icon,
|
|
74
|
+
label = _this$props3.label;
|
|
75
|
+
const props = omitProps(this.props, SideNavBarItem.allowedProps);
|
|
76
|
+
return jsx(ElementType, Object.assign({}, props, {
|
|
77
|
+
href: href,
|
|
78
|
+
onClick: onClick,
|
|
79
|
+
ref: addRef ? this.handleRef : void 0,
|
|
80
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
|
|
81
|
+
"aria-label": this.props.minimized ? label : void 0
|
|
82
|
+
}), jsx("div", {
|
|
83
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
|
|
84
|
+
"aria-hidden": "true"
|
|
85
|
+
}, icon), !this.props.minimized ? jsx("div", {
|
|
86
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.label
|
|
87
|
+
}, label) : null);
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
const _this$props4 = this.props,
|
|
91
|
+
minimized = _this$props4.minimized,
|
|
92
|
+
label = _this$props4.label;
|
|
93
|
+
const hasTooltip = minimized && hasVisibleChildren(label);
|
|
94
|
+
const link = this.renderLink(!hasTooltip);
|
|
95
|
+
return hasTooltip ? jsx(Tooltip, {
|
|
96
|
+
renderTip: label,
|
|
97
|
+
placement: "end",
|
|
98
|
+
elementRef: this.handleRef
|
|
99
|
+
}, link) : link;
|
|
100
|
+
}
|
|
101
|
+
}, _class2.displayName = "SideNavBarItem", _class2.componentId = 'SideNavBar.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
102
|
+
as: 'a',
|
|
103
|
+
selected: false,
|
|
104
|
+
minimized: false
|
|
105
|
+
}, _class2)) || _class) || _class);
|
|
106
|
+
export default SideNavBarItem;
|
|
107
|
+
export { SideNavBarItem };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { SideNavBarItemLocator } from './SideNavBarItemLocator';
|
|
25
|
+
export { SideNavBarItemLocator };
|
|
26
|
+
export default SideNavBarItemLocator;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
25
|
+
const propTypes = {
|
|
26
|
+
elementRef: PropTypes.func,
|
|
27
|
+
icon: PropTypes.node.isRequired,
|
|
28
|
+
label: PropTypes.node.isRequired,
|
|
29
|
+
as: PropTypes.elementType,
|
|
30
|
+
href: PropTypes.string,
|
|
31
|
+
onClick: PropTypes.func,
|
|
32
|
+
selected: PropTypes.bool,
|
|
33
|
+
minimized: PropTypes.bool
|
|
34
|
+
};
|
|
35
|
+
const allowedProps = ['elementRef', 'icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
36
|
+
export { propTypes, allowedProps };
|
|
@@ -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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (componentTheme, props) => {
|
|
36
|
+
const selected = props.selected;
|
|
37
|
+
return {
|
|
38
|
+
navigationItem: {
|
|
39
|
+
label: 'navigationItem',
|
|
40
|
+
fontFamily: componentTheme.fontFamily,
|
|
41
|
+
fontWeight: componentTheme.fontWeight,
|
|
42
|
+
display: 'block',
|
|
43
|
+
width: '100%',
|
|
44
|
+
textAlign: 'center',
|
|
45
|
+
padding: componentTheme.contentPadding,
|
|
46
|
+
cursor: 'pointer',
|
|
47
|
+
border: 'none',
|
|
48
|
+
boxSizing: 'border-box',
|
|
49
|
+
textDecoration: componentTheme.linkTextDecoration,
|
|
50
|
+
overflowWrap: 'break-word',
|
|
51
|
+
wordWrap: 'break-word',
|
|
52
|
+
hyphens: 'auto',
|
|
53
|
+
...(selected ? {
|
|
54
|
+
backgroundColor: componentTheme.selectedBackgroundColor,
|
|
55
|
+
fill: componentTheme.selectedIconColor,
|
|
56
|
+
color: componentTheme.selectedFontColor,
|
|
57
|
+
'&:active, &:hover': {
|
|
58
|
+
backgroundColor: componentTheme.selectedBackgroundColor
|
|
59
|
+
},
|
|
60
|
+
'&:focus': {
|
|
61
|
+
backgroundColor: componentTheme.selectedBackgroundColor,
|
|
62
|
+
boxShadow: `${componentTheme.selectedOuterFocusOutline}, ${componentTheme.selectedInnerFocusOutline}`,
|
|
63
|
+
outline: 'none'
|
|
64
|
+
}
|
|
65
|
+
} : {
|
|
66
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
67
|
+
color: componentTheme.fontColor,
|
|
68
|
+
'&:active': {
|
|
69
|
+
backgroundColor: componentTheme.hoverBackgroundColor
|
|
70
|
+
},
|
|
71
|
+
'&:hover': {
|
|
72
|
+
backgroundColor: componentTheme.hoverBackgroundColor
|
|
73
|
+
},
|
|
74
|
+
'&:focus': {
|
|
75
|
+
backgroundColor: componentTheme.hoverBackgroundColor,
|
|
76
|
+
boxShadow: `${componentTheme.outerFocusOutline}, ${componentTheme.innerFocusOutline}`,
|
|
77
|
+
outline: 'none'
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
icon: {
|
|
82
|
+
label: 'navigationItem__icon',
|
|
83
|
+
fontSize: componentTheme.iconSize,
|
|
84
|
+
fill: componentTheme.iconColor
|
|
85
|
+
},
|
|
86
|
+
label: {
|
|
87
|
+
label: 'navigationItem__label',
|
|
88
|
+
fontSize: componentTheme.fontSize,
|
|
89
|
+
lineHeight: componentTheme.lineHeight
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export default generateStyle;
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
27
|
+
* @param {Object} theme The actual theme object.
|
|
28
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
29
|
+
*/
|
|
30
|
+
const generateComponentTheme = theme => {
|
|
31
|
+
const colors = theme.colors,
|
|
32
|
+
spacing = theme.spacing,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
themeName = theme.key;
|
|
35
|
+
const themeSpecificStyle = {
|
|
36
|
+
canvas: {
|
|
37
|
+
fontColor: theme['ic-brand-global-nav-menu-item__text-color'],
|
|
38
|
+
iconColor: theme['ic-brand-global-nav-ic-icon-svg-fill'],
|
|
39
|
+
backgroundColor: theme['ic-brand-global-nav-bgd'],
|
|
40
|
+
hoverBackgroundColor: theme['ic-global-nav-link-hover'],
|
|
41
|
+
selectedFontColor: theme['ic-brand-global-nav-menu-item__text-color--active'],
|
|
42
|
+
selectedIconColor: theme['ic-brand-global-nav-ic-icon-svg-fill--active']
|
|
43
|
+
},
|
|
44
|
+
'canvas-high-contrast': {
|
|
45
|
+
linkTextDecoration: 'underline'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const componentVariables = {
|
|
49
|
+
fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
|
|
50
|
+
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
51
|
+
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightLight,
|
|
52
|
+
fontColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
53
|
+
iconSize: '1.625rem',
|
|
54
|
+
iconColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
55
|
+
lineHeight: typography === null || typography === void 0 ? void 0 : typography.lineHeight,
|
|
56
|
+
backgroundColor: 'transparent',
|
|
57
|
+
linkTextDecoration: 'none',
|
|
58
|
+
hoverBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundDarkest,
|
|
59
|
+
outerFocusOutline: `inset 0 0 0 0.125rem ${colors === null || colors === void 0 ? void 0 : colors.borderDarkest}`,
|
|
60
|
+
innerFocusOutline: `inset 0 0 0 0.25rem ${colors === null || colors === void 0 ? void 0 : colors.borderLightest}`,
|
|
61
|
+
selectedFontColor: colors === null || colors === void 0 ? void 0 : colors.textBrand,
|
|
62
|
+
selectedIconColor: colors === null || colors === void 0 ? void 0 : colors.textBrand,
|
|
63
|
+
selectedBackgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
64
|
+
selectedOuterFocusOutline: `inset 0 0 0 0.125rem ${colors === null || colors === void 0 ? void 0 : colors.borderLightest}`,
|
|
65
|
+
selectedInnerFocusOutline: `inset 0 0 0 0.25rem ${colors === null || colors === void 0 ? void 0 : colors.borderBrand}`,
|
|
66
|
+
contentPadding: spacing === null || spacing === void 0 ? void 0 : spacing.xxSmall
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
...componentVariables,
|
|
70
|
+
...themeSpecificStyle[themeName]
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export default generateComponentTheme;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { SideNavBar } from './index';
|
|
26
|
+
import { SideNavBarItemLocator } from './SideNavBarItem/SideNavBarItemLocator';
|
|
27
|
+
export { SideNavBarItemLocator };
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
30
|
+
export const SideNavBarLocator = locator(SideNavBar.selector, {
|
|
31
|
+
findAllItems: (...args) => {
|
|
32
|
+
return SideNavBarItemLocator.findAll(...args);
|
|
33
|
+
},
|
|
34
|
+
findItem: (...args) => {
|
|
35
|
+
return SideNavBarItemLocator.find(...args);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var _dec, _dec2, _class, _class2;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
/** @jsx jsx */
|
|
26
|
+
import React, { Component, Children } from 'react';
|
|
27
|
+
import { testable } from '@instructure/ui-testable';
|
|
28
|
+
import { omitProps, safeCloneElement } from '@instructure/ui-react-utils';
|
|
29
|
+
import { IconMoveStartLine } from '@instructure/ui-icons';
|
|
30
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
31
|
+
import { withStyle, jsx } from '@instructure/emotion';
|
|
32
|
+
import { SideNavBarItem } from './SideNavBarItem';
|
|
33
|
+
import generateStyle from './styles';
|
|
34
|
+
import generateComponentTheme from './theme';
|
|
35
|
+
import { allowedProps, propTypes } from './props';
|
|
36
|
+
const navMinimized = ({
|
|
37
|
+
minimized
|
|
38
|
+
}) => ({
|
|
39
|
+
minimized: !minimized
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
---
|
|
44
|
+
category: components
|
|
45
|
+
---
|
|
46
|
+
@tsProps
|
|
47
|
+
**/
|
|
48
|
+
let SideNavBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class SideNavBar extends Component {
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
this.ref = null;
|
|
52
|
+
this.handleNavToggle = event => {
|
|
53
|
+
if (!this.isControlled()) {
|
|
54
|
+
this.setState(navMinimized);
|
|
55
|
+
}
|
|
56
|
+
if (typeof this.props.onMinimized === 'function') {
|
|
57
|
+
this.props.onMinimized(event, !this.minimized);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this.state = {
|
|
61
|
+
minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
var _this$props$makeStyle, _this$props;
|
|
66
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
67
|
+
minimized: this.minimized
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
componentDidUpdate() {
|
|
71
|
+
var _this$props$makeStyle2, _this$props2;
|
|
72
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
73
|
+
minimized: this.minimized
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
get minimized() {
|
|
77
|
+
if (this.isControlled()) {
|
|
78
|
+
return !!this.props.minimized;
|
|
79
|
+
}
|
|
80
|
+
return !!this.state.minimized;
|
|
81
|
+
}
|
|
82
|
+
isControlled(props = this.props) {
|
|
83
|
+
return typeof props.minimized === 'boolean';
|
|
84
|
+
}
|
|
85
|
+
renderChildren() {
|
|
86
|
+
return Children.map(this.props.children, child => {
|
|
87
|
+
var _this$props$styles;
|
|
88
|
+
const navItem = safeCloneElement(child, {
|
|
89
|
+
minimized: this.state.minimized
|
|
90
|
+
});
|
|
91
|
+
return jsx("li", {
|
|
92
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.list
|
|
93
|
+
}, navItem);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
toggleMessage() {
|
|
97
|
+
return this.state.minimized ? this.props.toggleLabel.minimizedLabel : this.props.toggleLabel.expandedLabel;
|
|
98
|
+
}
|
|
99
|
+
render() {
|
|
100
|
+
var _this$props$styles2, _this$props$styles3, _this$props$styles4, _this$props$styles5;
|
|
101
|
+
const label = this.props.label;
|
|
102
|
+
const props = omitProps(this.props, SideNavBar.allowedProps, ['minimized']);
|
|
103
|
+
return jsx("nav", Object.assign({}, props, {
|
|
104
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.navigation,
|
|
105
|
+
"aria-label": label,
|
|
106
|
+
ref: element => {
|
|
107
|
+
this.ref = element;
|
|
108
|
+
}
|
|
109
|
+
}), jsx("ul", {
|
|
110
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.content
|
|
111
|
+
}, this.renderChildren()), jsx("div", {
|
|
112
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle
|
|
113
|
+
}, jsx(SideNavBarItem, {
|
|
114
|
+
"aria-expanded": !this.minimized,
|
|
115
|
+
onClick: this.handleNavToggle,
|
|
116
|
+
icon: jsx(IconMoveStartLine, {
|
|
117
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.toggleIcon,
|
|
118
|
+
inline: false
|
|
119
|
+
}),
|
|
120
|
+
label: jsx(ScreenReaderContent, null, this.toggleMessage())
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
}, _class2.displayName = "SideNavBar", _class2.componentId = 'SideNavBar', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
124
|
+
children: null,
|
|
125
|
+
defaultMinimized: false,
|
|
126
|
+
// TODO we should investigate later if it used or not
|
|
127
|
+
onClick: function (_e) {}
|
|
128
|
+
}, _class2.Item = SideNavBarItem, _class2)) || _class) || _class);
|
|
129
|
+
export default SideNavBar;
|
|
130
|
+
export { SideNavBar, SideNavBarItem };
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { SideNavBarLocator } from './SideNavBarLocator';
|
|
25
|
+
export { SideNavBarItemLocator } from './SideNavBarLocator';
|
|
26
|
+
export { SideNavBarLocator };
|
|
27
|
+
export default SideNavBarLocator;
|