@instructure/ui-top-nav-bar 8.30.1-snapshot-15
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 +57 -0
- package/README.md +30 -0
- package/es/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +47 -0
- package/es/TopNavBar/TopNavBarActionItems/index.js +215 -0
- package/es/TopNavBar/TopNavBarActionItems/props.js +36 -0
- package/es/TopNavBar/TopNavBarActionItems/styles.js +76 -0
- package/es/TopNavBar/TopNavBarActionItems/theme.js +46 -0
- package/es/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +57 -0
- package/es/TopNavBar/TopNavBarBrand/index.js +117 -0
- package/es/TopNavBar/TopNavBarBrand/props.js +37 -0
- package/es/TopNavBar/TopNavBarBrand/styles.js +91 -0
- package/es/TopNavBar/TopNavBarBrand/theme.js +42 -0
- package/es/TopNavBar/TopNavBarContext.js +37 -0
- package/es/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +114 -0
- package/es/TopNavBar/TopNavBarItem/index.js +634 -0
- package/es/TopNavBar/TopNavBarItem/props.js +64 -0
- package/es/TopNavBar/TopNavBarItem/styles.js +124 -0
- package/es/TopNavBar/TopNavBarItem/theme.js +54 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +86 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +119 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +31 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +115 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +61 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +126 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +454 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +31 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +158 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +61 -0
- package/es/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +36 -0
- package/es/TopNavBar/TopNavBarLayout/index.js +118 -0
- package/es/TopNavBar/TopNavBarLayout/props.js +69 -0
- package/es/TopNavBar/TopNavBarLayout/theme.js +40 -0
- package/es/TopNavBar/TopNavBarLocator.js +29 -0
- package/es/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +54 -0
- package/es/TopNavBar/TopNavBarMenuItems/index.js +210 -0
- package/es/TopNavBar/TopNavBarMenuItems/props.js +35 -0
- package/es/TopNavBar/TopNavBarMenuItems/styles.js +65 -0
- package/es/TopNavBar/TopNavBarMenuItems/theme.js +45 -0
- package/es/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +29 -0
- package/es/TopNavBar/TopNavBarUser/index.js +109 -0
- package/es/TopNavBar/TopNavBarUser/props.js +32 -0
- package/es/TopNavBar/TopNavBarUser/styles.js +45 -0
- package/es/TopNavBar/index.js +110 -0
- package/es/TopNavBar/props.js +33 -0
- package/es/TopNavBar/utils/exampleHelpers.js +211 -0
- package/es/TopNavBar/utils/exampleSvgFiles.js +86 -0
- package/es/TopNavBar/utils/mapItemsForDrilldown.js +142 -0
- package/es/index.js +24 -0
- package/lib/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +59 -0
- package/lib/TopNavBar/TopNavBarActionItems/index.js +222 -0
- package/lib/TopNavBar/TopNavBarActionItems/props.js +50 -0
- package/lib/TopNavBar/TopNavBarActionItems/styles.js +84 -0
- package/lib/TopNavBar/TopNavBarActionItems/theme.js +54 -0
- package/lib/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +68 -0
- package/lib/TopNavBar/TopNavBarBrand/index.js +115 -0
- package/lib/TopNavBar/TopNavBarBrand/props.js +48 -0
- package/lib/TopNavBar/TopNavBarBrand/styles.js +99 -0
- package/lib/TopNavBar/TopNavBarBrand/theme.js +50 -0
- package/lib/TopNavBar/TopNavBarContext.js +46 -0
- package/lib/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +131 -0
- package/lib/TopNavBar/TopNavBarItem/index.js +650 -0
- package/lib/TopNavBar/TopNavBarItem/props.js +79 -0
- package/lib/TopNavBar/TopNavBarItem/styles.js +132 -0
- package/lib/TopNavBar/TopNavBarItem/theme.js +62 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +102 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +113 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +40 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +123 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +69 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +143 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +472 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +40 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +166 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +69 -0
- package/lib/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +48 -0
- package/lib/TopNavBar/TopNavBarLayout/index.js +113 -0
- package/lib/TopNavBar/TopNavBarLayout/props.js +94 -0
- package/lib/TopNavBar/TopNavBarLayout/theme.js +52 -0
- package/lib/TopNavBar/TopNavBarLocator.js +39 -0
- package/lib/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +66 -0
- package/lib/TopNavBar/TopNavBarMenuItems/index.js +213 -0
- package/lib/TopNavBar/TopNavBarMenuItems/props.js +48 -0
- package/lib/TopNavBar/TopNavBarMenuItems/styles.js +73 -0
- package/lib/TopNavBar/TopNavBarMenuItems/theme.js +53 -0
- package/lib/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +39 -0
- package/lib/TopNavBar/TopNavBarUser/index.js +104 -0
- package/lib/TopNavBar/TopNavBarUser/props.js +45 -0
- package/lib/TopNavBar/TopNavBarUser/styles.js +53 -0
- package/lib/TopNavBar/index.js +110 -0
- package/lib/TopNavBar/props.js +44 -0
- package/lib/TopNavBar/utils/exampleHelpers.js +255 -0
- package/lib/TopNavBar/utils/exampleSvgFiles.js +75 -0
- package/lib/TopNavBar/utils/mapItemsForDrilldown.js +165 -0
- package/lib/index.js +13 -0
- package/lib/package.json +1 -0
- package/package.json +64 -0
- package/src/TopNavBar/README.md +2329 -0
- package/src/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.ts +53 -0
- package/src/TopNavBar/TopNavBarActionItems/index.tsx +299 -0
- package/src/TopNavBar/TopNavBarActionItems/props.ts +152 -0
- package/src/TopNavBar/TopNavBarActionItems/styles.ts +92 -0
- package/src/TopNavBar/TopNavBarActionItems/theme.ts +51 -0
- package/src/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.ts +44 -0
- package/src/TopNavBar/TopNavBarBrand/index.tsx +139 -0
- package/src/TopNavBar/TopNavBarBrand/props.ts +146 -0
- package/src/TopNavBar/TopNavBarBrand/styles.ts +102 -0
- package/src/TopNavBar/TopNavBarBrand/theme.ts +48 -0
- package/src/TopNavBar/TopNavBarContext.ts +47 -0
- package/src/TopNavBar/TopNavBarItem/TopNavBarItemLocator.ts +111 -0
- package/src/TopNavBar/TopNavBarItem/index.tsx +752 -0
- package/src/TopNavBar/TopNavBarItem/props.ts +331 -0
- package/src/TopNavBar/TopNavBarItem/styles.ts +142 -0
- package/src/TopNavBar/TopNavBarItem/theme.ts +60 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.ts +84 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/index.tsx +148 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/props.ts +104 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/styles.ts +136 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/theme.ts +66 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.ts +125 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.tsx +600 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.ts +187 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.ts +184 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.ts +69 -0
- package/src/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.ts +46 -0
- package/src/TopNavBar/TopNavBarLayout/index.tsx +149 -0
- package/src/TopNavBar/TopNavBarLayout/props.ts +209 -0
- package/src/TopNavBar/TopNavBarLayout/theme.ts +47 -0
- package/src/TopNavBar/TopNavBarLocator.ts +31 -0
- package/src/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.ts +56 -0
- package/src/TopNavBar/TopNavBarMenuItems/index.tsx +275 -0
- package/src/TopNavBar/TopNavBarMenuItems/props.ts +133 -0
- package/src/TopNavBar/TopNavBarMenuItems/styles.ts +72 -0
- package/src/TopNavBar/TopNavBarMenuItems/theme.ts +51 -0
- package/src/TopNavBar/TopNavBarUser/TopNavBarUserLocator.ts +32 -0
- package/src/TopNavBar/TopNavBarUser/index.tsx +133 -0
- package/src/TopNavBar/TopNavBarUser/props.ts +83 -0
- package/src/TopNavBar/TopNavBarUser/styles.ts +47 -0
- package/src/TopNavBar/index.tsx +142 -0
- package/src/TopNavBar/props.ts +108 -0
- package/src/TopNavBar/utils/exampleHelpers.tsx +342 -0
- package/src/TopNavBar/utils/exampleSvgFiles.tsx +76 -0
- package/src/TopNavBar/utils/mapItemsForDrilldown.tsx +228 -0
- package/src/index.ts +62 -0
- package/tsconfig.build.json +37 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.d.ts +2116 -0
- package/types/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts +40 -0
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts +59 -0
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarActionItems/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarActionItems/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts +592 -0
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/index.d.ts +30 -0
- package/types/TopNavBar/TopNavBarBrand/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/props.d.ts +60 -0
- package/types/TopNavBar/TopNavBarBrand/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarBrand/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarBrand/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarContext.d.ts +17 -0
- package/types/TopNavBar/TopNavBarContext.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/TopNavBarItemLocator.d.ts +642 -0
- package/types/TopNavBar/TopNavBarItem/TopNavBarItemLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/index.d.ts +64 -0
- package/types/TopNavBar/TopNavBarItem/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/props.d.ts +188 -0
- package/types/TopNavBar/TopNavBarItem/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarItem/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarItem/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.d.ts +5737 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts +31 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts +29 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.d.ts +4357 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts +58 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts +89 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.d.ts +7 -0
- package/types/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/index.d.ts +34 -0
- package/types/TopNavBar/TopNavBarLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/props.d.ts +83 -0
- package/types/TopNavBar/TopNavBarLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLocator.d.ts +566 -0
- package/types/TopNavBar/TopNavBarLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.d.ts +1351 -0
- package/types/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts +38 -0
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts +53 -0
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarMenuItems/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarMenuItems/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/TopNavBarUserLocator.d.ts +566 -0
- package/types/TopNavBar/TopNavBarUser/TopNavBarUserLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/index.d.ts +31 -0
- package/types/TopNavBar/TopNavBarUser/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/props.d.ts +29 -0
- package/types/TopNavBar/TopNavBarUser/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/styles.d.ts +14 -0
- package/types/TopNavBar/TopNavBarUser/styles.d.ts.map +1 -0
- package/types/TopNavBar/index.d.ts +38 -0
- package/types/TopNavBar/index.d.ts.map +1 -0
- package/types/TopNavBar/props.d.ts +43 -0
- package/types/TopNavBar/props.d.ts.map +1 -0
- package/types/TopNavBar/utils/exampleHelpers.d.ts +70 -0
- package/types/TopNavBar/utils/exampleHelpers.d.ts.map +1 -0
- package/types/TopNavBar/utils/exampleSvgFiles.d.ts +7 -0
- package/types/TopNavBar/utils/exampleSvgFiles.d.ts.map +1 -0
- package/types/TopNavBar/utils/mapItemsForDrilldown.d.ts +19 -0
- package/types/TopNavBar/utils/mapItemsForDrilldown.d.ts.map +1 -0
- package/types/index.d.ts +11 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,187 @@
|
|
|
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 React from 'react'
|
|
26
|
+
|
|
27
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
28
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
29
|
+
import type {
|
|
30
|
+
TopNavBarLayoutSmallViewportTheme,
|
|
31
|
+
OtherHTMLAttributes,
|
|
32
|
+
PropValidators
|
|
33
|
+
} from '@instructure/shared-types'
|
|
34
|
+
|
|
35
|
+
import type { DrilldownProps } from '@instructure/ui-drilldown'
|
|
36
|
+
|
|
37
|
+
import type { TopNavBarItemTooltipType } from '../../TopNavBarItem/props'
|
|
38
|
+
import type { TopNavBarContextType } from '../../TopNavBarContext'
|
|
39
|
+
|
|
40
|
+
import {
|
|
41
|
+
commonAllowedProps,
|
|
42
|
+
commonPropTypes,
|
|
43
|
+
smallViewportPropTypes,
|
|
44
|
+
smallViewportAllowedProps
|
|
45
|
+
} from '../props'
|
|
46
|
+
import type { CommonTopNavBarLayoutProps } from '../props'
|
|
47
|
+
|
|
48
|
+
import { TopNavBarSmallViewportLayout } from './index'
|
|
49
|
+
|
|
50
|
+
type SmallViewportLayoutChild = React.ComponentElement<
|
|
51
|
+
TopNavBarSmallViewportLayoutProps,
|
|
52
|
+
TopNavBarSmallViewportLayout
|
|
53
|
+
>
|
|
54
|
+
|
|
55
|
+
type SmallViewportLayoutOwnProps = {
|
|
56
|
+
/**
|
|
57
|
+
* A __required__ label for the hamburger menu icon, used as an accessible screen reader label.
|
|
58
|
+
*/
|
|
59
|
+
dropdownMenuToggleButtonLabel: string
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* An optional tooltip for the hamburger menu icon.
|
|
63
|
+
*/
|
|
64
|
+
dropdownMenuToggleButtonTooltip?: TopNavBarItemTooltipType
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An 'aria-label' for the dropdown menu.
|
|
68
|
+
*/
|
|
69
|
+
dropdownMenuLabel?: string
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Instead of the Brand logo and link, display other data (e.g.: page title).
|
|
73
|
+
*
|
|
74
|
+
* In this case, the hamburger menu icon will be replaced with a chevron.
|
|
75
|
+
*/
|
|
76
|
+
alternativeTitle?: React.ReactNode
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Renders a custom `<Dialog>` that renders in place of the navbar.
|
|
80
|
+
* Useful for features like full width search bars, etc.
|
|
81
|
+
*
|
|
82
|
+
* Use `returnFocusElement` prop for returning focus after close.
|
|
83
|
+
*/
|
|
84
|
+
renderInPlaceDialogConfig?: {
|
|
85
|
+
open: boolean
|
|
86
|
+
onClose: () => void
|
|
87
|
+
closeButtonLabel: string
|
|
88
|
+
content?:
|
|
89
|
+
| React.ReactNode
|
|
90
|
+
| ((args: { closeInPlaceDialog: () => void }) => React.ReactNode)
|
|
91
|
+
/**
|
|
92
|
+
* Function that returns an element the focus needs to return to on close
|
|
93
|
+
*/
|
|
94
|
+
returnFocusElement?: () => HTMLElement | null
|
|
95
|
+
shouldContainFocus?: boolean
|
|
96
|
+
shouldCloseOnDocumentClick?: boolean
|
|
97
|
+
shouldCloseOnEscape?: boolean
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* An element or a function returning an element to use as the mount node for the dropdown menu's `<Tray>` container.
|
|
102
|
+
*
|
|
103
|
+
* Use this prop when the default Tray placement doesn't work for your layout (e.g.: when the TopNavBar is not the main navbar of the window).
|
|
104
|
+
*/
|
|
105
|
+
trayMountNode?: Element | (() => Element | null) | null
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Callback fired on dropdown menu open and close
|
|
109
|
+
*/
|
|
110
|
+
onDropdownMenuToggle?: (isMenuOpen: boolean) => void
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Callback fired when an item is selected in the dropdown menu
|
|
114
|
+
*/
|
|
115
|
+
onDropdownMenuSelect?: DrilldownProps['onSelect']
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type TopNavBarSmallViewportLayoutOwnProps = CommonTopNavBarLayoutProps &
|
|
119
|
+
SmallViewportLayoutOwnProps
|
|
120
|
+
|
|
121
|
+
type PropKeys = keyof TopNavBarSmallViewportLayoutOwnProps
|
|
122
|
+
|
|
123
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
124
|
+
|
|
125
|
+
type TopNavBarSmallViewportLayoutProps = TopNavBarSmallViewportLayoutOwnProps &
|
|
126
|
+
WithStyleProps<
|
|
127
|
+
TopNavBarLayoutSmallViewportTheme,
|
|
128
|
+
TopNavBarSmallViewportLayoutStyle
|
|
129
|
+
> &
|
|
130
|
+
OtherHTMLAttributes<TopNavBarSmallViewportLayoutOwnProps> &
|
|
131
|
+
WithDeterministicIdProps
|
|
132
|
+
|
|
133
|
+
type TopNavBarSmallViewportLayoutStyle = ComponentStyle<
|
|
134
|
+
| 'topNavBarSmallViewportLayout'
|
|
135
|
+
| 'navbar'
|
|
136
|
+
| 'inPlaceDialogContainer'
|
|
137
|
+
| 'inPlaceDialogContainerContent'
|
|
138
|
+
| 'inPlaceDialogContainerButton'
|
|
139
|
+
| 'menuTriggerContainer'
|
|
140
|
+
| 'menuTrigger'
|
|
141
|
+
| 'dropdownMenuOption'
|
|
142
|
+
| 'dropdownMenuOptionActive'
|
|
143
|
+
| 'dropdownMenuOptionWithAvatar'
|
|
144
|
+
| 'brandContainer'
|
|
145
|
+
| 'alternativeTitleContainer'
|
|
146
|
+
| 'trayContainer'
|
|
147
|
+
| 'globalStyles'
|
|
148
|
+
> & {
|
|
149
|
+
navbarHeight: string | number
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
type TopNavBarSmallViewportLayoutState = {
|
|
153
|
+
isDropdownMenuOpen: boolean
|
|
154
|
+
isDropdownMenuVisible: boolean
|
|
155
|
+
menuBottomPosition: number
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type TopNavBarSmallViewportLayoutStyleProps = {
|
|
159
|
+
isDropdownMenuVisible: boolean
|
|
160
|
+
drilldownId: string
|
|
161
|
+
trayId: string
|
|
162
|
+
menuBottomPosition: number
|
|
163
|
+
inverseColor: TopNavBarContextType['inverseColor']
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
167
|
+
// Edit PropTypes in TopNabBarLayout/props.ts
|
|
168
|
+
...commonPropTypes,
|
|
169
|
+
...smallViewportPropTypes
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const allowedProps: AllowedPropKeys = [
|
|
173
|
+
// Edit allowed props in TopNabBarLayout/props.ts
|
|
174
|
+
...commonAllowedProps,
|
|
175
|
+
...smallViewportAllowedProps
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
export type {
|
|
179
|
+
SmallViewportLayoutChild,
|
|
180
|
+
SmallViewportLayoutOwnProps,
|
|
181
|
+
TopNavBarSmallViewportLayoutProps,
|
|
182
|
+
TopNavBarSmallViewportLayoutOwnProps,
|
|
183
|
+
TopNavBarSmallViewportLayoutStyle,
|
|
184
|
+
TopNavBarSmallViewportLayoutState,
|
|
185
|
+
TopNavBarSmallViewportLayoutStyleProps
|
|
186
|
+
}
|
|
187
|
+
export { propTypes, allowedProps }
|
|
@@ -0,0 +1,184 @@
|
|
|
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 { TopNavBarLayoutSmallViewportTheme } from '@instructure/shared-types'
|
|
26
|
+
import type {
|
|
27
|
+
TopNavBarSmallViewportLayoutProps,
|
|
28
|
+
TopNavBarSmallViewportLayoutStyleProps,
|
|
29
|
+
TopNavBarSmallViewportLayoutStyle
|
|
30
|
+
} from './props'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param {Object} componentTheme The theme variable object.
|
|
38
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
39
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
40
|
+
* @return {Object} The final style object, which will be used in the component
|
|
41
|
+
*/
|
|
42
|
+
const generateStyle = (
|
|
43
|
+
componentTheme: TopNavBarLayoutSmallViewportTheme,
|
|
44
|
+
_props: TopNavBarSmallViewportLayoutProps,
|
|
45
|
+
state: TopNavBarSmallViewportLayoutStyleProps
|
|
46
|
+
): TopNavBarSmallViewportLayoutStyle => {
|
|
47
|
+
const {
|
|
48
|
+
isDropdownMenuVisible,
|
|
49
|
+
drilldownId,
|
|
50
|
+
trayId,
|
|
51
|
+
menuBottomPosition,
|
|
52
|
+
inverseColor
|
|
53
|
+
} = state
|
|
54
|
+
|
|
55
|
+
const dropdownMenuTopPosition =
|
|
56
|
+
componentTheme.smallViewportTrayFixTopPosition || `${menuBottomPosition}px`
|
|
57
|
+
|
|
58
|
+
const dropdownMenuOptionStyle = {
|
|
59
|
+
display: 'inline-block',
|
|
60
|
+
padding: `0 ${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorSpacing}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const navBarStyles = {
|
|
64
|
+
fontSize: componentTheme.smallViewportFontSize,
|
|
65
|
+
fontFamily: componentTheme.smallViewportFontFamily,
|
|
66
|
+
fontWeight: componentTheme.smallViewportFontWeight,
|
|
67
|
+
background: inverseColor
|
|
68
|
+
? componentTheme.smallViewportBackgroundInverse
|
|
69
|
+
: componentTheme.smallViewportBackground,
|
|
70
|
+
borderBlockEnd: inverseColor
|
|
71
|
+
? componentTheme.smallViewportBottomBorderInverse
|
|
72
|
+
: componentTheme.smallViewportBottomBorder,
|
|
73
|
+
height: componentTheme.smallViewportHeight,
|
|
74
|
+
maxWidth: '100%',
|
|
75
|
+
paddingBlock: 0,
|
|
76
|
+
paddingInline: componentTheme.smallViewportInlinePadding,
|
|
77
|
+
position: 'relative',
|
|
78
|
+
zIndex: componentTheme.smallViewportZIndex,
|
|
79
|
+
display: 'flex',
|
|
80
|
+
justifyContent: 'space-between',
|
|
81
|
+
alignItems: 'stretch',
|
|
82
|
+
overflow: 'hidden'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
topNavBarSmallViewportLayout: {
|
|
87
|
+
label: 'topNavBarSmallViewportLayout'
|
|
88
|
+
},
|
|
89
|
+
navbar: {
|
|
90
|
+
label: 'topNavBarSmallViewportLayout__navbar',
|
|
91
|
+
...navBarStyles
|
|
92
|
+
},
|
|
93
|
+
inPlaceDialogContainer: {
|
|
94
|
+
label: 'topNavBarSmallViewportLayout__inPlaceDialogContainer',
|
|
95
|
+
...navBarStyles,
|
|
96
|
+
alignItems: 'center'
|
|
97
|
+
},
|
|
98
|
+
inPlaceDialogContainerContent: {
|
|
99
|
+
label: 'topNavBarSmallViewportLayout__inPlaceDialogContainerContent',
|
|
100
|
+
flex: '1 1'
|
|
101
|
+
},
|
|
102
|
+
inPlaceDialogContainerButton: {
|
|
103
|
+
label: 'topNavBarSmallViewportLayout__inPlaceDialogContainerButton',
|
|
104
|
+
flex: '0 0'
|
|
105
|
+
},
|
|
106
|
+
menuTriggerContainer: {
|
|
107
|
+
label: 'topNavBarSmallViewportLayout__menuTriggerContainer',
|
|
108
|
+
display: 'flex',
|
|
109
|
+
alignItems: 'stretch',
|
|
110
|
+
justifyContent: 'flex-start',
|
|
111
|
+
flex: '1 1'
|
|
112
|
+
},
|
|
113
|
+
menuTrigger: {
|
|
114
|
+
label: 'topNavBarSmallViewportLayout__menuTrigger',
|
|
115
|
+
display: 'flex',
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
justifyContent: 'flex-start'
|
|
118
|
+
},
|
|
119
|
+
alternativeTitleContainer: {
|
|
120
|
+
label: 'topNavBarSmallViewportLayout__alternativeTitleContainer',
|
|
121
|
+
marginBlock: componentTheme.smallViewportAlternativeTitleBlockMargin,
|
|
122
|
+
marginInline: componentTheme.smallViewportAlternativeTitleInlineMargin
|
|
123
|
+
},
|
|
124
|
+
dropdownMenuOption: {
|
|
125
|
+
label: 'topNavBarSmallViewportLayout__dropdownMenuOption',
|
|
126
|
+
...dropdownMenuOptionStyle
|
|
127
|
+
},
|
|
128
|
+
dropdownMenuOptionActive: {
|
|
129
|
+
label: 'topNavBarSmallViewportLayout__dropdownMenuOptionActive',
|
|
130
|
+
...dropdownMenuOptionStyle,
|
|
131
|
+
fontWeight:
|
|
132
|
+
componentTheme.smallViewportDropdownMenuActiveOptionFontWeight,
|
|
133
|
+
paddingBlockEnd:
|
|
134
|
+
componentTheme.smallViewportDropdownMenuActiveOptionIndicatorSpacing,
|
|
135
|
+
borderBottom: `${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorWidth} solid ${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorColor}`
|
|
136
|
+
},
|
|
137
|
+
dropdownMenuOptionWithAvatar: {
|
|
138
|
+
label: 'topNavBarSmallViewportLayout__dropdownMenuOptionWithAvatar',
|
|
139
|
+
...dropdownMenuOptionStyle,
|
|
140
|
+
display: 'flex',
|
|
141
|
+
alignItems: 'center'
|
|
142
|
+
},
|
|
143
|
+
brandContainer: {
|
|
144
|
+
label: 'topNavBarSmallViewportLayout__brandContainer',
|
|
145
|
+
display: 'flex',
|
|
146
|
+
alignItems: 'stretch'
|
|
147
|
+
},
|
|
148
|
+
trayContainer: {
|
|
149
|
+
label: 'topNavBarSmallViewportLayout__trayContainer',
|
|
150
|
+
width: '100%',
|
|
151
|
+
position: componentTheme.smallViewportTrayPosition,
|
|
152
|
+
insetBlockStart: dropdownMenuTopPosition,
|
|
153
|
+
insetInlineStart: '0px',
|
|
154
|
+
zIndex: componentTheme.smallViewportTrayZIndex,
|
|
155
|
+
|
|
156
|
+
...(isDropdownMenuVisible && {
|
|
157
|
+
height: `calc(100% - ${dropdownMenuTopPosition})`
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
globalStyles: {
|
|
161
|
+
// the tray should all have 100% height
|
|
162
|
+
[`#${trayId}`]: {
|
|
163
|
+
height: '100%'
|
|
164
|
+
},
|
|
165
|
+
// removes the focus ring on the drilldown,
|
|
166
|
+
// not needed on the mobile menu
|
|
167
|
+
[`#${drilldownId}`]: {
|
|
168
|
+
height: '100%',
|
|
169
|
+
|
|
170
|
+
'&::before': {
|
|
171
|
+
// display: 'none'
|
|
172
|
+
top: '4px',
|
|
173
|
+
left: '4px',
|
|
174
|
+
right: '4px',
|
|
175
|
+
bottom: '4px',
|
|
176
|
+
zIndex: 1
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
navbarHeight: componentTheme.smallViewportHeight
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default generateStyle
|
|
@@ -0,0 +1,69 @@
|
|
|
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 } from '@instructure/ui-themes'
|
|
26
|
+
import type { TopNavBarLayoutSmallViewportTheme } 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 = (
|
|
34
|
+
theme: Theme
|
|
35
|
+
): TopNavBarLayoutSmallViewportTheme => {
|
|
36
|
+
const { colors, stacking, typography, spacing, borders } = theme
|
|
37
|
+
|
|
38
|
+
const componentVariables: TopNavBarLayoutSmallViewportTheme = {
|
|
39
|
+
smallViewportFontSize: typography?.fontSizeMedium,
|
|
40
|
+
smallViewportFontFamily: typography?.fontFamily,
|
|
41
|
+
smallViewportFontWeight: typography?.fontWeightNormal,
|
|
42
|
+
|
|
43
|
+
smallViewportBackground: colors?.backgroundBrandSecondary,
|
|
44
|
+
smallViewportBackgroundInverse: colors?.backgroundLightest,
|
|
45
|
+
smallViewportBottomBorder: 'none',
|
|
46
|
+
smallViewportBottomBorderInverse: `${borders?.widthSmall} ${borders?.style} ${colors?.borderMedium}`,
|
|
47
|
+
smallViewportHeight: '3.5rem',
|
|
48
|
+
smallViewportInlinePadding: `0.25rem`,
|
|
49
|
+
smallViewportZIndex: stacking?.topmost + 1,
|
|
50
|
+
|
|
51
|
+
smallViewportTrayPosition: 'fixed',
|
|
52
|
+
smallViewportTrayFixTopPosition: undefined,
|
|
53
|
+
smallViewportTrayZIndex: stacking?.topmost + 1,
|
|
54
|
+
|
|
55
|
+
smallViewportDropdownMenuActiveOptionFontWeight: typography?.fontWeightBold,
|
|
56
|
+
smallViewportDropdownMenuActiveOptionIndicatorSpacing: '0.25rem',
|
|
57
|
+
smallViewportDropdownMenuActiveOptionIndicatorWidth: borders?.widthMedium,
|
|
58
|
+
smallViewportDropdownMenuActiveOptionIndicatorColor: 'currentColor',
|
|
59
|
+
|
|
60
|
+
smallViewportAlternativeTitleInlineMargin: spacing?.xxSmall,
|
|
61
|
+
smallViewportAlternativeTitleBlockMargin: '0'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...componentVariables
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { locator } from '@instructure/ui-test-locator'
|
|
26
|
+
|
|
27
|
+
import { TopNavBarDesktopLayoutLocator } from './DesktopLayout/TopNavBarDesktopLayoutLocator'
|
|
28
|
+
import { TopNavBarSmallViewportLayoutLocator } from './SmallViewportLayout/TopNavBarSmallViewportLayoutLocator'
|
|
29
|
+
|
|
30
|
+
import { TopNavBarLayout } from './index'
|
|
31
|
+
|
|
32
|
+
// TODO: this type seems to be too complex, try to fix it later
|
|
33
|
+
export const TopNavBarLayoutLocator: {
|
|
34
|
+
customMethods: {
|
|
35
|
+
findDesktopLayout: any
|
|
36
|
+
findSmallViewportLayout: any
|
|
37
|
+
}
|
|
38
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
39
|
+
} = locator(TopNavBarLayout.selector, {
|
|
40
|
+
findDesktopLayout: (...args: any[]) => {
|
|
41
|
+
return TopNavBarDesktopLayoutLocator.find(...args)
|
|
42
|
+
},
|
|
43
|
+
findSmallViewportLayout: (...args: any[]) => {
|
|
44
|
+
return TopNavBarSmallViewportLayoutLocator.find(...args)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
/** @jsx jsx */
|
|
26
|
+
import React, { Component } from 'react'
|
|
27
|
+
|
|
28
|
+
import { testable } from '@instructure/ui-testable'
|
|
29
|
+
|
|
30
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
import type {
|
|
33
|
+
TopNavBarLayoutDesktopTheme,
|
|
34
|
+
TopNavBarLayoutSmallViewportTheme
|
|
35
|
+
} from '@instructure/shared-types'
|
|
36
|
+
|
|
37
|
+
import { TopNavBarContext } from '../TopNavBarContext'
|
|
38
|
+
|
|
39
|
+
import generateComponentTheme from './theme'
|
|
40
|
+
|
|
41
|
+
import { TopNavBarSmallViewportLayout } from './SmallViewportLayout'
|
|
42
|
+
import type { TopNavBarSmallViewportLayoutProps } from './SmallViewportLayout/props'
|
|
43
|
+
import { TopNavBarDesktopLayout } from './DesktopLayout'
|
|
44
|
+
import type { TopNavBarDesktopLayoutProps } from './DesktopLayout/props'
|
|
45
|
+
|
|
46
|
+
import { propTypes, allowedProps } from './props'
|
|
47
|
+
import type { TopNavBarLayoutProps } from './props'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
---
|
|
51
|
+
parent: TopNavBar
|
|
52
|
+
id: TopNavBar.Layout
|
|
53
|
+
---
|
|
54
|
+
@module TopNavBarLayout
|
|
55
|
+
@tsProps
|
|
56
|
+
**/
|
|
57
|
+
@withStyle(null, generateComponentTheme)
|
|
58
|
+
@testable()
|
|
59
|
+
class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
60
|
+
static readonly componentId = 'TopNavBar.Layout'
|
|
61
|
+
|
|
62
|
+
static propTypes = propTypes
|
|
63
|
+
static allowedProps = allowedProps
|
|
64
|
+
static defaultProps = {
|
|
65
|
+
desktopConfig: {},
|
|
66
|
+
smallViewportConfig: {}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare context: React.ContextType<typeof TopNavBarContext>
|
|
70
|
+
static contextType = TopNavBarContext
|
|
71
|
+
|
|
72
|
+
ref: HTMLElement | null = null
|
|
73
|
+
|
|
74
|
+
handleRef = (el: HTMLElement | null) => {
|
|
75
|
+
const { elementRef } = this.props
|
|
76
|
+
|
|
77
|
+
this.ref = el
|
|
78
|
+
|
|
79
|
+
if (typeof elementRef === 'function') {
|
|
80
|
+
elementRef(el)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get sortedThemeOverride() {
|
|
85
|
+
const { themeOverride } = this.props
|
|
86
|
+
|
|
87
|
+
// TODO: try to type better, the themeOverride types are not prepared to be inherited and sorted
|
|
88
|
+
|
|
89
|
+
if (!themeOverride || typeof themeOverride === 'function') {
|
|
90
|
+
return {
|
|
91
|
+
desktopThemeOverride: themeOverride as any,
|
|
92
|
+
smallViewportThemeOverride: themeOverride as any
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const desktopThemeOverride: Partial<TopNavBarLayoutDesktopTheme> = {}
|
|
97
|
+
const smallViewportThemeOverride: Partial<TopNavBarLayoutSmallViewportTheme> =
|
|
98
|
+
{}
|
|
99
|
+
|
|
100
|
+
for (const key in themeOverride) {
|
|
101
|
+
if (key.startsWith('smallViewport')) {
|
|
102
|
+
const variable = key as keyof TopNavBarLayoutSmallViewportTheme
|
|
103
|
+
smallViewportThemeOverride[variable] = themeOverride[variable] as any
|
|
104
|
+
} else if (
|
|
105
|
+
(key as keyof TopNavBarLayoutDesktopTheme).startsWith('desktop')
|
|
106
|
+
) {
|
|
107
|
+
const variable = key as keyof TopNavBarLayoutDesktopTheme
|
|
108
|
+
desktopThemeOverride[variable] = themeOverride[variable] as any
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return { desktopThemeOverride, smallViewportThemeOverride }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
render() {
|
|
116
|
+
const {
|
|
117
|
+
desktopConfig,
|
|
118
|
+
smallViewportConfig,
|
|
119
|
+
// @ts-expect-error prevents it to be passed
|
|
120
|
+
styles,
|
|
121
|
+
// @ts-expect-error prevents it to be passed
|
|
122
|
+
makeStyles,
|
|
123
|
+
...restProps
|
|
124
|
+
} = this.props
|
|
125
|
+
|
|
126
|
+
if (this.context.layout === 'smallViewport') {
|
|
127
|
+
return (
|
|
128
|
+
<TopNavBarSmallViewportLayout
|
|
129
|
+
{...smallViewportConfig}
|
|
130
|
+
{...(restProps as TopNavBarSmallViewportLayoutProps)}
|
|
131
|
+
themeOverride={this.sortedThemeOverride.smallViewportThemeOverride}
|
|
132
|
+
elementRef={this.handleRef}
|
|
133
|
+
/>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<TopNavBarDesktopLayout
|
|
139
|
+
{...desktopConfig}
|
|
140
|
+
{...(restProps as TopNavBarDesktopLayoutProps)}
|
|
141
|
+
themeOverride={this.sortedThemeOverride.desktopThemeOverride}
|
|
142
|
+
elementRef={this.handleRef}
|
|
143
|
+
/>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { TopNavBarLayout }
|
|
149
|
+
export default TopNavBarLayout
|