@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,53 @@
|
|
|
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
|
+
/* eslint-disable no-restricted-imports */
|
|
28
|
+
// @ts-expect-error bypass no type definition found error
|
|
29
|
+
import { TruncateListLocator } from '@instructure/ui-truncate-list/es/TruncateList/TruncateListLocator'
|
|
30
|
+
/* eslint-enable no-restricted-imports */
|
|
31
|
+
|
|
32
|
+
import { TopNavBarItemLocator } from '../TopNavBarItem/TopNavBarItemLocator'
|
|
33
|
+
|
|
34
|
+
import { TopNavBarActionItems } from './index'
|
|
35
|
+
|
|
36
|
+
export const TopNavBarActionItemsLocator = 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
|
+
TopNavBarActionItems.selector,
|
|
39
|
+
{
|
|
40
|
+
findAllActionItems: (...args: any[]) => {
|
|
41
|
+
return TopNavBarItemLocator.findAll(...args)
|
|
42
|
+
},
|
|
43
|
+
findTruncateList: (...args: any[]) => {
|
|
44
|
+
return TruncateListLocator.find(...args)
|
|
45
|
+
},
|
|
46
|
+
findTruncateListTriggerItem: async (...args: any[]) => {
|
|
47
|
+
const truncateList = await TruncateListLocator.find(...args)
|
|
48
|
+
if (!truncateList) return undefined
|
|
49
|
+
const allItems = await TopNavBarItemLocator.findAll(...args)
|
|
50
|
+
return allItems[allItems.length - 1]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
@@ -0,0 +1,299 @@
|
|
|
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 {
|
|
29
|
+
omitProps,
|
|
30
|
+
passthroughProps,
|
|
31
|
+
safeCloneElement,
|
|
32
|
+
withDeterministicId
|
|
33
|
+
} from '@instructure/ui-react-utils'
|
|
34
|
+
import { testable } from '@instructure/ui-testable'
|
|
35
|
+
import { warn, error } from '@instructure/console'
|
|
36
|
+
|
|
37
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
38
|
+
|
|
39
|
+
import { Drilldown } from '@instructure/ui-drilldown'
|
|
40
|
+
import { IconMoreLine } from '@instructure/ui-icons'
|
|
41
|
+
import { TruncateList } from '@instructure/ui-truncate-list'
|
|
42
|
+
|
|
43
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
44
|
+
import type { ItemChild } from '../TopNavBarItem/props'
|
|
45
|
+
import {
|
|
46
|
+
mapItemsForDrilldown,
|
|
47
|
+
renderMappedItemDrilldownSubpages,
|
|
48
|
+
renderMappedItemsAsDrilldownOptions
|
|
49
|
+
} from '../utils/mapItemsForDrilldown'
|
|
50
|
+
import type { RenderOptionContent } from '../utils/mapItemsForDrilldown'
|
|
51
|
+
|
|
52
|
+
import { TopNavBarContext } from '../TopNavBarContext'
|
|
53
|
+
|
|
54
|
+
import generateStyle from './styles'
|
|
55
|
+
import generateComponentTheme from './theme'
|
|
56
|
+
|
|
57
|
+
import {
|
|
58
|
+
propTypes,
|
|
59
|
+
allowedProps,
|
|
60
|
+
TopNavBarActionItemsStyleProps
|
|
61
|
+
} from './props'
|
|
62
|
+
import type {
|
|
63
|
+
TopNavBarActionItemsProps,
|
|
64
|
+
TopNavBarActionItemsState
|
|
65
|
+
} from './props'
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
---
|
|
69
|
+
parent: TopNavBar
|
|
70
|
+
id: TopNavBar.ActionItems
|
|
71
|
+
---
|
|
72
|
+
@module TopNavBarActionItems
|
|
73
|
+
@tsProps
|
|
74
|
+
**/
|
|
75
|
+
@withDeterministicId()
|
|
76
|
+
@withStyle(generateStyle, generateComponentTheme)
|
|
77
|
+
@testable()
|
|
78
|
+
class TopNavBarActionItems extends Component<
|
|
79
|
+
TopNavBarActionItemsProps,
|
|
80
|
+
TopNavBarActionItemsState
|
|
81
|
+
> {
|
|
82
|
+
static readonly componentId = 'TopNavBar.ActionItems'
|
|
83
|
+
|
|
84
|
+
static propTypes = propTypes
|
|
85
|
+
static allowedProps = allowedProps
|
|
86
|
+
static defaultProps = {}
|
|
87
|
+
|
|
88
|
+
declare context: React.ContextType<typeof TopNavBarContext>
|
|
89
|
+
static contextType = TopNavBarContext
|
|
90
|
+
|
|
91
|
+
ref: HTMLUListElement | null = null
|
|
92
|
+
|
|
93
|
+
private readonly _hiddenActionItemsMenuId: string
|
|
94
|
+
private readonly _hiddenActionItemsMenuTriggerId: string
|
|
95
|
+
|
|
96
|
+
handleRef = (el: HTMLUListElement | null) => {
|
|
97
|
+
const { elementRef } = this.props
|
|
98
|
+
|
|
99
|
+
this.ref = el
|
|
100
|
+
|
|
101
|
+
if (typeof elementRef === 'function') {
|
|
102
|
+
elementRef(el)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
constructor(props: TopNavBarActionItemsProps) {
|
|
107
|
+
super(props)
|
|
108
|
+
|
|
109
|
+
this._hiddenActionItemsMenuId = props.deterministicId!(
|
|
110
|
+
'TopNavBarActionItems-hiddenActionItemsMenu'
|
|
111
|
+
)
|
|
112
|
+
this._hiddenActionItemsMenuTriggerId = props.deterministicId!(
|
|
113
|
+
'TopNavBarActionItems-hiddenActionItemsMenuTrigger'
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
this.state = {
|
|
117
|
+
key: 0,
|
|
118
|
+
visibleActionItemsCount: undefined
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
componentDidMount() {
|
|
123
|
+
this.props.makeStyles?.(this.makeStylesVariables)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
componentDidUpdate(prevProps: TopNavBarActionItemsProps) {
|
|
127
|
+
this.props.makeStyles?.(this.makeStylesVariables)
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
this.context.layout === 'smallViewport' &&
|
|
131
|
+
React.Children.count(prevProps.children) !==
|
|
132
|
+
React.Children.count(this.props.children)
|
|
133
|
+
) {
|
|
134
|
+
this.setState({ key: this.state.key + 1 })
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get makeStylesVariables(): TopNavBarActionItemsStyleProps {
|
|
139
|
+
return {
|
|
140
|
+
layout: this.context.layout
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get childrenArray() {
|
|
145
|
+
const children = React.Children.toArray(this.props.children) as ItemChild[]
|
|
146
|
+
|
|
147
|
+
return children.map((child) => {
|
|
148
|
+
if (!child?.props) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const { id, renderAvatar, renderIcon, variant } = child.props
|
|
153
|
+
|
|
154
|
+
if (renderAvatar) {
|
|
155
|
+
warn(
|
|
156
|
+
false,
|
|
157
|
+
`Items in <TopNavBar.ActionItems> are not allowed to have avatars, please remove it from item with the id "${id}".`
|
|
158
|
+
)
|
|
159
|
+
return safeCloneElement(child, {
|
|
160
|
+
renderAvatar: undefined,
|
|
161
|
+
variant: 'default'
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (this.context.layout === 'smallViewport' && variant !== 'icon') {
|
|
166
|
+
if (!renderIcon) {
|
|
167
|
+
error(
|
|
168
|
+
false,
|
|
169
|
+
`Items in <TopNavBar.ActionItems> are required to have the \`renderIcon\` prop, because only the icons are displayed due to the lack of space. Please add an icon to the item with the id "${id}".`
|
|
170
|
+
)
|
|
171
|
+
return null
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return safeCloneElement(child, {
|
|
175
|
+
variant: 'icon'
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return child
|
|
180
|
+
}) as ItemChild[]
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
renderOptionContent: RenderOptionContent = (children, itemProps) => {
|
|
184
|
+
const { styles } = this.props
|
|
185
|
+
const { status } = itemProps
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<span
|
|
189
|
+
css={
|
|
190
|
+
status === 'active'
|
|
191
|
+
? styles?.dropdownMenuOptionActive
|
|
192
|
+
: styles?.dropdownMenuOption
|
|
193
|
+
}
|
|
194
|
+
>
|
|
195
|
+
{children}
|
|
196
|
+
</span>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
renderHiddenActionItemsMenu(hiddenItems: ItemChild[]) {
|
|
201
|
+
const {
|
|
202
|
+
renderHiddenItemsMenuTriggerLabel,
|
|
203
|
+
renderHiddenItemsMenuTriggerTooltip
|
|
204
|
+
} = this.props
|
|
205
|
+
|
|
206
|
+
const mappedItems = mapItemsForDrilldown(hiddenItems, {
|
|
207
|
+
renderOptionContent: this.renderOptionContent
|
|
208
|
+
})
|
|
209
|
+
const subPages = renderMappedItemDrilldownSubpages(mappedItems)
|
|
210
|
+
const options = renderMappedItemsAsDrilldownOptions(mappedItems)
|
|
211
|
+
|
|
212
|
+
const label =
|
|
213
|
+
typeof renderHiddenItemsMenuTriggerLabel === 'function'
|
|
214
|
+
? renderHiddenItemsMenuTriggerLabel(hiddenItems.length)
|
|
215
|
+
: renderHiddenItemsMenuTriggerLabel
|
|
216
|
+
const tooltip =
|
|
217
|
+
typeof renderHiddenItemsMenuTriggerTooltip === 'function'
|
|
218
|
+
? renderHiddenItemsMenuTriggerTooltip(hiddenItems.length)
|
|
219
|
+
: renderHiddenItemsMenuTriggerTooltip
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<TopNavBarItem
|
|
223
|
+
id={this._hiddenActionItemsMenuTriggerId}
|
|
224
|
+
renderIcon={IconMoreLine}
|
|
225
|
+
variant="icon"
|
|
226
|
+
tooltip={tooltip}
|
|
227
|
+
showSubmenuChevron={false}
|
|
228
|
+
renderSubmenu={
|
|
229
|
+
<Drilldown rootPageId={this._hiddenActionItemsMenuId}>
|
|
230
|
+
{[
|
|
231
|
+
<Drilldown.Page
|
|
232
|
+
id={this._hiddenActionItemsMenuId}
|
|
233
|
+
key={this._hiddenActionItemsMenuId}
|
|
234
|
+
>
|
|
235
|
+
{options}
|
|
236
|
+
</Drilldown.Page>,
|
|
237
|
+
...subPages
|
|
238
|
+
]}
|
|
239
|
+
</Drilldown>
|
|
240
|
+
}
|
|
241
|
+
>
|
|
242
|
+
{label}
|
|
243
|
+
</TopNavBarItem>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
renderTruncatedActionItemList() {
|
|
248
|
+
const { listLabel, styles } = this.props
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<TruncateList
|
|
252
|
+
{...passthroughProps(omitProps(this.props, allowedProps))}
|
|
253
|
+
key={this.state.key} // rerender if child count changes
|
|
254
|
+
elementRef={this.handleRef}
|
|
255
|
+
css={styles?.topNavBarActionItems}
|
|
256
|
+
visibleItemsCount={this.state.visibleActionItemsCount}
|
|
257
|
+
onUpdate={({ visibleItemsCount }) => {
|
|
258
|
+
this.setState({ visibleActionItemsCount: visibleItemsCount })
|
|
259
|
+
}}
|
|
260
|
+
renderHiddenItemMenu={(hiddenChildren) =>
|
|
261
|
+
this.renderHiddenActionItemsMenu(hiddenChildren as ItemChild[])
|
|
262
|
+
}
|
|
263
|
+
aria-label={listLabel}
|
|
264
|
+
>
|
|
265
|
+
{this.childrenArray}
|
|
266
|
+
</TruncateList>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
render() {
|
|
271
|
+
const { listLabel, styles } = this.props
|
|
272
|
+
|
|
273
|
+
if (!this.childrenArray.length) {
|
|
274
|
+
return null
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (this.context.layout === 'smallViewport') {
|
|
278
|
+
return this.renderTruncatedActionItemList()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<ul
|
|
283
|
+
{...omitProps(this.props, allowedProps)}
|
|
284
|
+
ref={this.handleRef}
|
|
285
|
+
css={styles?.topNavBarActionItems}
|
|
286
|
+
aria-label={listLabel}
|
|
287
|
+
>
|
|
288
|
+
{this.childrenArray.map((item) => (
|
|
289
|
+
<li css={styles?.listItem} key={item.props.id}>
|
|
290
|
+
{item}
|
|
291
|
+
</li>
|
|
292
|
+
))}
|
|
293
|
+
</ul>
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export { TopNavBarActionItems }
|
|
299
|
+
export default TopNavBarActionItems
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
30
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
31
|
+
import type {
|
|
32
|
+
TopNavBarActionItemsTheme,
|
|
33
|
+
OtherHTMLAttributes,
|
|
34
|
+
PropValidators,
|
|
35
|
+
ChildrenOfType
|
|
36
|
+
} from '@instructure/shared-types'
|
|
37
|
+
|
|
38
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
39
|
+
import { topNavBarItemTooltipPropType } from '../TopNavBarItem/props'
|
|
40
|
+
import type {
|
|
41
|
+
ItemChild,
|
|
42
|
+
TopNavBarItemTooltipType
|
|
43
|
+
} from '../TopNavBarItem/props'
|
|
44
|
+
import type { TopNavBarContextType } from '../TopNavBarContext'
|
|
45
|
+
|
|
46
|
+
import { TopNavBarActionItems } from './index'
|
|
47
|
+
|
|
48
|
+
type ActionItemsChild = React.ComponentElement<
|
|
49
|
+
TopNavBarActionItemsProps,
|
|
50
|
+
TopNavBarActionItems
|
|
51
|
+
>
|
|
52
|
+
|
|
53
|
+
type TopNavBarActionItemsOwnProps = {
|
|
54
|
+
/**
|
|
55
|
+
* Children of type: `<TopNavBar.Item>`.
|
|
56
|
+
*
|
|
57
|
+
* Items in small viewport mode are __required__ to have the `renderIcon` prop,
|
|
58
|
+
* because only the icons are displayed due to the lack of space.
|
|
59
|
+
*/
|
|
60
|
+
children?: ChildrenOfType<ItemChild>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* An 'aria-label' for the action items list.
|
|
64
|
+
*/
|
|
65
|
+
listLabel?: string
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* In __smallViewport__ mode, a __required__ label for the trigger item
|
|
69
|
+
* of the hidden list items menu, used as an accessible screen reader label.
|
|
70
|
+
* (The list is not truncated in __desktop__ mode.)
|
|
71
|
+
*
|
|
72
|
+
* When there is not enough room to list all the action items,
|
|
73
|
+
* they will be accessible via a dropdown menu at the end of the list.
|
|
74
|
+
*/
|
|
75
|
+
renderHiddenItemsMenuTriggerLabel:
|
|
76
|
+
| string
|
|
77
|
+
| ((hiddenChildrenCount: number) => string)
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* In __smallViewport__ mode, an optional tooltip for the trigger item
|
|
81
|
+
* of the hidden list items menu.
|
|
82
|
+
* (The list is not truncated in __desktop__ mode.)
|
|
83
|
+
*
|
|
84
|
+
* When there is not enough room to list all the action items,
|
|
85
|
+
* they will be accessible via a dropdown menu at the end of the list.
|
|
86
|
+
*/
|
|
87
|
+
renderHiddenItemsMenuTriggerTooltip?:
|
|
88
|
+
| TopNavBarItemTooltipType
|
|
89
|
+
| ((hiddenChildrenCount: number) => TopNavBarItemTooltipType)
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A function that returns a reference to root HTML element
|
|
93
|
+
*/
|
|
94
|
+
elementRef?: (el: HTMLUListElement | null) => void
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type PropKeys = keyof TopNavBarActionItemsOwnProps
|
|
98
|
+
|
|
99
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
100
|
+
|
|
101
|
+
type TopNavBarActionItemsProps = TopNavBarActionItemsOwnProps &
|
|
102
|
+
WithStyleProps<TopNavBarActionItemsTheme, TopNavBarActionItemsStyle> &
|
|
103
|
+
OtherHTMLAttributes<TopNavBarActionItemsOwnProps> &
|
|
104
|
+
WithDeterministicIdProps
|
|
105
|
+
|
|
106
|
+
type TopNavBarActionItemsStyle = ComponentStyle<
|
|
107
|
+
| 'topNavBarActionItems'
|
|
108
|
+
| 'listItem'
|
|
109
|
+
| 'dropdownMenuOption'
|
|
110
|
+
| 'dropdownMenuOptionActive'
|
|
111
|
+
>
|
|
112
|
+
|
|
113
|
+
type TopNavBarActionItemsState = {
|
|
114
|
+
key: number
|
|
115
|
+
visibleActionItemsCount?: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type TopNavBarActionItemsStyleProps = {
|
|
119
|
+
layout?: TopNavBarContextType['layout']
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
123
|
+
children: ChildrenPropTypes.oneOf([TopNavBarItem]),
|
|
124
|
+
listLabel: PropTypes.string,
|
|
125
|
+
renderHiddenItemsMenuTriggerLabel: PropTypes.oneOfType([
|
|
126
|
+
PropTypes.string,
|
|
127
|
+
PropTypes.func
|
|
128
|
+
]).isRequired,
|
|
129
|
+
renderHiddenItemsMenuTriggerTooltip: PropTypes.oneOfType([
|
|
130
|
+
topNavBarItemTooltipPropType,
|
|
131
|
+
PropTypes.func
|
|
132
|
+
]),
|
|
133
|
+
elementRef: PropTypes.func
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const allowedProps: AllowedPropKeys = [
|
|
137
|
+
'children',
|
|
138
|
+
'listLabel',
|
|
139
|
+
'renderHiddenItemsMenuTriggerLabel',
|
|
140
|
+
'renderHiddenItemsMenuTriggerTooltip',
|
|
141
|
+
'elementRef'
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
export type {
|
|
145
|
+
ActionItemsChild,
|
|
146
|
+
TopNavBarActionItemsProps,
|
|
147
|
+
TopNavBarActionItemsOwnProps,
|
|
148
|
+
TopNavBarActionItemsState,
|
|
149
|
+
TopNavBarActionItemsStyleProps,
|
|
150
|
+
TopNavBarActionItemsStyle
|
|
151
|
+
}
|
|
152
|
+
export { propTypes, allowedProps }
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { TopNavBarActionItemsTheme } from '@instructure/shared-types'
|
|
26
|
+
import type {
|
|
27
|
+
TopNavBarActionItemsProps,
|
|
28
|
+
TopNavBarActionItemsStyleProps,
|
|
29
|
+
TopNavBarActionItemsStyle
|
|
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: TopNavBarActionItemsTheme,
|
|
44
|
+
_props: TopNavBarActionItemsProps,
|
|
45
|
+
state: TopNavBarActionItemsStyleProps
|
|
46
|
+
): TopNavBarActionItemsStyle => {
|
|
47
|
+
const dropdownMenuOptionStyle = {
|
|
48
|
+
display: 'inline-block',
|
|
49
|
+
padding: `0 ${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorSpacing}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
topNavBarActionItems: {
|
|
54
|
+
label: 'topNavBarActionItems',
|
|
55
|
+
boxSizing: 'border-box',
|
|
56
|
+
listStyleType: 'none',
|
|
57
|
+
margin: '0',
|
|
58
|
+
padding: '0',
|
|
59
|
+
flex: '0 0',
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
alignItems: 'stretch',
|
|
63
|
+
justifyContent: 'flex-end',
|
|
64
|
+
|
|
65
|
+
...(state.layout === 'smallViewport' && {
|
|
66
|
+
flex: '1 1',
|
|
67
|
+
marginInlineStart:
|
|
68
|
+
componentTheme.smallViewportActionItemContainerMargin,
|
|
69
|
+
maxWidth: componentTheme.smallViewportActionItemContainerMaxWidth
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
listItem: {
|
|
73
|
+
label: 'topNavBarActionItems__listItem',
|
|
74
|
+
flex: '0 0'
|
|
75
|
+
},
|
|
76
|
+
dropdownMenuOption: {
|
|
77
|
+
label: 'topNavBarActionItems__dropdownMenuOption',
|
|
78
|
+
...dropdownMenuOptionStyle
|
|
79
|
+
},
|
|
80
|
+
dropdownMenuOptionActive: {
|
|
81
|
+
label: 'topNavBarActionItems__dropdownMenuOptionActive',
|
|
82
|
+
...dropdownMenuOptionStyle,
|
|
83
|
+
fontWeight:
|
|
84
|
+
componentTheme.smallViewportDropdownMenuActiveOptionFontWeight,
|
|
85
|
+
paddingBlockEnd:
|
|
86
|
+
componentTheme.smallViewportDropdownMenuActiveOptionIndicatorSpacing,
|
|
87
|
+
borderBottom: `${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorWidth} solid ${componentTheme.smallViewportDropdownMenuActiveOptionIndicatorColor}`
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
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 { TopNavBarActionItemsTheme } 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): TopNavBarActionItemsTheme => {
|
|
34
|
+
const { typography, spacing, borders } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: TopNavBarActionItemsTheme = {
|
|
37
|
+
smallViewportActionItemContainerMargin: spacing?.xxLarge,
|
|
38
|
+
smallViewportActionItemContainerMaxWidth: '50%',
|
|
39
|
+
|
|
40
|
+
smallViewportDropdownMenuActiveOptionFontWeight: typography?.fontWeightBold,
|
|
41
|
+
smallViewportDropdownMenuActiveOptionIndicatorSpacing: '0.25rem',
|
|
42
|
+
smallViewportDropdownMenuActiveOptionIndicatorWidth: borders?.widthMedium,
|
|
43
|
+
smallViewportDropdownMenuActiveOptionIndicatorColor: 'currentColor'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...componentVariables
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
|
|
28
|
+
import { TopNavBarBrand } from './index'
|
|
29
|
+
|
|
30
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
31
|
+
export const TopNavBarBrandLocator = locator(TopNavBarBrand.selector, {
|
|
32
|
+
findContainer: (...args: any[]) => {
|
|
33
|
+
return find('[class$="-topNavBarBrand__container"]', ...args)
|
|
34
|
+
},
|
|
35
|
+
findBrandNameContainer: (...args: any[]) => {
|
|
36
|
+
return find('[class$="-topNavBarBrand__nameContainer"]', ...args)
|
|
37
|
+
},
|
|
38
|
+
findBrandIconContainer: (...args: any[]) => {
|
|
39
|
+
return find('[class$="-topNavBarBrand__iconContainer"]', ...args)
|
|
40
|
+
},
|
|
41
|
+
findScreenReaderLabel: (...args: any[]) => {
|
|
42
|
+
return find('[class$="-screenReaderContent"]', ...args)
|
|
43
|
+
}
|
|
44
|
+
})
|