@instructure/ui-top-nav-bar 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 +18 -0
- package/es/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +0 -3
- package/es/TopNavBar/TopNavBarBrand/index.js +11 -13
- package/es/TopNavBar/TopNavBarBrand/props.js +1 -3
- package/es/TopNavBar/TopNavBarBrand/styles.js +1 -11
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/__new-tests__/TopNavBarDesktopLayout.test.js +4 -132
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +5 -7
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -4
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/__new-tests__/TopNavBarSmallViewportLayout.test.js +1 -2
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +1 -1
- package/es/TopNavBar/TopNavBarLayout/__new-tests__/TopNavBarLayout.test.js +0 -18
- package/es/TopNavBar/TopNavBarLayout/index.js +6 -4
- package/es/TopNavBar/TopNavBarLayout/props.js +1 -2
- package/es/TopNavBar/__new-tests__/TopNavBar.test.js +0 -1
- package/es/TopNavBar/utils/exampleHelpers.js +1 -8
- package/lib/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +0 -3
- package/lib/TopNavBar/TopNavBarBrand/index.js +10 -13
- package/lib/TopNavBar/TopNavBarBrand/props.js +1 -3
- package/lib/TopNavBar/TopNavBarBrand/styles.js +1 -11
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/__new-tests__/TopNavBarDesktopLayout.test.js +3 -131
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +4 -7
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -4
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/__new-tests__/TopNavBarSmallViewportLayout.test.js +1 -2
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +1 -1
- package/lib/TopNavBar/TopNavBarLayout/__new-tests__/TopNavBarLayout.test.js +0 -18
- package/lib/TopNavBar/TopNavBarLayout/index.js +6 -4
- package/lib/TopNavBar/TopNavBarLayout/props.js +1 -2
- package/lib/TopNavBar/__new-tests__/TopNavBar.test.js +0 -1
- package/lib/TopNavBar/utils/exampleHelpers.js +0 -7
- package/package.json +30 -30
- package/src/TopNavBar/README.md +2 -248
- package/src/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.ts +0 -3
- package/src/TopNavBar/TopNavBarBrand/index.tsx +17 -22
- package/src/TopNavBar/TopNavBarBrand/props.ts +1 -21
- package/src/TopNavBar/TopNavBarBrand/styles.ts +1 -10
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/__new-tests__/TopNavBarDesktopLayout.test.tsx +3 -173
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/index.tsx +2 -10
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/styles.ts +3 -5
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/__new-tests__/TopNavBarSmallViewportLayout.test.tsx +2 -2
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.tsx +1 -4
- package/src/TopNavBar/TopNavBarLayout/__new-tests__/TopNavBarLayout.test.tsx +0 -25
- package/src/TopNavBar/TopNavBarLayout/index.tsx +10 -3
- package/src/TopNavBar/TopNavBarLayout/props.ts +0 -7
- package/src/TopNavBar/__new-tests__/TopNavBar.test.tsx +0 -1
- package/src/TopNavBar/utils/exampleHelpers.tsx +1 -15
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts +1 -6
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBrand/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBrand/props.d.ts +1 -10
- package/types/TopNavBar/TopNavBarBrand/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBrand/styles.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts +2 -2
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/index.d.ts +3 -3
- package/types/TopNavBar/TopNavBarLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/props.d.ts +0 -4
- package/types/TopNavBar/TopNavBarLayout/props.d.ts.map +1 -1
- package/types/TopNavBar/utils/exampleHelpers.d.ts +0 -2
- package/types/TopNavBar/utils/exampleHelpers.d.ts.map +1 -1
|
@@ -39,8 +39,7 @@ exports.default = void 0;
|
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
41
|
const generateStyle = (componentTheme, props, state) => {
|
|
42
|
-
const
|
|
43
|
-
iconBackground = props.iconBackground;
|
|
42
|
+
const iconBackground = props.iconBackground;
|
|
44
43
|
const isDesktop = state.layout === 'desktop';
|
|
45
44
|
return {
|
|
46
45
|
topNavBarBrand: {
|
|
@@ -60,15 +59,6 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
60
59
|
appearance: 'none',
|
|
61
60
|
textDecoration: 'none'
|
|
62
61
|
},
|
|
63
|
-
nameContainer: {
|
|
64
|
-
label: 'topNavBarBrand__nameContainer',
|
|
65
|
-
display: 'flex',
|
|
66
|
-
justifyContent: 'center',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
pointerEvents: 'none',
|
|
69
|
-
padding: componentTheme.logoPadding,
|
|
70
|
-
background: isDesktop ? nameBackground : void 0
|
|
71
|
-
},
|
|
72
62
|
name: {
|
|
73
63
|
label: 'topNavBarBrand__name',
|
|
74
64
|
display: 'flex',
|
package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/__new-tests__/TopNavBarDesktopLayout.test.js
CHANGED
|
@@ -96,7 +96,6 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
96
96
|
expect(consoleMock.mock.calls[0][0]).toEqual('Warning: [TopNavBarBreadcrumb] If the inverseColor prop is not set to true, TopNavBarBreadcrumb fails to render.');
|
|
97
97
|
});
|
|
98
98
|
it('should not render breadcrumb if brand exists', () => {
|
|
99
|
-
const consoleMock = jest.spyOn(console, 'warn').mockImplementation();
|
|
100
99
|
const _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_TopNavBarContext.default.Provider, {
|
|
101
100
|
value: {
|
|
102
101
|
layout: 'desktop',
|
|
@@ -116,7 +115,6 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
116
115
|
expect(crumb1).not.toBeInTheDocument();
|
|
117
116
|
expect(crumb2).not.toBeInTheDocument();
|
|
118
117
|
expect(crumb3).not.toBeInTheDocument();
|
|
119
|
-
expect(consoleMock.mock.calls[0][0]).toEqual('Warning: [TopNavBarBrand] `renderName` is deprecated and will be removed in version 9. Please use the updated TopNavBar design.');
|
|
120
118
|
});
|
|
121
119
|
it('should not render breadcrumb if menuitems exist', () => {
|
|
122
120
|
const _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_TopNavBarContext.default.Provider, {
|
|
@@ -161,11 +159,10 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
161
159
|
expect(brandContainer).not.toBeInTheDocument();
|
|
162
160
|
expect(desktopLayout).not.toHaveTextContent('Brand name');
|
|
163
161
|
});
|
|
164
|
-
it('should not render brand container when "
|
|
162
|
+
it('should not render brand container when "renderIcon" props is missing', () => {
|
|
165
163
|
const _render7 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
166
164
|
renderBrand: (0, _exampleHelpers.getBrand)({
|
|
167
165
|
brandProps: {
|
|
168
|
-
renderName: void 0,
|
|
169
166
|
renderIcon: void 0
|
|
170
167
|
}
|
|
171
168
|
})
|
|
@@ -316,135 +313,10 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
316
313
|
expect(elementRef).toHaveBeenCalledWith(container.firstChild);
|
|
317
314
|
});
|
|
318
315
|
});
|
|
319
|
-
describe('hideActionsUserSeparator prop', () => {
|
|
320
|
-
describe('in default mode', () => {
|
|
321
|
-
it('should hide separator between actions and user', () => {
|
|
322
|
-
const _render20 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
323
|
-
hideActionsUserSeparator: true
|
|
324
|
-
}))),
|
|
325
|
-
container = _render20.container;
|
|
326
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
327
|
-
|
|
328
|
-
// TODO convert to e2e
|
|
329
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
330
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
331
|
-
// const actionsUserSeparator = getComputedStyle(userContainer!, '::before')
|
|
332
|
-
// const actionsUserSeparatorBackground = actionsUserSeparator.getPropertyValue('background-color')
|
|
333
|
-
|
|
334
|
-
// expect(actionsUserSeparatorBackground).toBe('rgba(0, 0, 0, 0)')
|
|
335
|
-
|
|
336
|
-
expect(userContainer).toBeInTheDocument();
|
|
337
|
-
});
|
|
338
|
-
it('should show separator between actions and user, when false', () => {
|
|
339
|
-
const _render21 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
340
|
-
hideActionsUserSeparator: false
|
|
341
|
-
}))),
|
|
342
|
-
container = _render21.container;
|
|
343
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
344
|
-
|
|
345
|
-
// TODO convert to e2e
|
|
346
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
347
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
348
|
-
// expect(actionsUserSeparator).to.equal('rgb(199, 205, 209)')
|
|
349
|
-
|
|
350
|
-
expect(userContainer).toBeInTheDocument();
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
describe('in inverse mode', () => {
|
|
354
|
-
it('should hide separator between actions and user', () => {
|
|
355
|
-
const _render22 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_exampleHelpers.SmallViewportModeWrapper, {
|
|
356
|
-
layout: "desktop",
|
|
357
|
-
inverseColor: true
|
|
358
|
-
}, /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
359
|
-
hideActionsUserSeparator: true
|
|
360
|
-
})))),
|
|
361
|
-
container = _render22.container;
|
|
362
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
363
|
-
|
|
364
|
-
// TODO convert to e2e
|
|
365
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
366
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
367
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
368
|
-
|
|
369
|
-
expect(userContainer).toBeInTheDocument();
|
|
370
|
-
});
|
|
371
|
-
it('should show separator between actions and user, when false', () => {
|
|
372
|
-
const _render23 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_exampleHelpers.SmallViewportModeWrapper, {
|
|
373
|
-
layout: "desktop",
|
|
374
|
-
inverseColor: true
|
|
375
|
-
}, /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
376
|
-
hideActionsUserSeparator: false
|
|
377
|
-
})))),
|
|
378
|
-
container = _render23.container;
|
|
379
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
380
|
-
|
|
381
|
-
// TODO convert to e2e
|
|
382
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
383
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
384
|
-
// expect(actionsUserSeparator).to.equal('rgb(199, 205, 209)')
|
|
385
|
-
|
|
386
|
-
expect(userContainer).toBeInTheDocument();
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
describe('should not display when:', () => {
|
|
390
|
-
it('renderActionItems is missing', () => {
|
|
391
|
-
const _render24 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
392
|
-
hideActionsUserSeparator: void 0,
|
|
393
|
-
renderActionItems: void 0
|
|
394
|
-
}))),
|
|
395
|
-
container = _render24.container;
|
|
396
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
397
|
-
const actionItemsContainer = container.querySelector("[class$='topNavBarDesktopLayout__actionItemsContainer']");
|
|
398
|
-
|
|
399
|
-
// TODO convert to e2e
|
|
400
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
401
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
402
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
403
|
-
|
|
404
|
-
expect(actionItemsContainer).not.toBeInTheDocument();
|
|
405
|
-
expect(userContainer).toBeInTheDocument();
|
|
406
|
-
});
|
|
407
|
-
it('renderUser is missing', () => {
|
|
408
|
-
const _render25 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
409
|
-
hideActionsUserSeparator: void 0,
|
|
410
|
-
renderUser: void 0
|
|
411
|
-
}))),
|
|
412
|
-
container = _render25.container;
|
|
413
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
414
|
-
const actionItemsContainer = container.querySelector("[class$='topNavBarDesktopLayout__actionItemsContainer']");
|
|
415
|
-
|
|
416
|
-
// TODO convert to e2e
|
|
417
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
418
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
419
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
420
|
-
|
|
421
|
-
expect(actionItemsContainer).toBeInTheDocument();
|
|
422
|
-
expect(userContainer).not.toBeInTheDocument();
|
|
423
|
-
});
|
|
424
|
-
it('renderActionItems and renderUser is missing', () => {
|
|
425
|
-
const _render26 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, Object.assign({}, defaultBlocks, {
|
|
426
|
-
hideActionsUserSeparator: void 0,
|
|
427
|
-
renderActionItems: void 0,
|
|
428
|
-
renderUser: void 0
|
|
429
|
-
}))),
|
|
430
|
-
container = _render26.container;
|
|
431
|
-
const userContainer = container.querySelector("[class$='topNavBarDesktopLayout__userContainer']");
|
|
432
|
-
const actionItemsContainer = container.querySelector("[class$='topNavBarDesktopLayout__actionItemsContainer']");
|
|
433
|
-
|
|
434
|
-
// TODO convert to e2e
|
|
435
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
436
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
437
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
438
|
-
|
|
439
|
-
expect(actionItemsContainer).not.toBeInTheDocument();
|
|
440
|
-
expect(userContainer).not.toBeInTheDocument();
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
316
|
describe('should be accessible', () => {
|
|
445
317
|
it('a11y', async () => {
|
|
446
|
-
const
|
|
447
|
-
container =
|
|
318
|
+
const _render20 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.TopNavBarDesktopLayout, defaultBlocks)),
|
|
319
|
+
container = _render20.container;
|
|
448
320
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
449
321
|
expect(axeCheck).toBe(true);
|
|
450
322
|
});
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.TopNavBarDesktopLayout = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _deprecated = require("@instructure/ui-react-utils/lib/deprecated.js");
|
|
11
10
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
12
11
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
13
12
|
var _emotion = require("@instructure/emotion");
|
|
@@ -15,7 +14,7 @@ var _TopNavBarContext = require("../../TopNavBarContext");
|
|
|
15
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
16
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
17
16
|
var _props = require("./props");
|
|
18
|
-
var _dec, _dec2,
|
|
17
|
+
var _dec, _dec2, _class, _class2;
|
|
19
18
|
/*
|
|
20
19
|
* The MIT License (MIT)
|
|
21
20
|
*
|
|
@@ -45,9 +44,7 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
45
44
|
private: true
|
|
46
45
|
---
|
|
47
46
|
**/
|
|
48
|
-
let TopNavBarDesktopLayout = exports.TopNavBarDesktopLayout = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(),
|
|
49
|
-
hideActionsUserSeparator: true
|
|
50
|
-
}, 'From v9, actionUserSeparator has to be visible at all times. Please do not use designs which hide it. Note: this prop is probably used inside the desktopConfig prop on [TopNavBar.Layout]'), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TopNavBarDesktopLayout extends _react.Component {
|
|
47
|
+
let TopNavBarDesktopLayout = exports.TopNavBarDesktopLayout = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class TopNavBarDesktopLayout extends _react.Component {
|
|
51
48
|
constructor(...args) {
|
|
52
49
|
super(...args);
|
|
53
50
|
this.ref = null;
|
|
@@ -77,7 +74,7 @@ let TopNavBarDesktopLayout = exports.TopNavBarDesktopLayout = (_dec = (0, _emoti
|
|
|
77
74
|
}
|
|
78
75
|
get hasBrandBlock() {
|
|
79
76
|
const renderBrand = this.props.renderBrand;
|
|
80
|
-
return !!renderBrand &&
|
|
77
|
+
return !!renderBrand && !!renderBrand.props.renderIcon;
|
|
81
78
|
}
|
|
82
79
|
get hasActionItemsBlock() {
|
|
83
80
|
const renderActionItems = this.props.renderActionItems;
|
|
@@ -123,5 +120,5 @@ let TopNavBarDesktopLayout = exports.TopNavBarDesktopLayout = (_dec = (0, _emoti
|
|
|
123
120
|
css: styles === null || styles === void 0 ? void 0 : styles.userContainer
|
|
124
121
|
}, renderUser));
|
|
125
122
|
}
|
|
126
|
-
}, _class2.displayName = "TopNavBarDesktopLayout", _class2.componentId = 'TopNavBar.DesktopLayout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {}, _class2.contextType = _TopNavBarContext.TopNavBarContext, _class2)) || _class) || _class)
|
|
123
|
+
}, _class2.displayName = "TopNavBarDesktopLayout", _class2.componentId = 'TopNavBar.DesktopLayout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {}, _class2.contextType = _TopNavBarContext.TopNavBarContext, _class2)) || _class) || _class);
|
|
127
124
|
var _default = exports.default = TopNavBarDesktopLayout;
|
|
@@ -34,17 +34,16 @@ exports.default = void 0;
|
|
|
34
34
|
* ---
|
|
35
35
|
* Generates the style object from the theme and provided additional information
|
|
36
36
|
* @param {Object} componentTheme The theme variable object.
|
|
37
|
-
* @param {Object}
|
|
37
|
+
* @param {Object} _props the props of the component, the style is applied to
|
|
38
38
|
* @param {Object} state the state of the component, the style is applied to
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
|
-
const generateStyle = (componentTheme,
|
|
42
|
-
const hideActionsUserSeparator = props.hideActionsUserSeparator;
|
|
41
|
+
const generateStyle = (componentTheme, _props, state) => {
|
|
43
42
|
const inverseColor = state.inverseColor,
|
|
44
43
|
hasBrandBlock = state.hasBrandBlock,
|
|
45
44
|
hasActionItemsBlock = state.hasActionItemsBlock,
|
|
46
45
|
hasUserBlock = state.hasUserBlock;
|
|
47
|
-
const hasUserSeparator = hasActionItemsBlock && hasUserBlock
|
|
46
|
+
const hasUserSeparator = hasActionItemsBlock && hasUserBlock;
|
|
48
47
|
return {
|
|
49
48
|
topNavBarDesktopLayout: {
|
|
50
49
|
label: 'topNavBarDesktopLayout',
|
|
@@ -138,11 +138,10 @@ describe('<TopNavBarSmallViewportLayout />', () => {
|
|
|
138
138
|
expect(brandContainer).not.toBeInTheDocument();
|
|
139
139
|
expect(brandNameText).not.toBeInTheDocument();
|
|
140
140
|
});
|
|
141
|
-
it('should not render brand container when "
|
|
141
|
+
it('should not render brand container when "renderIcon" prop is missing', () => {
|
|
142
142
|
const _render6 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_exampleHelpers.SmallViewportModeWrapper, null, /*#__PURE__*/_react.default.createElement(_index.TopNavBarSmallViewportLayout, Object.assign({}, defaultProps, {
|
|
143
143
|
renderBrand: (0, _exampleHelpers.getBrand)({
|
|
144
144
|
brandProps: {
|
|
145
|
-
renderName: void 0,
|
|
146
145
|
renderIcon: void 0
|
|
147
146
|
}
|
|
148
147
|
})
|
|
@@ -146,7 +146,7 @@ let TopNavBarSmallViewportLayout = exports.TopNavBarSmallViewportLayout = (_dec
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
hasBrandBlock(renderBrand) {
|
|
149
|
-
return !!renderBrand &&
|
|
149
|
+
return !!renderBrand && !!renderBrand.props.renderIcon;
|
|
150
150
|
}
|
|
151
151
|
hasMenuItemsBlock(renderMenuItems) {
|
|
152
152
|
return !!renderMenuItems && _react.default.Children.count(renderMenuItems.props.children) > 0;
|
|
@@ -73,24 +73,6 @@ describe('<TopNavBarLayout />', () => {
|
|
|
73
73
|
expect(desktopLayout).toBeVisible();
|
|
74
74
|
expect(smallViewportLayout).toBeUndefined();
|
|
75
75
|
});
|
|
76
|
-
it('should pass the "desktopConfig" props to DesktopLayout', () => {
|
|
77
|
-
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_exampleHelpers.SmallViewportModeWrapper, {
|
|
78
|
-
layout: "desktop"
|
|
79
|
-
}, /*#__PURE__*/_react.default.createElement(_index.TopNavBarLayout, Object.assign({}, (0, _exampleHelpers.getLayoutProps)({
|
|
80
|
-
currentLayout: 'desktop',
|
|
81
|
-
inverseColor: false
|
|
82
|
-
}), {
|
|
83
|
-
desktopConfig: {
|
|
84
|
-
hideActionsUserSeparator: false
|
|
85
|
-
}
|
|
86
|
-
}))));
|
|
87
|
-
const navElement = _react2.screen.getByRole('navigation');
|
|
88
|
-
const userContainer = Array.from(navElement.children).find(child => child.className.includes('topNavBarDesktopLayout__userContainer'));
|
|
89
|
-
const userContainerStyle = userContainer ? window.getComputedStyle(userContainer) : null;
|
|
90
|
-
|
|
91
|
-
// userContainer get position relative and a pseudo ::before as a separator
|
|
92
|
-
expect(userContainerStyle === null || userContainerStyle === void 0 ? void 0 : userContainerStyle.position).toBe('relative');
|
|
93
|
-
});
|
|
94
76
|
it('should pass the proper "themeOverride"-s to DesktopLayout', () => {
|
|
95
77
|
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_exampleHelpers.SmallViewportModeWrapper, {
|
|
96
78
|
layout: "desktop"
|
|
@@ -15,7 +15,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
15
15
|
var _SmallViewportLayout = require("./SmallViewportLayout");
|
|
16
16
|
var _DesktopLayout = require("./DesktopLayout");
|
|
17
17
|
var _props = require("./props");
|
|
18
|
-
const _excluded = ["
|
|
18
|
+
const _excluded = ["smallViewportConfig", "styles", "makeStyles"];
|
|
19
19
|
var _dec, _dec2, _class, _class2;
|
|
20
20
|
/*
|
|
21
21
|
* The MIT License (MIT)
|
|
@@ -60,6 +60,10 @@ let TopNavBarLayout = exports.TopNavBarLayout = (_dec = (0, _emotion.withStyle)(
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
componentDidMount() {
|
|
64
|
+
// TODO: Remove this in v10!
|
|
65
|
+
if ('desktopConfig' in this.props) {}
|
|
66
|
+
}
|
|
63
67
|
get sortedThemeOverride() {
|
|
64
68
|
const themeOverride = this.props.themeOverride;
|
|
65
69
|
|
|
@@ -89,7 +93,6 @@ let TopNavBarLayout = exports.TopNavBarLayout = (_dec = (0, _emotion.withStyle)(
|
|
|
89
93
|
}
|
|
90
94
|
render() {
|
|
91
95
|
const _this$props = this.props,
|
|
92
|
-
desktopConfig = _this$props.desktopConfig,
|
|
93
96
|
smallViewportConfig = _this$props.smallViewportConfig,
|
|
94
97
|
styles = _this$props.styles,
|
|
95
98
|
makeStyles = _this$props.makeStyles,
|
|
@@ -100,13 +103,12 @@ let TopNavBarLayout = exports.TopNavBarLayout = (_dec = (0, _emotion.withStyle)(
|
|
|
100
103
|
elementRef: this.handleRef
|
|
101
104
|
}));
|
|
102
105
|
}
|
|
103
|
-
return (0, _emotion.jsx)(_DesktopLayout.TopNavBarDesktopLayout, Object.assign({},
|
|
106
|
+
return (0, _emotion.jsx)(_DesktopLayout.TopNavBarDesktopLayout, Object.assign({}, restProps, {
|
|
104
107
|
themeOverride: this.sortedThemeOverride.desktopThemeOverride,
|
|
105
108
|
elementRef: this.handleRef
|
|
106
109
|
}));
|
|
107
110
|
}
|
|
108
111
|
}, _class2.displayName = "TopNavBarLayout", _class2.componentId = 'TopNavBar.Layout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
109
|
-
desktopConfig: {},
|
|
110
112
|
smallViewportConfig: {}
|
|
111
113
|
}, _class2.contextType = _TopNavBarContext.TopNavBarContext, _class2)) || _class) || _class);
|
|
112
114
|
var _default = exports.default = TopNavBarLayout;
|
|
@@ -71,10 +71,9 @@ const smallViewportPropTypes = exports.smallViewportPropTypes = {
|
|
|
71
71
|
};
|
|
72
72
|
const propTypes = exports.propTypes = {
|
|
73
73
|
...commonPropTypes,
|
|
74
|
-
desktopConfig: _propTypes.default.shape(desktopPropTypes),
|
|
75
74
|
smallViewportConfig: _propTypes.default.shape(smallViewportPropTypes).isRequired
|
|
76
75
|
};
|
|
77
76
|
const commonAllowedProps = exports.commonAllowedProps = ['renderBrand', 'renderMenuItems', 'renderActionItems', 'renderUser', 'renderBreadcrumb', 'navLabel', 'elementRef'];
|
|
78
77
|
const desktopAllowedProps = exports.desktopAllowedProps = ['hideActionsUserSeparator'];
|
|
79
78
|
const smallViewportAllowedProps = exports.smallViewportAllowedProps = ['dropdownMenuToggleButtonLabel', 'dropdownMenuToggleButtonTooltip', 'dropdownMenuLabel', 'alternativeTitle', 'renderInPlaceDialogConfig', 'trayMountNode', 'onDropdownMenuToggle', 'onDropdownMenuSelect'];
|
|
80
|
-
const allowedProps = exports.allowedProps = [...commonAllowedProps, '
|
|
79
|
+
const allowedProps = exports.allowedProps = [...commonAllowedProps, 'smallViewportConfig'];
|
|
@@ -65,7 +65,6 @@ const BaseExample = () => {
|
|
|
65
65
|
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
66
66
|
breakpoint: 700
|
|
67
67
|
}, () => /*#__PURE__*/_react.default.createElement(_index.default.Layout, {
|
|
68
|
-
desktopConfig: {},
|
|
69
68
|
smallViewportConfig: {
|
|
70
69
|
dropdownMenuToggleButtonLabel: 'Toggle Menu',
|
|
71
70
|
dropdownMenuLabel: 'Main Menu'
|
|
@@ -100,14 +100,10 @@ SmallViewportModeWrapper.defaultProps = {
|
|
|
100
100
|
inverseColor: false
|
|
101
101
|
};
|
|
102
102
|
const getBrand = (config = {}) => {
|
|
103
|
-
const logo = config.inverseColor ? _exampleSvgFiles.elevateLogoInverse : _exampleSvgFiles.elevateLogo;
|
|
104
|
-
const nameBackground = !config.hasBrandNameBackground ? void 0 : config.inverseColor ? '#F5F5F5' : '#2D3B45';
|
|
105
103
|
return /*#__PURE__*/_react.default.createElement(_index.TopNavBar.Brand, Object.assign({
|
|
106
104
|
screenReaderLabel: "Brand name",
|
|
107
|
-
renderName: logo,
|
|
108
105
|
renderIcon: _exampleSvgFiles.elevateIcon,
|
|
109
106
|
iconBackground: "#0097D3",
|
|
110
|
-
nameBackground: nameBackground,
|
|
111
107
|
href: "/#TopNavBar"
|
|
112
108
|
}, config.brandProps));
|
|
113
109
|
};
|
|
@@ -189,9 +185,6 @@ const getBreadcrumb = (_config = {}) => {
|
|
|
189
185
|
exports.getBreadcrumb = getBreadcrumb;
|
|
190
186
|
const getLayoutProps = (props, config = {}) => {
|
|
191
187
|
return {
|
|
192
|
-
desktopConfig: {
|
|
193
|
-
hideActionsUserSeparator: config.hideActionsUserSeparator
|
|
194
|
-
},
|
|
195
188
|
smallViewportConfig: {
|
|
196
189
|
dropdownMenuToggleButtonLabel: 'Toggle Menu',
|
|
197
190
|
dropdownMenuLabel: 'Main Menu',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-top-nav-bar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,38 +24,38 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.23.2",
|
|
27
|
-
"@instructure/console": "
|
|
28
|
-
"@instructure/emotion": "
|
|
29
|
-
"@instructure/shared-types": "
|
|
30
|
-
"@instructure/ui-a11y-content": "
|
|
31
|
-
"@instructure/ui-avatar": "
|
|
32
|
-
"@instructure/ui-breadcrumb": "
|
|
33
|
-
"@instructure/ui-buttons": "
|
|
34
|
-
"@instructure/ui-dialog": "
|
|
35
|
-
"@instructure/ui-dom-utils": "
|
|
36
|
-
"@instructure/ui-drilldown": "
|
|
37
|
-
"@instructure/ui-icons": "
|
|
38
|
-
"@instructure/ui-link": "
|
|
39
|
-
"@instructure/ui-popover": "
|
|
40
|
-
"@instructure/ui-prop-types": "
|
|
41
|
-
"@instructure/ui-react-utils": "
|
|
42
|
-
"@instructure/ui-responsive": "
|
|
43
|
-
"@instructure/ui-testable": "
|
|
44
|
-
"@instructure/ui-tooltip": "
|
|
45
|
-
"@instructure/ui-tray": "
|
|
46
|
-
"@instructure/ui-truncate-list": "
|
|
47
|
-
"@instructure/ui-utils": "
|
|
48
|
-
"@instructure/ui-view": "
|
|
27
|
+
"@instructure/console": "9.0.0",
|
|
28
|
+
"@instructure/emotion": "9.0.0",
|
|
29
|
+
"@instructure/shared-types": "9.0.0",
|
|
30
|
+
"@instructure/ui-a11y-content": "9.0.0",
|
|
31
|
+
"@instructure/ui-avatar": "9.0.0",
|
|
32
|
+
"@instructure/ui-breadcrumb": "9.0.0",
|
|
33
|
+
"@instructure/ui-buttons": "9.0.0",
|
|
34
|
+
"@instructure/ui-dialog": "9.0.0",
|
|
35
|
+
"@instructure/ui-dom-utils": "9.0.0",
|
|
36
|
+
"@instructure/ui-drilldown": "9.0.0",
|
|
37
|
+
"@instructure/ui-icons": "9.0.0",
|
|
38
|
+
"@instructure/ui-link": "9.0.0",
|
|
39
|
+
"@instructure/ui-popover": "9.0.0",
|
|
40
|
+
"@instructure/ui-prop-types": "9.0.0",
|
|
41
|
+
"@instructure/ui-react-utils": "9.0.0",
|
|
42
|
+
"@instructure/ui-responsive": "9.0.0",
|
|
43
|
+
"@instructure/ui-testable": "9.0.0",
|
|
44
|
+
"@instructure/ui-tooltip": "9.0.0",
|
|
45
|
+
"@instructure/ui-tray": "9.0.0",
|
|
46
|
+
"@instructure/ui-truncate-list": "9.0.0",
|
|
47
|
+
"@instructure/ui-utils": "9.0.0",
|
|
48
|
+
"@instructure/ui-view": "9.0.0",
|
|
49
49
|
"prop-types": "^15.8.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@instructure/ui-axe-check": "
|
|
53
|
-
"@instructure/ui-babel-preset": "
|
|
54
|
-
"@instructure/ui-color-utils": "
|
|
55
|
-
"@instructure/ui-scripts": "
|
|
56
|
-
"@instructure/ui-test-locator": "
|
|
57
|
-
"@instructure/ui-test-utils": "
|
|
58
|
-
"@instructure/ui-themes": "
|
|
52
|
+
"@instructure/ui-axe-check": "9.0.0",
|
|
53
|
+
"@instructure/ui-babel-preset": "9.0.0",
|
|
54
|
+
"@instructure/ui-color-utils": "9.0.0",
|
|
55
|
+
"@instructure/ui-scripts": "9.0.0",
|
|
56
|
+
"@instructure/ui-test-locator": "9.0.0",
|
|
57
|
+
"@instructure/ui-test-utils": "9.0.0",
|
|
58
|
+
"@instructure/ui-themes": "9.0.0",
|
|
59
59
|
"@testing-library/jest-dom": "^6.1.4",
|
|
60
60
|
"@testing-library/react": "^14.1.2",
|
|
61
61
|
"@testing-library/user-event": "^14.5.1"
|