@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,139 @@
|
|
|
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 { getElementType, omitProps } from '@instructure/ui-react-utils'
|
|
29
|
+
import { testable } from '@instructure/ui-testable'
|
|
30
|
+
|
|
31
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
32
|
+
|
|
33
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
34
|
+
import { View } from '@instructure/ui-view'
|
|
35
|
+
|
|
36
|
+
import { TopNavBarContext } from '../TopNavBarContext'
|
|
37
|
+
|
|
38
|
+
import generateStyle from './styles'
|
|
39
|
+
import generateComponentTheme from './theme'
|
|
40
|
+
|
|
41
|
+
import { propTypes, allowedProps } from './props'
|
|
42
|
+
import type { TopNavBarBrandProps, TopNavBarBrandStyleProps } from './props'
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
---
|
|
46
|
+
parent: TopNavBar
|
|
47
|
+
id: TopNavBar.Brand
|
|
48
|
+
---
|
|
49
|
+
@module TopNavBarBrand
|
|
50
|
+
@tsProps
|
|
51
|
+
**/
|
|
52
|
+
@withStyle(generateStyle, generateComponentTheme)
|
|
53
|
+
@testable()
|
|
54
|
+
class TopNavBarBrand extends Component<TopNavBarBrandProps> {
|
|
55
|
+
static readonly componentId = 'TopNavBar.Brand'
|
|
56
|
+
// TODO: add to the docs: making it static on parent and jsdocs parent/module settings, dont export child on its own
|
|
57
|
+
|
|
58
|
+
static propTypes = propTypes
|
|
59
|
+
static allowedProps = allowedProps
|
|
60
|
+
static defaultProps = {}
|
|
61
|
+
|
|
62
|
+
declare context: React.ContextType<typeof TopNavBarContext>
|
|
63
|
+
static contextType = TopNavBarContext
|
|
64
|
+
|
|
65
|
+
ref: HTMLDivElement | null = null
|
|
66
|
+
|
|
67
|
+
handleRef = (el: HTMLDivElement | null) => {
|
|
68
|
+
const { elementRef } = this.props
|
|
69
|
+
|
|
70
|
+
this.ref = el
|
|
71
|
+
|
|
72
|
+
if (typeof elementRef === 'function') {
|
|
73
|
+
elementRef(el)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
componentDidMount() {
|
|
78
|
+
this.props.makeStyles?.(this.makeStylesVariables)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
componentDidUpdate() {
|
|
82
|
+
this.props.makeStyles?.(this.makeStylesVariables)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get makeStylesVariables(): TopNavBarBrandStyleProps {
|
|
86
|
+
return {
|
|
87
|
+
layout: this.context.layout
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const { screenReaderLabel, renderName, renderIcon, href, onClick, styles } =
|
|
93
|
+
this.props
|
|
94
|
+
|
|
95
|
+
const ElementType = getElementType(TopNavBarBrand, this.props)
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div ref={this.handleRef} css={styles?.topNavBarBrand}>
|
|
99
|
+
{(renderIcon || renderName) && (
|
|
100
|
+
<View
|
|
101
|
+
{...omitProps(this.props, allowedProps)}
|
|
102
|
+
css={styles?.container}
|
|
103
|
+
as={ElementType}
|
|
104
|
+
href={href}
|
|
105
|
+
onClick={onClick}
|
|
106
|
+
position="relative"
|
|
107
|
+
focusColor={this.context.inverseColor ? 'info' : 'inverse'}
|
|
108
|
+
focusPosition="inset"
|
|
109
|
+
borderRadius="medium"
|
|
110
|
+
themeOverride={{ focusOutlineInset: styles?.focusOutlineInset }}
|
|
111
|
+
>
|
|
112
|
+
<ScreenReaderContent>{screenReaderLabel}</ScreenReaderContent>
|
|
113
|
+
{renderIcon && this.context.layout !== 'smallViewport' && (
|
|
114
|
+
<div
|
|
115
|
+
css={styles?.iconContainer}
|
|
116
|
+
role="presentation"
|
|
117
|
+
aria-hidden="true"
|
|
118
|
+
>
|
|
119
|
+
{renderIcon}
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
{renderName && (
|
|
123
|
+
<div
|
|
124
|
+
css={styles?.nameContainer}
|
|
125
|
+
role="presentation"
|
|
126
|
+
aria-hidden="true"
|
|
127
|
+
>
|
|
128
|
+
{renderName}
|
|
129
|
+
</div>
|
|
130
|
+
)}
|
|
131
|
+
</View>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { TopNavBarBrand }
|
|
139
|
+
export default TopNavBarBrand
|
|
@@ -0,0 +1,146 @@
|
|
|
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 type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
29
|
+
import type {
|
|
30
|
+
TopNavBarBrandTheme,
|
|
31
|
+
OtherHTMLAttributes,
|
|
32
|
+
PropValidators,
|
|
33
|
+
AsElementType
|
|
34
|
+
} from '@instructure/shared-types'
|
|
35
|
+
import type { ViewOwnProps } from '@instructure/ui-view'
|
|
36
|
+
|
|
37
|
+
import type { TopNavBarContextType } from '../TopNavBarContext'
|
|
38
|
+
|
|
39
|
+
import { TopNavBarBrand } from './index'
|
|
40
|
+
|
|
41
|
+
type BrandChild = React.ComponentElement<TopNavBarBrandProps, TopNavBarBrand>
|
|
42
|
+
|
|
43
|
+
type TopNavBarBrandOwnProps = {
|
|
44
|
+
/**
|
|
45
|
+
* A label is required for accessibility (e.g. name).
|
|
46
|
+
*/
|
|
47
|
+
screenReaderLabel: string
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The app/product/brand/company/etc. name.
|
|
51
|
+
*/
|
|
52
|
+
renderName?: React.ReactNode
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The app/product/brand/company/etc. logo or icon.
|
|
56
|
+
* The icon is not displayed in "smallViewport" mode.
|
|
57
|
+
*/
|
|
58
|
+
renderIcon?: React.ReactNode
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Background color of the brand name.
|
|
62
|
+
* The background is not displayed in "smallViewport" mode.
|
|
63
|
+
*/
|
|
64
|
+
nameBackground?: string
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Background color of the icon, usually the brand color (when an icon is provided).
|
|
68
|
+
* The background is not displayed in "smallViewport" mode.
|
|
69
|
+
*/
|
|
70
|
+
iconBackground?: string
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* If the item goes to a new page, pass a href.
|
|
74
|
+
*/
|
|
75
|
+
href?: string
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* If the item does not go to a new page, pass an onClick
|
|
79
|
+
*/
|
|
80
|
+
onClick?: (event: React.MouseEvent<ViewOwnProps>) => void
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
84
|
+
*/
|
|
85
|
+
as?: AsElementType
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A function that returns a reference to root HTML element
|
|
89
|
+
*/
|
|
90
|
+
elementRef?: (el: HTMLDivElement | null) => void
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type PropKeys = keyof TopNavBarBrandOwnProps
|
|
94
|
+
|
|
95
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
96
|
+
|
|
97
|
+
type TopNavBarBrandProps = TopNavBarBrandOwnProps &
|
|
98
|
+
WithStyleProps<TopNavBarBrandTheme, TopNavBarBrandStyle> &
|
|
99
|
+
OtherHTMLAttributes<TopNavBarBrandOwnProps>
|
|
100
|
+
|
|
101
|
+
type TopNavBarBrandStyle = ComponentStyle<
|
|
102
|
+
| 'topNavBarBrand'
|
|
103
|
+
| 'container'
|
|
104
|
+
| 'nameContainer'
|
|
105
|
+
| 'name'
|
|
106
|
+
| 'iconContainer'
|
|
107
|
+
| 'icon'
|
|
108
|
+
> &
|
|
109
|
+
Pick<TopNavBarBrandTheme, 'focusOutlineInset'>
|
|
110
|
+
|
|
111
|
+
type TopNavBarBrandStyleProps = {
|
|
112
|
+
layout: TopNavBarContextType['layout']
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
116
|
+
screenReaderLabel: PropTypes.string.isRequired,
|
|
117
|
+
renderName: PropTypes.node,
|
|
118
|
+
renderIcon: PropTypes.node,
|
|
119
|
+
nameBackground: PropTypes.string,
|
|
120
|
+
iconBackground: PropTypes.string,
|
|
121
|
+
href: PropTypes.string,
|
|
122
|
+
onClick: PropTypes.func,
|
|
123
|
+
as: PropTypes.elementType,
|
|
124
|
+
elementRef: PropTypes.func
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const allowedProps: AllowedPropKeys = [
|
|
128
|
+
'screenReaderLabel',
|
|
129
|
+
'renderName',
|
|
130
|
+
'renderIcon',
|
|
131
|
+
'nameBackground',
|
|
132
|
+
'iconBackground',
|
|
133
|
+
'href',
|
|
134
|
+
'onClick',
|
|
135
|
+
'as',
|
|
136
|
+
'elementRef'
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
export type {
|
|
140
|
+
BrandChild,
|
|
141
|
+
TopNavBarBrandProps,
|
|
142
|
+
TopNavBarBrandOwnProps,
|
|
143
|
+
TopNavBarBrandStyle,
|
|
144
|
+
TopNavBarBrandStyleProps
|
|
145
|
+
}
|
|
146
|
+
export { propTypes, allowedProps }
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { TopNavBarBrandTheme } from '@instructure/shared-types'
|
|
26
|
+
import type {
|
|
27
|
+
TopNavBarBrandProps,
|
|
28
|
+
TopNavBarBrandStyle,
|
|
29
|
+
TopNavBarBrandStyleProps
|
|
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: TopNavBarBrandTheme,
|
|
44
|
+
props: TopNavBarBrandProps,
|
|
45
|
+
state: TopNavBarBrandStyleProps
|
|
46
|
+
): TopNavBarBrandStyle => {
|
|
47
|
+
const { nameBackground, iconBackground } = props
|
|
48
|
+
const isDesktop = state.layout === 'desktop'
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
topNavBarBrand: {
|
|
52
|
+
label: 'topNavBarBrand',
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'stretch'
|
|
55
|
+
},
|
|
56
|
+
container: {
|
|
57
|
+
label: 'topNavBarBrand__container',
|
|
58
|
+
display: 'flex',
|
|
59
|
+
justifyContent: 'flex-start',
|
|
60
|
+
alignItems: 'stretch',
|
|
61
|
+
border: 0,
|
|
62
|
+
outline: 0,
|
|
63
|
+
padding: 0,
|
|
64
|
+
margin: 0,
|
|
65
|
+
appearance: 'none',
|
|
66
|
+
textDecoration: 'none'
|
|
67
|
+
},
|
|
68
|
+
nameContainer: {
|
|
69
|
+
label: 'topNavBarBrand__nameContainer',
|
|
70
|
+
display: 'flex',
|
|
71
|
+
justifyContent: 'center',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
pointerEvents: 'none',
|
|
74
|
+
padding: componentTheme.logoPadding,
|
|
75
|
+
background: isDesktop ? nameBackground : undefined
|
|
76
|
+
},
|
|
77
|
+
name: {
|
|
78
|
+
label: 'topNavBarBrand__name',
|
|
79
|
+
display: 'flex',
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
height: componentTheme.logoHeight
|
|
82
|
+
},
|
|
83
|
+
iconContainer: {
|
|
84
|
+
label: 'topNavBarBrand__iconContainer',
|
|
85
|
+
display: 'flex',
|
|
86
|
+
justifyContent: 'center',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
pointerEvents: 'none',
|
|
89
|
+
padding: componentTheme.iconPadding,
|
|
90
|
+
background: isDesktop ? iconBackground : undefined
|
|
91
|
+
},
|
|
92
|
+
icon: {
|
|
93
|
+
label: 'topNavBarBrand__icon',
|
|
94
|
+
display: 'flex',
|
|
95
|
+
justifyContent: 'center',
|
|
96
|
+
alignItems: 'center'
|
|
97
|
+
},
|
|
98
|
+
focusOutlineInset: componentTheme.focusOutlineInset
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default generateStyle
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { TopNavBarBrandTheme } 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): TopNavBarBrandTheme => {
|
|
34
|
+
const { spacing } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: TopNavBarBrandTheme = {
|
|
37
|
+
logoHeight: '2.25rem',
|
|
38
|
+
logoPadding: spacing.small,
|
|
39
|
+
iconPadding: spacing.small,
|
|
40
|
+
focusOutlineInset: '-0.25rem'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...componentVariables
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default generateComponentTheme
|
|
@@ -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 { createContext } from 'react'
|
|
26
|
+
|
|
27
|
+
type TopNavBarLayouts = 'desktop' | 'smallViewport'
|
|
28
|
+
|
|
29
|
+
type TopNavBarContextType = {
|
|
30
|
+
layout: TopNavBarLayouts
|
|
31
|
+
inverseColor: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
private: true
|
|
37
|
+
---
|
|
38
|
+
@module TopNavBarContext
|
|
39
|
+
**/
|
|
40
|
+
const TopNavBarContext = createContext<TopNavBarContextType>({
|
|
41
|
+
layout: 'desktop',
|
|
42
|
+
inverseColor: false
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export default TopNavBarContext
|
|
46
|
+
export { TopNavBarContext }
|
|
47
|
+
export type { TopNavBarLayouts, TopNavBarContextType }
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
/* eslint-disable no-restricted-imports */
|
|
30
|
+
// @ts-expect-error bypass no type definition found error
|
|
31
|
+
import { BaseButtonLocator } from '@instructure/ui-buttons/es/BaseButton/BaseButtonLocator'
|
|
32
|
+
// @ts-expect-error bypass no type definition found error
|
|
33
|
+
import { TooltipLocator } from '@instructure/ui-tooltip/es/Tooltip/TooltipLocator'
|
|
34
|
+
// @ts-expect-error bypass no type definition found error
|
|
35
|
+
import { AvatarLocator } from '@instructure/ui-avatar/es/Avatar/AvatarLocator'
|
|
36
|
+
// @ts-expect-error bypass no type definition found error
|
|
37
|
+
import { DrilldownLocator } from '@instructure/ui-drilldown/es/Drilldown/DrilldownLocator'
|
|
38
|
+
// @ts-expect-error bypass no type definition found error
|
|
39
|
+
import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator'
|
|
40
|
+
/* eslint-enable no-restricted-imports */
|
|
41
|
+
|
|
42
|
+
import { TopNavBarItem } from './index'
|
|
43
|
+
|
|
44
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
45
|
+
export const TopNavBarItemLocator = locator(TopNavBarItem.selector, {
|
|
46
|
+
findButton: (...args: any[]) => {
|
|
47
|
+
return BaseButtonLocator.find(...args)
|
|
48
|
+
},
|
|
49
|
+
getButtonBackground: async () => {
|
|
50
|
+
const buttonContent = await find('[class$="-baseButton__content"]')
|
|
51
|
+
return buttonContent
|
|
52
|
+
? getComputedStyle(buttonContent.getDOMNode()).backgroundColor
|
|
53
|
+
: undefined
|
|
54
|
+
},
|
|
55
|
+
getButtonBorder: async () => {
|
|
56
|
+
const buttonContent = await find('[class$="-baseButton__content"]')
|
|
57
|
+
return buttonContent
|
|
58
|
+
? getComputedStyle(buttonContent.getDOMNode()).border
|
|
59
|
+
: undefined
|
|
60
|
+
},
|
|
61
|
+
getButtonOpacity: async () => {
|
|
62
|
+
const buttonContent = await find('[class$="-baseButton__content"]')
|
|
63
|
+
return buttonContent
|
|
64
|
+
? getComputedStyle(buttonContent.getDOMNode()).opacity
|
|
65
|
+
: undefined
|
|
66
|
+
},
|
|
67
|
+
getFocusRingColor: async () => {
|
|
68
|
+
const buttonContent = await find('[class$="-baseButton"]')
|
|
69
|
+
return buttonContent
|
|
70
|
+
? getComputedStyle(buttonContent.getDOMNode(), '::before').borderColor
|
|
71
|
+
: undefined
|
|
72
|
+
},
|
|
73
|
+
getActiveIndicatorStyle: async () => {
|
|
74
|
+
const container = await find('[class$="-topNavBarItem__container"]')
|
|
75
|
+
return getComputedStyle(container.getDOMNode(), '::after')
|
|
76
|
+
},
|
|
77
|
+
findContent: (...args: any[]) => {
|
|
78
|
+
return find('[class$="-topNavBarItem__content"]', ...args)
|
|
79
|
+
},
|
|
80
|
+
findSubmenu: (...args: any[]) => {
|
|
81
|
+
return DrilldownLocator.find(...args)
|
|
82
|
+
},
|
|
83
|
+
findCustomPopover: async (...args: any[]) => {
|
|
84
|
+
const popover = await PopoverLocator.find(...args)
|
|
85
|
+
|
|
86
|
+
if (popover) {
|
|
87
|
+
const isDrilldown = popover.getAttribute('data-cid').includes('Drilldown')
|
|
88
|
+
return isDrilldown ? null : popover
|
|
89
|
+
} else {
|
|
90
|
+
return popover
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
findTooltip: (...args: any[]) => {
|
|
94
|
+
return TooltipLocator.find(...args)
|
|
95
|
+
},
|
|
96
|
+
findIcon: (...args: any[]) => {
|
|
97
|
+
return find('[class*="-baseButton__icon"] [class$="-svgIcon"]', ...args)
|
|
98
|
+
},
|
|
99
|
+
findSubmenuChevron: (...args: any[]) => {
|
|
100
|
+
return find(
|
|
101
|
+
'[class$="-topNavBarItem__submenuIcon"] [class$="-svgIcon"]',
|
|
102
|
+
...args
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
findAvatar: (...args: any[]) => {
|
|
106
|
+
return AvatarLocator.find(...args)
|
|
107
|
+
},
|
|
108
|
+
findScreenReaderLabel: (...args: any[]) => {
|
|
109
|
+
return find('[class$="-screenReaderContent"]', ...args)
|
|
110
|
+
}
|
|
111
|
+
})
|