@instructure/ui-top-nav-bar 8.56.0 → 9.0.1-snapshot-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 +26 -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
package/src/TopNavBar/TopNavBarLayout/DesktopLayout/__new-tests__/TopNavBarDesktopLayout.test.tsx
CHANGED
|
@@ -31,8 +31,7 @@ import {
|
|
|
31
31
|
getBrand,
|
|
32
32
|
getMenuItems,
|
|
33
33
|
getUser,
|
|
34
|
-
getBreadcrumb
|
|
35
|
-
SmallViewportModeWrapper
|
|
34
|
+
getBreadcrumb
|
|
36
35
|
} from '../../../utils/exampleHelpers'
|
|
37
36
|
|
|
38
37
|
import { TopNavBarDesktopLayout } from '../index'
|
|
@@ -122,8 +121,6 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
122
121
|
})
|
|
123
122
|
|
|
124
123
|
it('should not render breadcrumb if brand exists', () => {
|
|
125
|
-
const consoleMock = jest.spyOn(console, 'warn').mockImplementation()
|
|
126
|
-
|
|
127
124
|
const { queryByLabelText, queryByText } = render(
|
|
128
125
|
<TopNavBarContext.Provider
|
|
129
126
|
value={{
|
|
@@ -146,9 +143,6 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
146
143
|
expect(crumb1).not.toBeInTheDocument()
|
|
147
144
|
expect(crumb2).not.toBeInTheDocument()
|
|
148
145
|
expect(crumb3).not.toBeInTheDocument()
|
|
149
|
-
expect(consoleMock.mock.calls[0][0]).toEqual(
|
|
150
|
-
'Warning: [TopNavBarBrand] `renderName` is deprecated and will be removed in version 9. Please use the updated TopNavBar design.'
|
|
151
|
-
)
|
|
152
146
|
})
|
|
153
147
|
|
|
154
148
|
it('should not render breadcrumb if menuitems exist', () => {
|
|
@@ -207,12 +201,12 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
207
201
|
expect(desktopLayout).not.toHaveTextContent('Brand name')
|
|
208
202
|
})
|
|
209
203
|
|
|
210
|
-
it('should not render brand container when "
|
|
204
|
+
it('should not render brand container when "renderIcon" props is missing', () => {
|
|
211
205
|
const { container } = render(
|
|
212
206
|
<TopNavBarDesktopLayout
|
|
213
207
|
{...defaultBlocks}
|
|
214
208
|
renderBrand={getBrand({
|
|
215
|
-
brandProps: {
|
|
209
|
+
brandProps: { renderIcon: undefined }
|
|
216
210
|
})}
|
|
217
211
|
/>
|
|
218
212
|
)
|
|
@@ -430,170 +424,6 @@ describe('<TopNavBarDesktopLayout />', () => {
|
|
|
430
424
|
})
|
|
431
425
|
})
|
|
432
426
|
|
|
433
|
-
describe('hideActionsUserSeparator prop', () => {
|
|
434
|
-
describe('in default mode', () => {
|
|
435
|
-
it('should hide separator between actions and user', () => {
|
|
436
|
-
const { container } = render(
|
|
437
|
-
<TopNavBarDesktopLayout
|
|
438
|
-
{...defaultBlocks}
|
|
439
|
-
hideActionsUserSeparator={true}
|
|
440
|
-
/>
|
|
441
|
-
)
|
|
442
|
-
const userContainer = container.querySelector(
|
|
443
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
444
|
-
)
|
|
445
|
-
|
|
446
|
-
// TODO convert to e2e
|
|
447
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
448
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
449
|
-
// const actionsUserSeparator = getComputedStyle(userContainer!, '::before')
|
|
450
|
-
// const actionsUserSeparatorBackground = actionsUserSeparator.getPropertyValue('background-color')
|
|
451
|
-
|
|
452
|
-
// expect(actionsUserSeparatorBackground).toBe('rgba(0, 0, 0, 0)')
|
|
453
|
-
|
|
454
|
-
expect(userContainer).toBeInTheDocument()
|
|
455
|
-
})
|
|
456
|
-
|
|
457
|
-
it('should show separator between actions and user, when false', () => {
|
|
458
|
-
const { container } = render(
|
|
459
|
-
<TopNavBarDesktopLayout
|
|
460
|
-
{...defaultBlocks}
|
|
461
|
-
hideActionsUserSeparator={false}
|
|
462
|
-
/>
|
|
463
|
-
)
|
|
464
|
-
const userContainer = container.querySelector(
|
|
465
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
466
|
-
)
|
|
467
|
-
|
|
468
|
-
// TODO convert to e2e
|
|
469
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
470
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
471
|
-
// expect(actionsUserSeparator).to.equal('rgb(199, 205, 209)')
|
|
472
|
-
|
|
473
|
-
expect(userContainer).toBeInTheDocument()
|
|
474
|
-
})
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
describe('in inverse mode', () => {
|
|
478
|
-
it('should hide separator between actions and user', () => {
|
|
479
|
-
const { container } = render(
|
|
480
|
-
<SmallViewportModeWrapper layout="desktop" inverseColor>
|
|
481
|
-
<TopNavBarDesktopLayout
|
|
482
|
-
{...defaultBlocks}
|
|
483
|
-
hideActionsUserSeparator={true}
|
|
484
|
-
/>
|
|
485
|
-
</SmallViewportModeWrapper>
|
|
486
|
-
)
|
|
487
|
-
const userContainer = container.querySelector(
|
|
488
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
489
|
-
)
|
|
490
|
-
|
|
491
|
-
// TODO convert to e2e
|
|
492
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
493
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
494
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
495
|
-
|
|
496
|
-
expect(userContainer).toBeInTheDocument()
|
|
497
|
-
})
|
|
498
|
-
|
|
499
|
-
it('should show separator between actions and user, when false', () => {
|
|
500
|
-
const { container } = render(
|
|
501
|
-
<SmallViewportModeWrapper layout="desktop" inverseColor>
|
|
502
|
-
<TopNavBarDesktopLayout
|
|
503
|
-
{...defaultBlocks}
|
|
504
|
-
hideActionsUserSeparator={false}
|
|
505
|
-
/>
|
|
506
|
-
</SmallViewportModeWrapper>
|
|
507
|
-
)
|
|
508
|
-
const userContainer = container.querySelector(
|
|
509
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
510
|
-
)
|
|
511
|
-
|
|
512
|
-
// TODO convert to e2e
|
|
513
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
514
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
515
|
-
// expect(actionsUserSeparator).to.equal('rgb(199, 205, 209)')
|
|
516
|
-
|
|
517
|
-
expect(userContainer).toBeInTheDocument()
|
|
518
|
-
})
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
describe('should not display when:', () => {
|
|
522
|
-
it('renderActionItems is missing', () => {
|
|
523
|
-
const { container } = render(
|
|
524
|
-
<TopNavBarDesktopLayout
|
|
525
|
-
{...defaultBlocks}
|
|
526
|
-
hideActionsUserSeparator={undefined}
|
|
527
|
-
renderActionItems={undefined}
|
|
528
|
-
/>
|
|
529
|
-
)
|
|
530
|
-
const userContainer = container.querySelector(
|
|
531
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
532
|
-
)
|
|
533
|
-
const actionItemsContainer = container.querySelector(
|
|
534
|
-
"[class$='topNavBarDesktopLayout__actionItemsContainer']"
|
|
535
|
-
)
|
|
536
|
-
|
|
537
|
-
// TODO convert to e2e
|
|
538
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
539
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
540
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
541
|
-
|
|
542
|
-
expect(actionItemsContainer).not.toBeInTheDocument()
|
|
543
|
-
expect(userContainer).toBeInTheDocument()
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
it('renderUser is missing', () => {
|
|
547
|
-
const { container } = render(
|
|
548
|
-
<TopNavBarDesktopLayout
|
|
549
|
-
{...defaultBlocks}
|
|
550
|
-
hideActionsUserSeparator={undefined}
|
|
551
|
-
renderUser={undefined}
|
|
552
|
-
/>
|
|
553
|
-
)
|
|
554
|
-
const userContainer = container.querySelector(
|
|
555
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
556
|
-
)
|
|
557
|
-
const actionItemsContainer = container.querySelector(
|
|
558
|
-
"[class$='topNavBarDesktopLayout__actionItemsContainer']"
|
|
559
|
-
)
|
|
560
|
-
|
|
561
|
-
// TODO convert to e2e
|
|
562
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
563
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
564
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
565
|
-
|
|
566
|
-
expect(actionItemsContainer).toBeInTheDocument()
|
|
567
|
-
expect(userContainer).not.toBeInTheDocument()
|
|
568
|
-
})
|
|
569
|
-
|
|
570
|
-
it('renderActionItems and renderUser is missing', () => {
|
|
571
|
-
const { container } = render(
|
|
572
|
-
<TopNavBarDesktopLayout
|
|
573
|
-
{...defaultBlocks}
|
|
574
|
-
hideActionsUserSeparator={undefined}
|
|
575
|
-
renderActionItems={undefined}
|
|
576
|
-
renderUser={undefined}
|
|
577
|
-
/>
|
|
578
|
-
)
|
|
579
|
-
const userContainer = container.querySelector(
|
|
580
|
-
"[class$='topNavBarDesktopLayout__userContainer']"
|
|
581
|
-
)
|
|
582
|
-
const actionItemsContainer = container.querySelector(
|
|
583
|
-
"[class$='topNavBarDesktopLayout__actionItemsContainer']"
|
|
584
|
-
)
|
|
585
|
-
|
|
586
|
-
// TODO convert to e2e
|
|
587
|
-
// const component = await TopNavBarDesktopLayoutLocator.find()
|
|
588
|
-
// const actionsUserSeparator = await component.getActionsUserSeparatorBackground()
|
|
589
|
-
// expect(actionsUserSeparator).to.equal('rgba(0, 0, 0, 0)')
|
|
590
|
-
|
|
591
|
-
expect(actionItemsContainer).not.toBeInTheDocument()
|
|
592
|
-
expect(userContainer).not.toBeInTheDocument()
|
|
593
|
-
})
|
|
594
|
-
})
|
|
595
|
-
})
|
|
596
|
-
|
|
597
427
|
describe('should be accessible', () => {
|
|
598
428
|
it('a11y', async () => {
|
|
599
429
|
const { container } = render(
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import React, { Component } from 'react'
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
import { omitProps } from '@instructure/ui-react-utils'
|
|
29
29
|
import { testable } from '@instructure/ui-testable'
|
|
30
30
|
|
|
31
31
|
import { withStyle, jsx } from '@instructure/emotion'
|
|
@@ -48,11 +48,6 @@ private: true
|
|
|
48
48
|
**/
|
|
49
49
|
@withStyle(generateStyle, generateComponentTheme)
|
|
50
50
|
@testable()
|
|
51
|
-
@deprecated(
|
|
52
|
-
'9',
|
|
53
|
-
{ hideActionsUserSeparator: true },
|
|
54
|
-
'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]'
|
|
55
|
-
)
|
|
56
51
|
class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
|
|
57
52
|
static readonly componentId = 'TopNavBar.DesktopLayout'
|
|
58
53
|
|
|
@@ -94,10 +89,7 @@ class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
|
|
|
94
89
|
|
|
95
90
|
get hasBrandBlock() {
|
|
96
91
|
const { renderBrand } = this.props
|
|
97
|
-
return
|
|
98
|
-
!!renderBrand &&
|
|
99
|
-
(!!renderBrand.props.renderName || !!renderBrand.props.renderIcon)
|
|
100
|
-
)
|
|
92
|
+
return !!renderBrand && !!renderBrand.props.renderIcon
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
get hasActionItemsBlock() {
|
|
@@ -35,21 +35,19 @@ import type {
|
|
|
35
35
|
* ---
|
|
36
36
|
* Generates the style object from the theme and provided additional information
|
|
37
37
|
* @param {Object} componentTheme The theme variable object.
|
|
38
|
-
* @param {Object}
|
|
38
|
+
* @param {Object} _props the props of the component, the style is applied to
|
|
39
39
|
* @param {Object} state the state of the component, the style is applied to
|
|
40
40
|
* @return {Object} The final style object, which will be used in the component
|
|
41
41
|
*/
|
|
42
42
|
const generateStyle = (
|
|
43
43
|
componentTheme: TopNavBarLayoutDesktopTheme,
|
|
44
|
-
|
|
44
|
+
_props: TopNavBarDesktopLayoutProps,
|
|
45
45
|
state: TopNavBarDesktopLayoutStyleProps
|
|
46
46
|
): TopNavBarDesktopLayoutStyle => {
|
|
47
|
-
const { hideActionsUserSeparator } = props
|
|
48
47
|
const { inverseColor, hasBrandBlock, hasActionItemsBlock, hasUserBlock } =
|
|
49
48
|
state
|
|
50
49
|
|
|
51
|
-
const hasUserSeparator =
|
|
52
|
-
hasActionItemsBlock && hasUserBlock && !hideActionsUserSeparator
|
|
50
|
+
const hasUserSeparator = hasActionItemsBlock && hasUserBlock
|
|
53
51
|
|
|
54
52
|
return {
|
|
55
53
|
topNavBarDesktopLayout: {
|
|
@@ -203,13 +203,13 @@ describe('<TopNavBarSmallViewportLayout />', () => {
|
|
|
203
203
|
expect(brandNameText).not.toBeInTheDocument()
|
|
204
204
|
})
|
|
205
205
|
|
|
206
|
-
it('should not render brand container when "
|
|
206
|
+
it('should not render brand container when "renderIcon" prop is missing', () => {
|
|
207
207
|
const { container } = render(
|
|
208
208
|
<SmallViewportModeWrapper>
|
|
209
209
|
<TopNavBarSmallViewportLayout
|
|
210
210
|
{...defaultProps}
|
|
211
211
|
renderBrand={getBrand({
|
|
212
|
-
brandProps: {
|
|
212
|
+
brandProps: { renderIcon: undefined }
|
|
213
213
|
})}
|
|
214
214
|
/>
|
|
215
215
|
</SmallViewportModeWrapper>
|
|
@@ -181,10 +181,7 @@ class TopNavBarSmallViewportLayout extends Component<
|
|
|
181
181
|
): renderBrand is NonNullable<
|
|
182
182
|
TopNavBarSmallViewportLayoutProps['renderBrand']
|
|
183
183
|
> {
|
|
184
|
-
return
|
|
185
|
-
!!renderBrand &&
|
|
186
|
-
(!!renderBrand.props.renderName || !!renderBrand.props.renderIcon)
|
|
187
|
-
)
|
|
184
|
+
return !!renderBrand && !!renderBrand.props.renderIcon
|
|
188
185
|
}
|
|
189
186
|
|
|
190
187
|
hasMenuItemsBlock(
|
|
@@ -89,31 +89,6 @@ describe('<TopNavBarLayout />', () => {
|
|
|
89
89
|
expect(smallViewportLayout).toBeUndefined()
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
it('should pass the "desktopConfig" props to DesktopLayout', () => {
|
|
93
|
-
render(
|
|
94
|
-
<SmallViewportModeWrapper layout="desktop">
|
|
95
|
-
<TopNavBarLayout
|
|
96
|
-
{...getLayoutProps({
|
|
97
|
-
currentLayout: 'desktop',
|
|
98
|
-
inverseColor: false
|
|
99
|
-
})}
|
|
100
|
-
desktopConfig={{ hideActionsUserSeparator: false }}
|
|
101
|
-
/>
|
|
102
|
-
</SmallViewportModeWrapper>
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
const navElement = screen.getByRole('navigation')
|
|
106
|
-
const userContainer = Array.from(navElement.children).find((child) =>
|
|
107
|
-
child.className.includes('topNavBarDesktopLayout__userContainer')
|
|
108
|
-
)
|
|
109
|
-
const userContainerStyle = userContainer
|
|
110
|
-
? window.getComputedStyle(userContainer)
|
|
111
|
-
: null
|
|
112
|
-
|
|
113
|
-
// userContainer get position relative and a pseudo ::before as a separator
|
|
114
|
-
expect(userContainerStyle?.position).toBe('relative')
|
|
115
|
-
})
|
|
116
|
-
|
|
117
92
|
it('should pass the proper "themeOverride"-s to DesktopLayout', () => {
|
|
118
93
|
render(
|
|
119
94
|
<SmallViewportModeWrapper layout="desktop">
|
|
@@ -61,7 +61,6 @@ class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
|
61
61
|
static propTypes = propTypes
|
|
62
62
|
static allowedProps = allowedProps
|
|
63
63
|
static defaultProps = {
|
|
64
|
-
desktopConfig: {},
|
|
65
64
|
smallViewportConfig: {}
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -70,6 +69,15 @@ class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
|
70
69
|
|
|
71
70
|
ref: HTMLElement | null = null
|
|
72
71
|
|
|
72
|
+
componentDidMount() {
|
|
73
|
+
// TODO: Remove this in v10!
|
|
74
|
+
if ('desktopConfig' in this.props) {
|
|
75
|
+
console.error(
|
|
76
|
+
'Warning: `desktopConfig` prop on [TopNavBar.Layout] is deprecated, please remove it from your code. Further info: https://instructure.design/#v9-upgrade-guide/#deprecated-properties'
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
handleRef = (el: HTMLElement | null) => {
|
|
74
82
|
const { elementRef } = this.props
|
|
75
83
|
|
|
@@ -113,12 +121,12 @@ class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
|
113
121
|
|
|
114
122
|
render() {
|
|
115
123
|
const {
|
|
116
|
-
desktopConfig,
|
|
117
124
|
smallViewportConfig,
|
|
118
125
|
// @ts-expect-error prevents it to be passed
|
|
119
126
|
styles,
|
|
120
127
|
// @ts-expect-error prevents it to be passed
|
|
121
128
|
makeStyles,
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
130
|
...restProps
|
|
123
131
|
} = this.props
|
|
124
132
|
|
|
@@ -135,7 +143,6 @@ class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
|
135
143
|
|
|
136
144
|
return (
|
|
137
145
|
<TopNavBarDesktopLayout
|
|
138
|
-
{...desktopConfig}
|
|
139
146
|
{...(restProps as TopNavBarDesktopLayoutProps)}
|
|
140
147
|
themeOverride={this.sortedThemeOverride.desktopThemeOverride}
|
|
141
148
|
elementRef={this.handleRef}
|
|
@@ -116,11 +116,6 @@ type CommonTopNavBarLayoutProps = {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
type TopNavBarLayoutOwnProps = CommonTopNavBarLayoutProps & {
|
|
119
|
-
/**
|
|
120
|
-
* Config object for the "desktop" mode:
|
|
121
|
-
*/
|
|
122
|
-
desktopConfig?: DesktopLayoutOwnProps
|
|
123
|
-
|
|
124
119
|
/**
|
|
125
120
|
* Config object for the "small viewport" mode:
|
|
126
121
|
*/
|
|
@@ -177,7 +172,6 @@ const smallViewportPropTypes: PropValidators<SmallViewportPropKeys> = {
|
|
|
177
172
|
|
|
178
173
|
const propTypes: PropValidators<PropKeys> = {
|
|
179
174
|
...commonPropTypes,
|
|
180
|
-
desktopConfig: PropTypes.shape(desktopPropTypes),
|
|
181
175
|
smallViewportConfig: PropTypes.shape(smallViewportPropTypes).isRequired
|
|
182
176
|
}
|
|
183
177
|
|
|
@@ -206,7 +200,6 @@ const smallViewportAllowedProps: SmallViewportAllowedPropKeys = [
|
|
|
206
200
|
|
|
207
201
|
const allowedProps: AllowedPropKeys = [
|
|
208
202
|
...commonAllowedProps,
|
|
209
|
-
'desktopConfig',
|
|
210
203
|
'smallViewportConfig'
|
|
211
204
|
]
|
|
212
205
|
|
|
@@ -45,7 +45,7 @@ import { TopNavBarContext } from '../TopNavBarContext'
|
|
|
45
45
|
import type { TopNavBarContextType } from '../TopNavBarContext'
|
|
46
46
|
|
|
47
47
|
import { TopNavBar } from '../index'
|
|
48
|
-
import { elevateIcon
|
|
48
|
+
import { elevateIcon } from './exampleSvgFiles'
|
|
49
49
|
import { Breadcrumb } from '@instructure/ui-breadcrumb'
|
|
50
50
|
|
|
51
51
|
type ChildrenFuncProps = {
|
|
@@ -54,11 +54,9 @@ type ChildrenFuncProps = {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
type VariantConfig = Partial<ChildrenFuncProps> & {
|
|
57
|
-
hideActionsUserSeparator?: boolean
|
|
58
57
|
hasAlternativeTitle?: boolean
|
|
59
58
|
hasRenderInPlaceDialogConfig?: boolean
|
|
60
59
|
brandProps?: Partial<TopNavBarBrandProps>
|
|
61
|
-
hasBrandNameBackground?: boolean
|
|
62
60
|
hasRenderBreadcrumb?: boolean
|
|
63
61
|
currentPageId?: string
|
|
64
62
|
menuItemsWithSubmenu?: boolean
|
|
@@ -167,20 +165,11 @@ SmallViewportModeWrapper.defaultProps = {
|
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
const getBrand = (config: VariantConfig = {}) => {
|
|
170
|
-
const logo = config.inverseColor ? elevateLogoInverse : elevateLogo
|
|
171
|
-
const nameBackground = !config.hasBrandNameBackground
|
|
172
|
-
? undefined
|
|
173
|
-
: config.inverseColor
|
|
174
|
-
? '#F5F5F5'
|
|
175
|
-
: '#2D3B45'
|
|
176
|
-
|
|
177
168
|
return (
|
|
178
169
|
<TopNavBar.Brand
|
|
179
170
|
screenReaderLabel="Brand name"
|
|
180
|
-
renderName={logo}
|
|
181
171
|
renderIcon={elevateIcon}
|
|
182
172
|
iconBackground="#0097D3"
|
|
183
|
-
nameBackground={nameBackground}
|
|
184
173
|
href="/#TopNavBar"
|
|
185
174
|
{...config.brandProps}
|
|
186
175
|
/>
|
|
@@ -322,9 +311,6 @@ const getLayoutProps = (
|
|
|
322
311
|
config: VariantConfig = {}
|
|
323
312
|
): TopNavBarLayoutProps => {
|
|
324
313
|
return {
|
|
325
|
-
desktopConfig: {
|
|
326
|
-
hideActionsUserSeparator: config.hideActionsUserSeparator
|
|
327
|
-
},
|
|
328
314
|
smallViewportConfig: {
|
|
329
315
|
dropdownMenuToggleButtonLabel: 'Toggle Menu',
|
|
330
316
|
dropdownMenuLabel: 'Main Menu',
|