@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,331 @@
|
|
|
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 { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
32
|
+
import type {
|
|
33
|
+
TopNavBarItemTheme,
|
|
34
|
+
OtherHTMLAttributes,
|
|
35
|
+
PropValidators,
|
|
36
|
+
Renderable
|
|
37
|
+
} from '@instructure/shared-types'
|
|
38
|
+
|
|
39
|
+
import { Drilldown } from '@instructure/ui-drilldown'
|
|
40
|
+
import type { DrilldownProps } from '@instructure/ui-drilldown'
|
|
41
|
+
import type { PopoverProps } from '@instructure/ui-popover'
|
|
42
|
+
import type { TooltipProps } from '@instructure/ui-tooltip'
|
|
43
|
+
import type { BaseButtonOwnProps } from '@instructure/ui-buttons'
|
|
44
|
+
import type { ViewOwnProps, ViewProps } from '@instructure/ui-view'
|
|
45
|
+
|
|
46
|
+
import { TopNavBarContextType } from '../TopNavBarContext'
|
|
47
|
+
import { TopNavBarItem } from './index'
|
|
48
|
+
|
|
49
|
+
type ItemChild = React.ComponentElement<TopNavBarItemProps, TopNavBarItem>
|
|
50
|
+
type DrilldownSubmenu = React.ComponentElement<DrilldownProps, Drilldown>
|
|
51
|
+
|
|
52
|
+
type TopNavBarItemTooltipType =
|
|
53
|
+
| string
|
|
54
|
+
| {
|
|
55
|
+
renderTip: TooltipProps['renderTip']
|
|
56
|
+
color?: TooltipProps['color']
|
|
57
|
+
placement?: TooltipProps['placement']
|
|
58
|
+
offsetX?: TooltipProps['offsetX']
|
|
59
|
+
offsetY?: TooltipProps['offsetY']
|
|
60
|
+
onShowContent?: TooltipProps['onShowContent']
|
|
61
|
+
onHideContent?: TooltipProps['onHideContent']
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const topNavBarItemTooltipPropType = PropTypes.oneOfType([
|
|
65
|
+
PropTypes.string,
|
|
66
|
+
PropTypes.shape({
|
|
67
|
+
renderTip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
68
|
+
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
69
|
+
placement: PropTypes.string,
|
|
70
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
71
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
72
|
+
onShowContent: PropTypes.func,
|
|
73
|
+
onHideContent: PropTypes.func
|
|
74
|
+
})
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
type TopNavBarItemOwnProps = {
|
|
78
|
+
/**
|
|
79
|
+
* Required id, used for internal tracking,
|
|
80
|
+
* and it also appears as an id on the item element.
|
|
81
|
+
*/
|
|
82
|
+
id: string
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A required label of the navbar item.
|
|
86
|
+
*
|
|
87
|
+
* __Note__ that it is required even for the `variant="icon"` type items: the label will be used as an accessible label for screen readers.
|
|
88
|
+
*/
|
|
89
|
+
children: React.ReactNode
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The display variant of the item.
|
|
93
|
+
*
|
|
94
|
+
* The __"default"__ variant is displayed as a normal menu item.
|
|
95
|
+
*
|
|
96
|
+
* The __"button"__ variant is displayed as a button.
|
|
97
|
+
*
|
|
98
|
+
* The __"icon"__ variant is displayed as an icon without label.
|
|
99
|
+
*
|
|
100
|
+
* The __"avatar"__ variant is displayed as an avatar without label.
|
|
101
|
+
*/
|
|
102
|
+
variant?: 'default' | 'button' | 'icon' | 'avatar'
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The status of the item.
|
|
106
|
+
*
|
|
107
|
+
* The __"active"__ status indicates current page or currently active menu item.
|
|
108
|
+
* Only `variant="default"` items can be set to active.
|
|
109
|
+
*
|
|
110
|
+
* The __"disabled"__ status indicates that the items is disabled.
|
|
111
|
+
*/
|
|
112
|
+
status?: 'default' | 'active' | 'disabled'
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Renders the submenu for the item.
|
|
116
|
+
* Accepts a [Drilldown](#Drilldown) component.
|
|
117
|
+
* The menu toggle logic is controlled by the menu item.
|
|
118
|
+
*
|
|
119
|
+
* If you need more customization, use the `customPopoverConfig` prop.
|
|
120
|
+
*/
|
|
121
|
+
renderSubmenu?: DrilldownSubmenu
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Displays the open/close chevron next to the item,
|
|
125
|
+
* when it has a submenu or custom popover.
|
|
126
|
+
*/
|
|
127
|
+
showSubmenuChevron?: boolean
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Configures a custom Popover for the menu item.
|
|
131
|
+
* Accepts [Popover](#Popover) props (except "renderTrigger").
|
|
132
|
+
*
|
|
133
|
+
* Use this prop for features like search, tooltips, etc., and use
|
|
134
|
+
* the `renderSubmenu` prop for the default submenu!
|
|
135
|
+
*
|
|
136
|
+
* In small viewport mode only items in `<TopNavBar.ActionItems>` can display custom popovers.
|
|
137
|
+
*/
|
|
138
|
+
customPopoverConfig?: Omit<
|
|
139
|
+
PopoverProps,
|
|
140
|
+
'renderTrigger' | 'positionContainerDisplay'
|
|
141
|
+
>
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Configures a Tooltip for the menu item.
|
|
145
|
+
*
|
|
146
|
+
* Tooltips can be useful for `variant="icon"` or `variant="avatar"` type
|
|
147
|
+
* menu items where there is no visible text.
|
|
148
|
+
*
|
|
149
|
+
* Accepts a string or a config object containing a subset of props from [Tooltip](#Tooltip).
|
|
150
|
+
*/
|
|
151
|
+
tooltip?: TopNavBarItemTooltipType
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Config for displaying an avatar.
|
|
155
|
+
*
|
|
156
|
+
* Used only in `<TopNavBar.User>`, and it is a __required__ prop for the `variant="avatar"` type menu items.
|
|
157
|
+
*
|
|
158
|
+
* - __avatarSrc__: Avatar url
|
|
159
|
+
* - __avatarName__: A __required__ name (user's name) for the avatar
|
|
160
|
+
* - __avatarAlt__: Accessible label for the avatar
|
|
161
|
+
*/
|
|
162
|
+
renderAvatar?: {
|
|
163
|
+
avatarSrc?: string
|
|
164
|
+
avatarName: string
|
|
165
|
+
avatarAlt?: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Renders an icon before the label, or by itself.
|
|
170
|
+
*
|
|
171
|
+
* It is __required__ for the `variant="icon"` type menu items.
|
|
172
|
+
* It is also __required__ for items in `<TopNavBar.ActionItems>`
|
|
173
|
+
* in small viewport mode, because only the icons are displayed
|
|
174
|
+
* due to the lack of space.
|
|
175
|
+
*/
|
|
176
|
+
renderIcon?: Renderable
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* If the item goes to a new page, pass a href.
|
|
180
|
+
* Items with submenus cannot have href prop.
|
|
181
|
+
*/
|
|
182
|
+
href?: string
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* If the item does not go to a new page, pass an onClick.
|
|
186
|
+
* Items with submenus cannot have onClick prop, use the `onSubmenuToggle` prop instead.
|
|
187
|
+
*/
|
|
188
|
+
onClick?: (
|
|
189
|
+
event: React.MouseEvent<ViewOwnProps> | React.KeyboardEvent<ViewOwnProps>
|
|
190
|
+
) => void
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* __In desktop mode__, the callback fired when the item's submenu ([Drilldown](#Drilldown)) is toggled open/closed.
|
|
194
|
+
*/
|
|
195
|
+
onSubmenuToggle?: DrilldownProps['onToggle']
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* __In desktop mode__, the callback fired when mouse is over item.
|
|
199
|
+
*/
|
|
200
|
+
onMouseOver?: (event: React.MouseEvent<BaseButtonOwnProps>) => void
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* __In desktop mode__, the callback fired when mouse leaves item.
|
|
204
|
+
*/
|
|
205
|
+
onMouseOut?: (event: React.MouseEvent<BaseButtonOwnProps>) => void
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* __In desktop mode__, the callback fired when the item is focused.
|
|
209
|
+
*/
|
|
210
|
+
onFocus?: (event: React.FocusEvent<BaseButtonOwnProps>) => void
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* __In desktop mode__, the callback fired when the item is blurred.
|
|
214
|
+
*/
|
|
215
|
+
onBlur?: (event: React.FocusEvent<BaseButtonOwnProps>) => void
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* __In desktop mode__, the callback fired on keydown.
|
|
219
|
+
*/
|
|
220
|
+
onKeyDown?: (event: React.KeyboardEvent<ViewProps>) => void
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* __In desktop mode__, the callback fired on keyup.
|
|
224
|
+
*/
|
|
225
|
+
onKeyUp?: (event: React.KeyboardEvent<BaseButtonOwnProps>) => void
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* A function that returns a reference to root HTML element
|
|
229
|
+
*/
|
|
230
|
+
elementRef?: (el: Element | null) => void
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* A function that returns a reference to the button/link HTML element
|
|
234
|
+
*/
|
|
235
|
+
itemRef?: (el: HTMLButtonElement | HTMLLinkElement | null) => void
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
type PropKeys = keyof TopNavBarItemOwnProps
|
|
239
|
+
|
|
240
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
241
|
+
|
|
242
|
+
type TopNavBarItemProps = TopNavBarItemOwnProps &
|
|
243
|
+
WithStyleProps<TopNavBarItemTheme, TopNavBarItemStyle> &
|
|
244
|
+
OtherHTMLAttributes<TopNavBarItemOwnProps> &
|
|
245
|
+
WithDeterministicIdProps
|
|
246
|
+
|
|
247
|
+
type TopNavBarItemStyle = ComponentStyle<
|
|
248
|
+
| 'topNavBarItem'
|
|
249
|
+
| 'container'
|
|
250
|
+
| 'content'
|
|
251
|
+
| 'avatarContainer'
|
|
252
|
+
| 'submenuTriggerContainer'
|
|
253
|
+
| 'submenuIcon'
|
|
254
|
+
> & {
|
|
255
|
+
focusOutlineOffset: string | 0
|
|
256
|
+
itemInlinePadding: string | 0
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type TopNavBarItemState = {
|
|
260
|
+
isSubmenuOpen: boolean
|
|
261
|
+
isPopoverOpen: boolean
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
type TopNavBarItemStyleProps = {
|
|
265
|
+
layout: TopNavBarContextType['layout']
|
|
266
|
+
inverseColor: TopNavBarContextType['inverseColor']
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
270
|
+
id: PropTypes.string.isRequired,
|
|
271
|
+
children: PropTypes.node.isRequired,
|
|
272
|
+
variant: PropTypes.oneOf(['default', 'button', 'icon', 'avatar']),
|
|
273
|
+
status: PropTypes.oneOf(['default', 'active', 'disabled']),
|
|
274
|
+
renderSubmenu: ChildrenPropTypes.oneOf([Drilldown]),
|
|
275
|
+
showSubmenuChevron: PropTypes.bool,
|
|
276
|
+
customPopoverConfig: PropTypes.object,
|
|
277
|
+
tooltip: topNavBarItemTooltipPropType,
|
|
278
|
+
renderAvatar: PropTypes.shape({
|
|
279
|
+
avatarName: PropTypes.string.isRequired,
|
|
280
|
+
avatarSrc: PropTypes.string,
|
|
281
|
+
avatarAlt: PropTypes.string
|
|
282
|
+
}),
|
|
283
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
284
|
+
href: PropTypes.string,
|
|
285
|
+
onClick: PropTypes.func,
|
|
286
|
+
onSubmenuToggle: PropTypes.func,
|
|
287
|
+
onMouseOver: PropTypes.func,
|
|
288
|
+
onMouseOut: PropTypes.func,
|
|
289
|
+
onFocus: PropTypes.func,
|
|
290
|
+
onBlur: PropTypes.func,
|
|
291
|
+
onKeyDown: PropTypes.func,
|
|
292
|
+
onKeyUp: PropTypes.func,
|
|
293
|
+
elementRef: PropTypes.func,
|
|
294
|
+
itemRef: PropTypes.func
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const allowedProps: AllowedPropKeys = [
|
|
298
|
+
'id',
|
|
299
|
+
'children',
|
|
300
|
+
'variant',
|
|
301
|
+
'status',
|
|
302
|
+
'renderSubmenu',
|
|
303
|
+
'showSubmenuChevron',
|
|
304
|
+
'customPopoverConfig',
|
|
305
|
+
'tooltip',
|
|
306
|
+
'renderAvatar',
|
|
307
|
+
'renderIcon',
|
|
308
|
+
'href',
|
|
309
|
+
'onClick',
|
|
310
|
+
'onSubmenuToggle',
|
|
311
|
+
'onMouseOver',
|
|
312
|
+
'onMouseOut',
|
|
313
|
+
'onFocus',
|
|
314
|
+
'onBlur',
|
|
315
|
+
'onKeyDown',
|
|
316
|
+
'onKeyUp',
|
|
317
|
+
'elementRef',
|
|
318
|
+
'itemRef'
|
|
319
|
+
]
|
|
320
|
+
|
|
321
|
+
export type {
|
|
322
|
+
ItemChild,
|
|
323
|
+
TopNavBarItemProps,
|
|
324
|
+
TopNavBarItemOwnProps,
|
|
325
|
+
TopNavBarItemStyle,
|
|
326
|
+
TopNavBarItemState,
|
|
327
|
+
TopNavBarItemStyleProps,
|
|
328
|
+
DrilldownSubmenu,
|
|
329
|
+
TopNavBarItemTooltipType
|
|
330
|
+
}
|
|
331
|
+
export { propTypes, allowedProps, topNavBarItemTooltipPropType }
|
|
@@ -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 type { TopNavBarItemTheme } from '@instructure/shared-types'
|
|
26
|
+
import type {
|
|
27
|
+
TopNavBarItemProps,
|
|
28
|
+
TopNavBarItemStyleProps,
|
|
29
|
+
TopNavBarItemStyle
|
|
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: TopNavBarItemTheme,
|
|
44
|
+
props: TopNavBarItemProps,
|
|
45
|
+
state: TopNavBarItemStyleProps
|
|
46
|
+
): TopNavBarItemStyle => {
|
|
47
|
+
const { status, variant, renderSubmenu, renderAvatar, customPopoverConfig } =
|
|
48
|
+
props
|
|
49
|
+
const { layout, inverseColor } = state
|
|
50
|
+
|
|
51
|
+
const isSmallViewport = layout === 'smallViewport'
|
|
52
|
+
const isActive = renderAvatar
|
|
53
|
+
? false
|
|
54
|
+
: status === 'active' && variant === 'default'
|
|
55
|
+
const hasPopover = renderSubmenu || customPopoverConfig
|
|
56
|
+
|
|
57
|
+
const activeIndicatorPosition = `calc(${componentTheme.itemInlinePadding} - ${componentTheme.activeItemIndicatorSpacing})`
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
topNavBarItem: {
|
|
61
|
+
label: 'topNavBarItem',
|
|
62
|
+
padding: `0 calc(${componentTheme.itemSpacing} / 2)`,
|
|
63
|
+
height: '100%',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
alignItems: hasPopover ? 'stretch' : 'center'
|
|
67
|
+
},
|
|
68
|
+
container: {
|
|
69
|
+
label: 'topNavBarItem__container',
|
|
70
|
+
display: 'flex',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
position: 'relative',
|
|
74
|
+
|
|
75
|
+
...(isActive && {
|
|
76
|
+
'&::after': {
|
|
77
|
+
content: '""',
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
insetBlockEnd: 0,
|
|
80
|
+
insetInlineStart: activeIndicatorPosition,
|
|
81
|
+
insetInlineEnd: activeIndicatorPosition,
|
|
82
|
+
height: componentTheme.activeIndicatorWidth,
|
|
83
|
+
background: inverseColor
|
|
84
|
+
? componentTheme.activeIndicatorColorInverse
|
|
85
|
+
: componentTheme.activeIndicatorColor,
|
|
86
|
+
display: 'block'
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
|
|
90
|
+
'& a': {
|
|
91
|
+
textDecoration: 'none'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
content: {
|
|
95
|
+
label: 'topNavBarItem__content',
|
|
96
|
+
fontSize: componentTheme.fontSize,
|
|
97
|
+
fontFamily: componentTheme.fontFamily,
|
|
98
|
+
fontWeight: componentTheme.fontWeight,
|
|
99
|
+
appearance: 'none',
|
|
100
|
+
border: 0,
|
|
101
|
+
outline: 0,
|
|
102
|
+
margin: 0,
|
|
103
|
+
textDecoration: 'none',
|
|
104
|
+
whiteSpace: 'nowrap',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
justifyContent: 'center',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
color: inverseColor ? componentTheme.colorInverse : componentTheme.color,
|
|
109
|
+
|
|
110
|
+
...(isActive && {
|
|
111
|
+
fontWeight: componentTheme.activeItemFontWeight
|
|
112
|
+
}),
|
|
113
|
+
|
|
114
|
+
'*': {
|
|
115
|
+
pointerEvents: 'none'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
avatarContainer: {
|
|
119
|
+
label: 'topNavBarItem__avatarContainer',
|
|
120
|
+
display: 'flex',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
paddingInlineEnd: `calc(${componentTheme.iconTextGap} * 1.5)`
|
|
123
|
+
},
|
|
124
|
+
submenuTriggerContainer: {
|
|
125
|
+
label: 'topNavBarItem__submenuTriggerContainer',
|
|
126
|
+
height: '100%',
|
|
127
|
+
display: 'flex',
|
|
128
|
+
alignItems: 'center'
|
|
129
|
+
},
|
|
130
|
+
submenuIcon: {
|
|
131
|
+
label: 'topNavBarItem__submenuIcon',
|
|
132
|
+
fontSize: '0.875em',
|
|
133
|
+
display: 'flex',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
paddingInlineStart: componentTheme.iconTextGap
|
|
136
|
+
},
|
|
137
|
+
focusOutlineOffset: isSmallViewport ? '0.375rem' : '0.625rem',
|
|
138
|
+
itemInlinePadding: componentTheme.itemInlinePadding
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default generateStyle
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { TopNavBarItemTheme } 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): TopNavBarItemTheme => {
|
|
34
|
+
const { colors, spacing, typography, borders } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: TopNavBarItemTheme = {
|
|
37
|
+
fontSize: typography?.fontSizeMedium,
|
|
38
|
+
fontFamily: typography?.fontFamily,
|
|
39
|
+
fontWeight: typography?.fontWeightNormal,
|
|
40
|
+
|
|
41
|
+
color: 'inherit',
|
|
42
|
+
colorInverse: 'inherit',
|
|
43
|
+
|
|
44
|
+
itemInlinePadding: spacing?.xSmall,
|
|
45
|
+
itemSpacing: spacing?.xSmall,
|
|
46
|
+
iconTextGap: spacing?.xSmall,
|
|
47
|
+
|
|
48
|
+
activeItemFontWeight: typography?.fontWeightBold,
|
|
49
|
+
activeItemIndicatorSpacing: '0.25rem',
|
|
50
|
+
activeIndicatorWidth: borders?.widthMedium,
|
|
51
|
+
activeIndicatorColor: colors?.textLightest,
|
|
52
|
+
activeIndicatorColorInverse: colors.textDarkest
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...componentVariables
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
import { find } from '@instructure/ui-test-utils'
|
|
27
|
+
import { getComputedStyle } from '@instructure/ui-dom-utils'
|
|
28
|
+
|
|
29
|
+
import { TopNavBarBrandLocator } from '../../TopNavBarBrand/TopNavBarBrandLocator'
|
|
30
|
+
import { TopNavBarMenuItemsLocator } from '../../TopNavBarMenuItems/TopNavBarMenuItemsLocator'
|
|
31
|
+
import { TopNavBarActionItemsLocator } from '../../TopNavBarActionItems/TopNavBarActionItemsLocator'
|
|
32
|
+
import { TopNavBarUserLocator } from '../../TopNavBarUser/TopNavBarUserLocator'
|
|
33
|
+
|
|
34
|
+
import { TopNavBarDesktopLayout } from './index'
|
|
35
|
+
|
|
36
|
+
export const TopNavBarDesktopLayoutLocator = locator(
|
|
37
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
38
|
+
TopNavBarDesktopLayout.selector,
|
|
39
|
+
{
|
|
40
|
+
findBrandContainer: (...args: any[]) => {
|
|
41
|
+
return find('[class$=-topNavBarDesktopLayout__brandContainer]', ...args)
|
|
42
|
+
},
|
|
43
|
+
findMenuItemsContainer: (...args: any[]) => {
|
|
44
|
+
return find(
|
|
45
|
+
'[class$=-topNavBarDesktopLayout__menuItemsContainer]',
|
|
46
|
+
...args
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
findActionItemsContainer: (...args: any[]) => {
|
|
50
|
+
return find(
|
|
51
|
+
'[class$=-topNavBarDesktopLayout__actionItemsContainer]',
|
|
52
|
+
...args
|
|
53
|
+
)
|
|
54
|
+
},
|
|
55
|
+
findUserContainer: (...args: any[]) => {
|
|
56
|
+
return find('[class$=-topNavBarDesktopLayout__userContainer]', ...args)
|
|
57
|
+
},
|
|
58
|
+
findBrand: (...args: any[]) => {
|
|
59
|
+
return TopNavBarBrandLocator.find(...args)
|
|
60
|
+
},
|
|
61
|
+
findMenuItems: (...args: any[]) => {
|
|
62
|
+
return TopNavBarMenuItemsLocator.find(...args)
|
|
63
|
+
},
|
|
64
|
+
findActionItems: (...args: any[]) => {
|
|
65
|
+
return TopNavBarActionItemsLocator.find(...args)
|
|
66
|
+
},
|
|
67
|
+
findUser: (...args: any[]) => {
|
|
68
|
+
return TopNavBarUserLocator.find(...args)
|
|
69
|
+
},
|
|
70
|
+
getActionsUserSeparatorBackground: async (...args: any[]) => {
|
|
71
|
+
try {
|
|
72
|
+
const user = await find(
|
|
73
|
+
'[class$=-topNavBarDesktopLayout__userContainer]',
|
|
74
|
+
...args
|
|
75
|
+
)
|
|
76
|
+
return user
|
|
77
|
+
? getComputedStyle(user.getDOMNode(), '::before').backgroundColor
|
|
78
|
+
: 'rgba(0, 0, 0, 0)'
|
|
79
|
+
} catch {
|
|
80
|
+
return 'rgba(0, 0, 0, 0)'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
)
|