@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,133 @@
|
|
|
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
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
29
|
+
|
|
30
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
31
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
32
|
+
import type {
|
|
33
|
+
TopNavBarMenuItemsTheme,
|
|
34
|
+
OtherHTMLAttributes,
|
|
35
|
+
PropValidators,
|
|
36
|
+
ChildrenOfType
|
|
37
|
+
} from '@instructure/shared-types'
|
|
38
|
+
|
|
39
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
40
|
+
import type { ItemChild } from '../TopNavBarItem/props'
|
|
41
|
+
|
|
42
|
+
import { TopNavBarMenuItems } from './index'
|
|
43
|
+
|
|
44
|
+
type MenuItemsChild = React.ComponentElement<
|
|
45
|
+
TopNavBarMenuItemsProps,
|
|
46
|
+
TopNavBarMenuItems
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
type TopNavBarMenuItemsOwnProps = {
|
|
50
|
+
/**
|
|
51
|
+
* Children of type: `<TopNavBar.Item>`.
|
|
52
|
+
*
|
|
53
|
+
* In __desktop__ mode the items are listed on the navbar. See `renderHiddenItemsMenuTriggerLabel` prop description for overflow logic.
|
|
54
|
+
*
|
|
55
|
+
* In __smallViewport__ mode the items are accessible under the main "hamburger" menu.
|
|
56
|
+
*/
|
|
57
|
+
children?: ChildrenOfType<ItemChild>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The `id` of the link to the current page. Marks the item by setting `aria-current="page"` attribute on it and setting its status to 'active'.
|
|
61
|
+
*
|
|
62
|
+
* (Note: only non-disabled, `variant="default"` items can be set to current/active.)
|
|
63
|
+
*/
|
|
64
|
+
currentPageId?: string
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* In __desktop__ mode, required label for the trigger item of the hidden list items menu.
|
|
68
|
+
*
|
|
69
|
+
* When there is not enough room to list all the menu items,
|
|
70
|
+
* they will be accessible via a dropdown menu at the end of the list.
|
|
71
|
+
*/
|
|
72
|
+
renderHiddenItemsMenuTriggerLabel: (
|
|
73
|
+
hiddenChildrenCount: number
|
|
74
|
+
) => React.ReactNode
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* In __desktop__ mode, 'aria-label' for the `<ul>` container.
|
|
78
|
+
*/
|
|
79
|
+
listLabel?: string
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A function that returns a reference to root HTML element
|
|
83
|
+
*/
|
|
84
|
+
elementRef?: (el: HTMLUListElement | null) => void
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type PropKeys = keyof TopNavBarMenuItemsOwnProps
|
|
88
|
+
|
|
89
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
90
|
+
|
|
91
|
+
type TopNavBarMenuItemsProps = TopNavBarMenuItemsOwnProps &
|
|
92
|
+
WithStyleProps<TopNavBarMenuItemsTheme, TopNavBarMenuItemsStyle> &
|
|
93
|
+
WithDeterministicIdProps &
|
|
94
|
+
OtherHTMLAttributes<TopNavBarMenuItemsOwnProps>
|
|
95
|
+
|
|
96
|
+
type TopNavBarMenuItemsStyle = ComponentStyle<
|
|
97
|
+
'topNavBarMenuItems' | 'submenuOption' | 'submenuOptionActive'
|
|
98
|
+
> & {
|
|
99
|
+
itemSpacing: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type TopNavBarMenuItemsState = {
|
|
103
|
+
key: number
|
|
104
|
+
visibleItemsCount?: number
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
108
|
+
children: ChildrenPropTypes.oneOf([TopNavBarItem]),
|
|
109
|
+
currentPageId: PropTypes.string,
|
|
110
|
+
renderHiddenItemsMenuTriggerLabel: PropTypes.oneOfType([
|
|
111
|
+
PropTypes.func,
|
|
112
|
+
PropTypes.string
|
|
113
|
+
]).isRequired,
|
|
114
|
+
listLabel: PropTypes.string,
|
|
115
|
+
elementRef: PropTypes.func
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const allowedProps: AllowedPropKeys = [
|
|
119
|
+
'children',
|
|
120
|
+
'currentPageId',
|
|
121
|
+
'renderHiddenItemsMenuTriggerLabel',
|
|
122
|
+
'listLabel',
|
|
123
|
+
'elementRef'
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
export type {
|
|
127
|
+
MenuItemsChild,
|
|
128
|
+
TopNavBarMenuItemsProps,
|
|
129
|
+
TopNavBarMenuItemsOwnProps,
|
|
130
|
+
TopNavBarMenuItemsStyle,
|
|
131
|
+
TopNavBarMenuItemsState
|
|
132
|
+
}
|
|
133
|
+
export { propTypes, allowedProps }
|
|
@@ -0,0 +1,72 @@
|
|
|
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 { TopNavBarMenuItemsTheme } from '@instructure/shared-types'
|
|
26
|
+
import type { TopNavBarMenuItemsStyle } from './props'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
36
|
+
* @return {Object} The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (
|
|
39
|
+
componentTheme: TopNavBarMenuItemsTheme
|
|
40
|
+
): TopNavBarMenuItemsStyle => {
|
|
41
|
+
const submenuOptionStyle = {
|
|
42
|
+
display: 'inline-block',
|
|
43
|
+
padding: `0 ${componentTheme.desktopSubmenuActiveOptionIndicatorSpacing}`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
topNavBarMenuItems: {
|
|
48
|
+
label: 'topNavBarMenuItems',
|
|
49
|
+
flex: '1 1',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
alignItems: 'stretch',
|
|
53
|
+
// padding to prevent focus ring getting cropped by `overflow: hidden`
|
|
54
|
+
padding: '0 0.125rem'
|
|
55
|
+
},
|
|
56
|
+
submenuOption: {
|
|
57
|
+
label: 'topNavBarMenuItems__submenuOption',
|
|
58
|
+
...submenuOptionStyle
|
|
59
|
+
},
|
|
60
|
+
submenuOptionActive: {
|
|
61
|
+
label: 'topNavBarMenuItems__submenuOptionActive',
|
|
62
|
+
...submenuOptionStyle,
|
|
63
|
+
fontWeight: componentTheme.desktopSubmenuActiveOptionFontWeight,
|
|
64
|
+
paddingBlockEnd:
|
|
65
|
+
componentTheme.desktopSubmenuActiveOptionIndicatorSpacing,
|
|
66
|
+
borderBottom: `${componentTheme.desktopSubmenuActiveOptionIndicatorWidth} solid ${componentTheme.desktopSubmenuActiveOptionIndicatorColor}`
|
|
67
|
+
},
|
|
68
|
+
itemSpacing: componentTheme.desktopItemSpacing
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default generateStyle
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { TopNavBarMenuItemsTheme } from '@instructure/shared-types'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
30
|
+
* @param {Object} theme The actual theme object.
|
|
31
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
32
|
+
*/
|
|
33
|
+
const generateComponentTheme = (theme: Theme): TopNavBarMenuItemsTheme => {
|
|
34
|
+
const { borders, typography } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: TopNavBarMenuItemsTheme = {
|
|
37
|
+
desktopItemSpacing: '1rem',
|
|
38
|
+
desktopMaxWidth: '100%',
|
|
39
|
+
|
|
40
|
+
desktopSubmenuActiveOptionFontWeight: typography?.fontWeightBold,
|
|
41
|
+
desktopSubmenuActiveOptionIndicatorSpacing: '0.25rem',
|
|
42
|
+
desktopSubmenuActiveOptionIndicatorWidth: borders?.widthMedium,
|
|
43
|
+
desktopSubmenuActiveOptionIndicatorColor: 'currentColor'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...componentVariables
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { TopNavBarUser } from './index'
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
30
|
+
export const TopNavBarUserLocator = locator(TopNavBarUser.selector, {
|
|
31
|
+
/* custom component query methods go here */
|
|
32
|
+
})
|
|
@@ -0,0 +1,133 @@
|
|
|
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, Children } from 'react'
|
|
27
|
+
|
|
28
|
+
import { error } from '@instructure/console'
|
|
29
|
+
import { omitProps } from '@instructure/ui-react-utils'
|
|
30
|
+
import { testable } from '@instructure/ui-testable'
|
|
31
|
+
|
|
32
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
33
|
+
|
|
34
|
+
import { TopNavBarContext } from '../TopNavBarContext'
|
|
35
|
+
import type { ItemChild, TopNavBarItemProps } from '../TopNavBarItem/props'
|
|
36
|
+
|
|
37
|
+
import generateStyle from './styles'
|
|
38
|
+
|
|
39
|
+
import { propTypes, allowedProps } from './props'
|
|
40
|
+
import type { TopNavBarUserProps } from './props'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
---
|
|
44
|
+
parent: TopNavBar
|
|
45
|
+
id: TopNavBar.User
|
|
46
|
+
---
|
|
47
|
+
@module TopNavBarUser
|
|
48
|
+
@tsProps
|
|
49
|
+
**/
|
|
50
|
+
@withStyle(generateStyle, null)
|
|
51
|
+
@testable()
|
|
52
|
+
class TopNavBarUser extends Component<TopNavBarUserProps> {
|
|
53
|
+
static readonly componentId = 'TopNavBar.User'
|
|
54
|
+
|
|
55
|
+
static propTypes = propTypes
|
|
56
|
+
static allowedProps = allowedProps
|
|
57
|
+
static defaultProps = {}
|
|
58
|
+
|
|
59
|
+
declare context: React.ContextType<typeof TopNavBarContext>
|
|
60
|
+
static contextType = TopNavBarContext
|
|
61
|
+
|
|
62
|
+
ref: HTMLDivElement | null = null
|
|
63
|
+
|
|
64
|
+
handleRef = (el: HTMLDivElement | null) => {
|
|
65
|
+
const { elementRef } = this.props
|
|
66
|
+
|
|
67
|
+
this.ref = el
|
|
68
|
+
|
|
69
|
+
if (typeof elementRef === 'function') {
|
|
70
|
+
elementRef(el)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
componentDidMount() {
|
|
75
|
+
this.props.makeStyles?.()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
componentDidUpdate() {
|
|
79
|
+
this.props.makeStyles?.()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get content() {
|
|
83
|
+
const children = React.Children.toArray(this.props.children) as ItemChild[]
|
|
84
|
+
|
|
85
|
+
const allowedVariants: TopNavBarItemProps['variant'][] = [
|
|
86
|
+
'default',
|
|
87
|
+
'button',
|
|
88
|
+
'avatar'
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
return Children.map(children, (child) => {
|
|
92
|
+
const { id, variant } = child.props
|
|
93
|
+
|
|
94
|
+
if (variant && !allowedVariants.includes(variant)) {
|
|
95
|
+
error(
|
|
96
|
+
false,
|
|
97
|
+
`Item with id "${id}" has "${variant}" variant, but only the following variants are allowed in <TopNavBarUser>: ${allowedVariants.join(
|
|
98
|
+
', '
|
|
99
|
+
)}.`
|
|
100
|
+
)
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return child
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
render() {
|
|
109
|
+
const { styles } = this.props
|
|
110
|
+
|
|
111
|
+
if (!this.content || this.content.length === 0) {
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (this.context.layout === 'smallViewport') {
|
|
116
|
+
// in smallViewport mode it is rendered as a Drilldown
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
{...omitProps(this.props, allowedProps)}
|
|
123
|
+
ref={this.handleRef}
|
|
124
|
+
css={styles?.topNavBarUser}
|
|
125
|
+
>
|
|
126
|
+
{this.content}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { TopNavBarUser }
|
|
133
|
+
export default TopNavBarUser
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
29
|
+
|
|
30
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
31
|
+
import type {
|
|
32
|
+
OtherHTMLAttributes,
|
|
33
|
+
PropValidators,
|
|
34
|
+
ChildrenOfType
|
|
35
|
+
} from '@instructure/shared-types'
|
|
36
|
+
|
|
37
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
38
|
+
import type { ItemChild } from '../TopNavBarItem/props'
|
|
39
|
+
|
|
40
|
+
import { TopNavBarUser } from './index'
|
|
41
|
+
|
|
42
|
+
type UserChild = React.ComponentElement<TopNavBarUserProps, TopNavBarUser>
|
|
43
|
+
|
|
44
|
+
type TopNavBarUserOwnProps = {
|
|
45
|
+
/**
|
|
46
|
+
* Required children of type TopNavBar.Item.
|
|
47
|
+
*
|
|
48
|
+
* Only accepts 'default', 'button' and 'avatar' variants.
|
|
49
|
+
*
|
|
50
|
+
* In "smallViewport" mode it will always display as text (with or without avatar).
|
|
51
|
+
*/
|
|
52
|
+
children: ChildrenOfType<ItemChild>
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A function that returns a reference to root HTML element
|
|
56
|
+
*/
|
|
57
|
+
elementRef?: (el: HTMLDivElement | null) => void
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type PropKeys = keyof TopNavBarUserOwnProps
|
|
61
|
+
|
|
62
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
63
|
+
|
|
64
|
+
type TopNavBarUserProps = TopNavBarUserOwnProps &
|
|
65
|
+
WithStyleProps<null, TopNavBarUserStyle> &
|
|
66
|
+
OtherHTMLAttributes<TopNavBarUserOwnProps>
|
|
67
|
+
|
|
68
|
+
type TopNavBarUserStyle = ComponentStyle<'topNavBarUser'>
|
|
69
|
+
|
|
70
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
71
|
+
children: ChildrenPropTypes.oneOf([TopNavBarItem]).isRequired,
|
|
72
|
+
elementRef: PropTypes.func
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const allowedProps: AllowedPropKeys = ['children', 'elementRef']
|
|
76
|
+
|
|
77
|
+
export type {
|
|
78
|
+
UserChild,
|
|
79
|
+
TopNavBarUserProps,
|
|
80
|
+
TopNavBarUserOwnProps,
|
|
81
|
+
TopNavBarUserStyle
|
|
82
|
+
}
|
|
83
|
+
export { propTypes, allowedProps }
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { TopNavBarUserStyle } from './props'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ---
|
|
29
|
+
* private: true
|
|
30
|
+
* ---
|
|
31
|
+
* Generates the style object from the theme and provided additional information
|
|
32
|
+
* @param {Object} componentTheme The theme variable object.
|
|
33
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
34
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
35
|
+
* @return {Object} The final style object, which will be used in the component
|
|
36
|
+
*/
|
|
37
|
+
const generateStyle = (): TopNavBarUserStyle => {
|
|
38
|
+
return {
|
|
39
|
+
topNavBarUser: {
|
|
40
|
+
label: 'topNavBarUser',
|
|
41
|
+
flex: '0 0',
|
|
42
|
+
display: 'flex'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default generateStyle
|
|
@@ -0,0 +1,142 @@
|
|
|
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, { Component } from 'react'
|
|
26
|
+
|
|
27
|
+
import { error } from '@instructure/console'
|
|
28
|
+
import { testable } from '@instructure/ui-testable'
|
|
29
|
+
import { px } from '@instructure/ui-utils'
|
|
30
|
+
import { matchComponentTypes } from '@instructure/ui-react-utils'
|
|
31
|
+
|
|
32
|
+
import { Responsive } from '@instructure/ui-responsive'
|
|
33
|
+
|
|
34
|
+
import { TopNavBarActionItems } from './TopNavBarActionItems'
|
|
35
|
+
import { TopNavBarBrand } from './TopNavBarBrand'
|
|
36
|
+
import { TopNavBarItem } from './TopNavBarItem'
|
|
37
|
+
import { TopNavBarLayout } from './TopNavBarLayout'
|
|
38
|
+
import { TopNavBarMenuItems } from './TopNavBarMenuItems'
|
|
39
|
+
import { TopNavBarUser } from './TopNavBarUser'
|
|
40
|
+
|
|
41
|
+
import { TopNavBarContext } from './TopNavBarContext'
|
|
42
|
+
import type { TopNavBarLayouts } from './TopNavBarContext'
|
|
43
|
+
|
|
44
|
+
import { propTypes, allowedProps } from './props'
|
|
45
|
+
import type { TopNavBarProps } from './props'
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
---
|
|
49
|
+
category: components
|
|
50
|
+
---
|
|
51
|
+
@tsProps
|
|
52
|
+
**/
|
|
53
|
+
@testable()
|
|
54
|
+
class TopNavBar extends Component<TopNavBarProps> {
|
|
55
|
+
static readonly componentId = 'TopNavBar'
|
|
56
|
+
|
|
57
|
+
// TODO: mention subcomponent registration in "new component" docs
|
|
58
|
+
static ActionItems = TopNavBarActionItems
|
|
59
|
+
static Brand = TopNavBarBrand
|
|
60
|
+
static Item = TopNavBarItem
|
|
61
|
+
static Layout = TopNavBarLayout
|
|
62
|
+
static MenuItems = TopNavBarMenuItems
|
|
63
|
+
static User = TopNavBarUser
|
|
64
|
+
|
|
65
|
+
static contextType = TopNavBarContext
|
|
66
|
+
|
|
67
|
+
static propTypes = propTypes
|
|
68
|
+
static allowedProps = allowedProps
|
|
69
|
+
static defaultProps = {
|
|
70
|
+
breakpoint: 1024,
|
|
71
|
+
mediaQueryMatch: 'media',
|
|
72
|
+
inverseColor: false
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ref: HTMLDivElement | null = null
|
|
76
|
+
|
|
77
|
+
handleRef = (el: HTMLDivElement | null) => {
|
|
78
|
+
const { elementRef } = this.props
|
|
79
|
+
|
|
80
|
+
this.ref = el
|
|
81
|
+
|
|
82
|
+
if (typeof elementRef === 'function') {
|
|
83
|
+
elementRef(el)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get breakpoint() {
|
|
88
|
+
return px(this.props.breakpoint!)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const { children, mediaQueryMatch, inverseColor } = this.props
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Responsive
|
|
96
|
+
elementRef={this.handleRef}
|
|
97
|
+
match={mediaQueryMatch}
|
|
98
|
+
query={{
|
|
99
|
+
smallViewport: { maxWidth: this.breakpoint - 1 },
|
|
100
|
+
desktop: { minWidth: this.breakpoint }
|
|
101
|
+
}}
|
|
102
|
+
render={(_props, matches) => {
|
|
103
|
+
const layout = matches
|
|
104
|
+
? (matches[0] as TopNavBarLayouts)
|
|
105
|
+
: 'smallViewport'
|
|
106
|
+
|
|
107
|
+
const isInverseColor =
|
|
108
|
+
typeof inverseColor === 'function'
|
|
109
|
+
? inverseColor(layout)
|
|
110
|
+
: !!inverseColor
|
|
111
|
+
|
|
112
|
+
const content = children({
|
|
113
|
+
currentLayout: layout,
|
|
114
|
+
inverseColor: isInverseColor
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
if (!matchComponentTypes(content, [TopNavBarLayout])) {
|
|
118
|
+
error(
|
|
119
|
+
false,
|
|
120
|
+
'The `children` function prop of TopNavBar has to return a child of type <TopNavBar.Layout>, but it returned:',
|
|
121
|
+
content
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<TopNavBarContext.Provider
|
|
127
|
+
value={{
|
|
128
|
+
layout,
|
|
129
|
+
inverseColor: isInverseColor
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{content}
|
|
133
|
+
</TopNavBarContext.Provider>
|
|
134
|
+
)
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { TopNavBar }
|
|
142
|
+
export default TopNavBar
|