@instructure/ui-global-nav 11.7.11-snapshot-33 → 11.7.11-snapshot-35
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 +2 -1
- package/es/GlobalNav/v1/CollapseButton/index.js +24 -20
- package/es/GlobalNav/v1/CollapseButton/styles.js +46 -10
- package/es/GlobalNav/v1/InstitutionLogo/index.js +2 -4
- package/es/GlobalNav/v1/InstitutionLogo/styles.js +7 -0
- package/es/GlobalNav/v1/MainNavItem/styles.js +2 -7
- package/es/GlobalNav/v1/SubNavItem/styles.js +3 -8
- package/es/GlobalNav/v1/utils/calcBandFocusStyles.js +66 -0
- package/lib/GlobalNav/v1/CollapseButton/index.js +22 -18
- package/lib/GlobalNav/v1/CollapseButton/styles.js +48 -11
- package/lib/GlobalNav/v1/InstitutionLogo/index.js +2 -4
- package/lib/GlobalNav/v1/InstitutionLogo/styles.js +7 -0
- package/lib/GlobalNav/v1/MainNavItem/styles.js +2 -7
- package/lib/GlobalNav/v1/SubNavItem/styles.js +3 -8
- package/lib/GlobalNav/v1/utils/calcBandFocusStyles.js +72 -0
- package/package.json +15 -15
- package/src/GlobalNav/v1/CollapseButton/index.tsx +27 -26
- package/src/GlobalNav/v1/CollapseButton/props.ts +6 -7
- package/src/GlobalNav/v1/CollapseButton/styles.ts +53 -12
- package/src/GlobalNav/v1/InstitutionLogo/index.tsx +1 -6
- package/src/GlobalNav/v1/InstitutionLogo/props.ts +1 -1
- package/src/GlobalNav/v1/InstitutionLogo/styles.ts +7 -0
- package/src/GlobalNav/v1/MainNavItem/styles.ts +10 -9
- package/src/GlobalNav/v1/SubNavItem/styles.ts +5 -8
- package/src/GlobalNav/v1/utils/calcBandFocusStyles.ts +67 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/GlobalNav/v1/CollapseButton/index.d.ts.map +1 -1
- package/types/GlobalNav/v1/CollapseButton/props.d.ts +4 -6
- package/types/GlobalNav/v1/CollapseButton/props.d.ts.map +1 -1
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts +8 -4
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts.map +1 -1
- package/types/GlobalNav/v1/InstitutionLogo/index.d.ts.map +1 -1
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts +1 -1
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts.map +1 -1
- package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts.map +1 -1
- package/types/GlobalNav/v1/MainNavItem/styles.d.ts.map +1 -1
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts.map +1 -1
- package/types/GlobalNav/v1/utils/calcBandFocusStyles.d.ts +40 -0
- package/types/GlobalNav/v1/utils/calcBandFocusStyles.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.7.11-snapshot-
|
|
6
|
+
## [11.7.11-snapshot-35](https://github.com/instructure/instructure-ui/compare/v11.7.10...v11.7.11-snapshot-35) (2026-11-30)
|
|
7
7
|
|
|
8
8
|
### Features
|
|
9
9
|
|
|
10
10
|
* **ui-global-nav:** add GlobalNav package scaffolding ([#2759](https://github.com/instructure/instructure-ui/issues/2759)) ([0441b0d](https://github.com/instructure/instructure-ui/commit/0441b0d8278614206289f20d9c771bc282e68352))
|
|
11
11
|
* **ui-global-nav:** add the GlobalNav API types, the collapsible rail, its items and the logo ([#2768](https://github.com/instructure/instructure-ui/issues/2768)) ([5cca5e2](https://github.com/instructure/instructure-ui/commit/5cca5e2e80b4c8a66d7aff309f76535cf596c3d2))
|
|
12
12
|
* **ui-global-nav:** add the SubNav panel ([#2775](https://github.com/instructure/instructure-ui/issues/2775)) ([9c5d56e](https://github.com/instructure/instructure-ui/commit/9c5d56eadc27abd333d475ffdb40494f6c46ec40))
|
|
13
|
+
* **ui-global-nav:** use the design tokens v2.7.0 ([#2820](https://github.com/instructure/instructure-ui/issues/2820)) ([04ed5ea](https://github.com/instructure/instructure-ui/commit/04ed5ea0a520986517f60b8c968c08d8d40bd5d4)), closes [#2786](https://github.com/instructure/instructure-ui/issues/2786) [#2819](https://github.com/instructure/instructure-ui/issues/2819)
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { useStyleNew } from '@instructure/emotion';
|
|
26
|
-
import {
|
|
26
|
+
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
27
27
|
import { PanelRightCloseInstUIIcon, PanelRightOpenInstUIIcon } from '@instructure/ui-icons';
|
|
28
|
-
import generateStyle, {
|
|
28
|
+
import generateStyle, { generateMainNavItemStyle, generateSizeStyle } from './styles.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
---
|
|
@@ -33,7 +33,7 @@ private: true
|
|
|
33
33
|
id: GlobalNav.CollapseButton
|
|
34
34
|
---
|
|
35
35
|
**/
|
|
36
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
36
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
37
37
|
const CollapseButton = props => {
|
|
38
38
|
const {
|
|
39
39
|
collapsed,
|
|
@@ -50,29 +50,33 @@ const CollapseButton = props => {
|
|
|
50
50
|
componentId: 'CollapseButton'
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
// MainNavItem
|
|
54
|
-
const
|
|
55
|
-
generateStyle:
|
|
53
|
+
// MainNavItem and BaseButton are separate token sets, and useStyleNew reads one set per call
|
|
54
|
+
const mainNavItemStyles = useStyleNew({
|
|
55
|
+
generateStyle: generateMainNavItemStyle,
|
|
56
56
|
componentId: 'CollapseButton',
|
|
57
57
|
useTokensFrom: 'MainNavItem'
|
|
58
58
|
});
|
|
59
|
-
const
|
|
59
|
+
const sizeStyles = useStyleNew({
|
|
60
|
+
generateStyle: generateSizeStyle,
|
|
61
|
+
componentId: 'CollapseButton',
|
|
62
|
+
useTokensFrom: 'BaseButton'
|
|
63
|
+
});
|
|
64
|
+
const Icon = collapsed ? PanelRightCloseInstUIIcon : PanelRightOpenInstUIIcon;
|
|
60
65
|
return _jsx("div", {
|
|
61
66
|
css: styles?.collapseButton,
|
|
62
|
-
children:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
withBorder: false,
|
|
67
|
-
size: "small",
|
|
68
|
-
elementRef: elementRef
|
|
69
|
-
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
70
|
-
,
|
|
67
|
+
children: _jsxs("button", {
|
|
68
|
+
type: "button",
|
|
69
|
+
ref: elementRef,
|
|
70
|
+
css: [styles?.button, sizeStyles?.button, mainNavItemStyles?.button],
|
|
71
71
|
onClick: event => onCollapse(event, !collapsed),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
children: [_jsx("span", {
|
|
73
|
+
css: mainNavItemStyles?.icon,
|
|
74
|
+
children: _jsx(Icon, {
|
|
75
|
+
size: "sm"
|
|
76
|
+
})
|
|
77
|
+
}), _jsx(ScreenReaderContent, {
|
|
78
|
+
children: collapsed ? expandLabel : collapseLabel
|
|
79
|
+
})]
|
|
76
80
|
})
|
|
77
81
|
});
|
|
78
82
|
};
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { calcBandFocusStyles } from '../utils/calcBandFocusStyles.js';
|
|
25
26
|
/**
|
|
26
27
|
* ---
|
|
27
28
|
* private: true
|
|
@@ -41,24 +42,59 @@ const generateStyle = (componentTheme, params) => {
|
|
|
41
42
|
// the collapsed rail centers the button
|
|
42
43
|
marginInlineEnd: collapsed ? 0 : componentTheme.rightMargin
|
|
43
44
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
button: {
|
|
46
|
+
label: 'collapseButton__button',
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
boxSizing: 'border-box',
|
|
51
|
+
margin: 0,
|
|
52
|
+
padding: 0,
|
|
53
|
+
border: 'none',
|
|
54
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
'&:hover': {
|
|
57
|
+
backgroundColor: componentTheme.hoverBackgroundColor
|
|
58
|
+
},
|
|
59
|
+
'&:active': {
|
|
60
|
+
backgroundColor: componentTheme.activeBackgroundColor
|
|
61
|
+
}
|
|
47
62
|
}
|
|
48
63
|
};
|
|
49
64
|
};
|
|
50
65
|
|
|
51
66
|
/**
|
|
52
|
-
* Generates the icon color from the `MainNavItem` tokens
|
|
67
|
+
* Generates the focus ring and the icon color from the `MainNavItem` tokens
|
|
53
68
|
*/
|
|
54
|
-
const
|
|
69
|
+
const generateMainNavItemStyle = componentTheme => {
|
|
55
70
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
button: {
|
|
72
|
+
label: 'collapseButton__button',
|
|
73
|
+
// CollapseButton has no focus color tokens
|
|
74
|
+
...calcBandFocusStyles(componentTheme.outerFocusOutlineColor, componentTheme.innerFocusOutlineColor)
|
|
75
|
+
},
|
|
76
|
+
icon: {
|
|
77
|
+
label: 'collapseButton__icon',
|
|
78
|
+
display: 'flex',
|
|
79
|
+
// CollapseButton has no icon color token
|
|
80
|
+
color: componentTheme.fontColor
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Generates the button size from the `BaseButton` tokens
|
|
87
|
+
*/
|
|
88
|
+
const generateSizeStyle = componentTheme => {
|
|
89
|
+
return {
|
|
90
|
+
button: {
|
|
91
|
+
label: 'collapseButton__button',
|
|
92
|
+
// the size of a small IconButton, CollapseButton has no size tokens
|
|
93
|
+
width: componentTheme.smallHeight,
|
|
94
|
+
height: componentTheme.smallHeight,
|
|
95
|
+
borderRadius: componentTheme.borderRadius
|
|
60
96
|
}
|
|
61
97
|
};
|
|
62
98
|
};
|
|
63
99
|
export default generateStyle;
|
|
64
|
-
export {
|
|
100
|
+
export { generateMainNavItemStyle, generateSizeStyle };
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { useStyleNew } from '@instructure/emotion';
|
|
26
|
-
import { Text } from '@instructure/ui-text/latest';
|
|
27
26
|
import { safeLinkProps } from '@instructure/ui-utils';
|
|
28
27
|
import generateStyle from './styles.js';
|
|
29
28
|
|
|
@@ -63,9 +62,8 @@ const InstitutionLogo = props => {
|
|
|
63
62
|
// the visible name labels the logo when it shows
|
|
64
63
|
,
|
|
65
64
|
alt: showName ? '' : logo.name
|
|
66
|
-
}), showName && _jsx(
|
|
67
|
-
|
|
68
|
-
weight: "bold",
|
|
65
|
+
}), showName && _jsx("span", {
|
|
66
|
+
css: styles?.name,
|
|
69
67
|
children: logo.name
|
|
70
68
|
})]
|
|
71
69
|
});
|
|
@@ -63,6 +63,13 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
63
63
|
height: wordmark ? componentTheme.wordmarkHeight : componentTheme.minimizedHeight,
|
|
64
64
|
objectFit: 'contain',
|
|
65
65
|
flexShrink: 0
|
|
66
|
+
},
|
|
67
|
+
name: {
|
|
68
|
+
label: 'institutionLogo__name',
|
|
69
|
+
fontFamily: componentTheme.fontFamily,
|
|
70
|
+
fontWeight: componentTheme.fontWeight,
|
|
71
|
+
fontSize: componentTheme.fontSize,
|
|
72
|
+
lineHeight: componentTheme.lineHeight
|
|
66
73
|
}
|
|
67
74
|
};
|
|
68
75
|
};
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { calcBandFocusStyles } from '../utils/calcBandFocusStyles.js';
|
|
25
26
|
/**
|
|
26
27
|
* ---
|
|
27
28
|
* private: true
|
|
@@ -73,14 +74,8 @@ const generateStyle = (componentTheme, params) => {
|
|
|
73
74
|
backgroundColor: componentTheme.activeBackgroundColor
|
|
74
75
|
}
|
|
75
76
|
}),
|
|
76
|
-
// the other GlobalNav focus rings animate with calcFocusOutlineStyles,
|
|
77
|
-
// which can't take these tokens, because each theme colors a different ring
|
|
78
|
-
transition: 'box-shadow 0.2s',
|
|
79
77
|
// same focus ring as SideNavBarItem, which has the same focus tokens
|
|
80
|
-
|
|
81
|
-
outline: 'none',
|
|
82
|
-
boxShadow: current ? `inset 0 0 0 0.125rem ${componentTheme.selectedOuterFocusOutlineColor}, inset 0 0 0 0.25rem ${componentTheme.selectedInnerFocusOutlineColor}` : `inset 0 0 0 0.125rem ${componentTheme.outerFocusOutlineColor}, inset 0 0 0 0.25rem ${componentTheme.innerFocusOutlineColor}`
|
|
83
|
-
}
|
|
78
|
+
...(current ? calcBandFocusStyles(componentTheme.selectedOuterFocusOutlineColor, componentTheme.selectedInnerFocusOutlineColor) : calcBandFocusStyles(componentTheme.outerFocusOutlineColor, componentTheme.innerFocusOutlineColor))
|
|
84
79
|
},
|
|
85
80
|
icon: {
|
|
86
81
|
label: 'mainNavItem__icon',
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { calcBandFocusStyles } from '../utils/calcBandFocusStyles.js';
|
|
26
26
|
/**
|
|
27
27
|
* ---
|
|
28
28
|
* private: true
|
|
@@ -58,13 +58,8 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
58
58
|
textAlign: 'start',
|
|
59
59
|
textDecoration: 'none',
|
|
60
60
|
cursor: 'pointer',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// the `inset` token is 0, so the ring would sit outside the item, where the scrolling panel body clips it
|
|
64
|
-
inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
|
|
65
|
-
}, {
|
|
66
|
-
focusPosition: 'inset'
|
|
67
|
-
}),
|
|
61
|
+
// SubNavItem has no focus color tokens, so it gets the shared focus color on the outer band
|
|
62
|
+
...calcBandFocusStyles(sharedTokens.focusOutline.infoColor, 'transparent'),
|
|
68
63
|
'&:hover': {
|
|
69
64
|
// a page-wide a:hover rule is more specific than the base class
|
|
70
65
|
textDecoration: 'none',
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Returns the focus ring of the nav items: a 2px band 1px outside the item and a 2px band 1px
|
|
30
|
+
* inside it. Each theme colors a different band, so calcFocusOutlineStyles, which draws one ring,
|
|
31
|
+
* can't take these tokens.
|
|
32
|
+
*/
|
|
33
|
+
const calcBandFocusStyles = (outerColor, innerColor) => ({
|
|
34
|
+
position: 'relative',
|
|
35
|
+
outlineStyle: 'solid',
|
|
36
|
+
outlineWidth: '0.125rem',
|
|
37
|
+
outlineOffset: '0.0625rem',
|
|
38
|
+
outlineColor: 'transparent',
|
|
39
|
+
transition: 'outline-color 0.2s',
|
|
40
|
+
// forced colors mode draws even a transparent outline, so there the ring only exists on focus
|
|
41
|
+
'@media (forced-colors: active)': {
|
|
42
|
+
outlineStyle: 'none'
|
|
43
|
+
},
|
|
44
|
+
// an element has one outline, so the inner band is a layer with an inset box-shadow
|
|
45
|
+
'&::after': {
|
|
46
|
+
content: '""',
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
inset: '0.0625rem',
|
|
49
|
+
borderRadius: 'inherit',
|
|
50
|
+
boxShadow: 'inset 0 0 0 0.125rem transparent',
|
|
51
|
+
transition: 'box-shadow 0.2s',
|
|
52
|
+
pointerEvents: 'none'
|
|
53
|
+
},
|
|
54
|
+
'&:focus': {
|
|
55
|
+
outlineColor: outerColor,
|
|
56
|
+
'&::after': {
|
|
57
|
+
boxShadow: `inset 0 0 0 0.125rem ${innerColor}`
|
|
58
|
+
},
|
|
59
|
+
// forced colors mode drops the inner band's box-shadow, so the outline is the whole ring there
|
|
60
|
+
'@media (forced-colors: active)': {
|
|
61
|
+
outlineStyle: 'solid'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
export default calcBandFocusStyles;
|
|
66
|
+
export { calcBandFocusStyles };
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.CollapseButton = void 0;
|
|
8
8
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
var
|
|
9
|
+
var _uiA11yContent = require("@instructure/ui-a11y-content");
|
|
10
10
|
var _uiIcons = require("@instructure/ui-icons");
|
|
11
11
|
var _styles = _interopRequireWildcard(require("./styles.js"));
|
|
12
12
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
@@ -55,29 +55,33 @@ id: GlobalNav.CollapseButton
|
|
|
55
55
|
componentId: 'CollapseButton'
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
// MainNavItem
|
|
59
|
-
const
|
|
60
|
-
generateStyle: _styles.
|
|
58
|
+
// MainNavItem and BaseButton are separate token sets, and useStyleNew reads one set per call
|
|
59
|
+
const mainNavItemStyles = (0, _emotion.useStyleNew)({
|
|
60
|
+
generateStyle: _styles.generateMainNavItemStyle,
|
|
61
61
|
componentId: 'CollapseButton',
|
|
62
62
|
useTokensFrom: 'MainNavItem'
|
|
63
63
|
});
|
|
64
|
-
const
|
|
64
|
+
const sizeStyles = (0, _emotion.useStyleNew)({
|
|
65
|
+
generateStyle: _styles.generateSizeStyle,
|
|
66
|
+
componentId: 'CollapseButton',
|
|
67
|
+
useTokensFrom: 'BaseButton'
|
|
68
|
+
});
|
|
69
|
+
const Icon = collapsed ? _uiIcons.PanelRightCloseInstUIIcon : _uiIcons.PanelRightOpenInstUIIcon;
|
|
65
70
|
return (0, _jsxRuntime.jsx)("div", {
|
|
66
71
|
css: styles?.collapseButton,
|
|
67
|
-
children: (0, _jsxRuntime.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
withBorder: false,
|
|
72
|
-
size: "small",
|
|
73
|
-
elementRef: elementRef
|
|
74
|
-
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
75
|
-
,
|
|
72
|
+
children: (0, _jsxRuntime.jsxs)("button", {
|
|
73
|
+
type: "button",
|
|
74
|
+
ref: elementRef,
|
|
75
|
+
css: [styles?.button, sizeStyles?.button, mainNavItemStyles?.button],
|
|
76
76
|
onClick: event => onCollapse(event, !collapsed),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
78
|
+
css: mainNavItemStyles?.icon,
|
|
79
|
+
children: (0, _jsxRuntime.jsx)(Icon, {
|
|
80
|
+
size: "sm"
|
|
81
|
+
})
|
|
82
|
+
}), (0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
|
|
83
|
+
children: collapsed ? expandLabel : collapseLabel
|
|
84
|
+
})]
|
|
81
85
|
})
|
|
82
86
|
});
|
|
83
87
|
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.generateSizeStyle = exports.generateMainNavItemStyle = exports.default = void 0;
|
|
7
|
+
var _calcBandFocusStyles = require("../utils/calcBandFocusStyles.js");
|
|
7
8
|
/*
|
|
8
9
|
* The MIT License (MIT)
|
|
9
10
|
*
|
|
@@ -47,24 +48,60 @@ const generateStyle = (componentTheme, params) => {
|
|
|
47
48
|
// the collapsed rail centers the button
|
|
48
49
|
marginInlineEnd: collapsed ? 0 : componentTheme.rightMargin
|
|
49
50
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
button: {
|
|
52
|
+
label: 'collapseButton__button',
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
boxSizing: 'border-box',
|
|
57
|
+
margin: 0,
|
|
58
|
+
padding: 0,
|
|
59
|
+
border: 'none',
|
|
60
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
'&:hover': {
|
|
63
|
+
backgroundColor: componentTheme.hoverBackgroundColor
|
|
64
|
+
},
|
|
65
|
+
'&:active': {
|
|
66
|
+
backgroundColor: componentTheme.activeBackgroundColor
|
|
67
|
+
}
|
|
53
68
|
}
|
|
54
69
|
};
|
|
55
70
|
};
|
|
56
71
|
|
|
57
72
|
/**
|
|
58
|
-
* Generates the icon color from the `MainNavItem` tokens
|
|
73
|
+
* Generates the focus ring and the icon color from the `MainNavItem` tokens
|
|
59
74
|
*/
|
|
60
|
-
const
|
|
75
|
+
const generateMainNavItemStyle = componentTheme => {
|
|
61
76
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
button: {
|
|
78
|
+
label: 'collapseButton__button',
|
|
79
|
+
// CollapseButton has no focus color tokens
|
|
80
|
+
...(0, _calcBandFocusStyles.calcBandFocusStyles)(componentTheme.outerFocusOutlineColor, componentTheme.innerFocusOutlineColor)
|
|
81
|
+
},
|
|
82
|
+
icon: {
|
|
83
|
+
label: 'collapseButton__icon',
|
|
84
|
+
display: 'flex',
|
|
85
|
+
// CollapseButton has no icon color token
|
|
86
|
+
color: componentTheme.fontColor
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Generates the button size from the `BaseButton` tokens
|
|
93
|
+
*/
|
|
94
|
+
exports.generateMainNavItemStyle = generateMainNavItemStyle;
|
|
95
|
+
const generateSizeStyle = componentTheme => {
|
|
96
|
+
return {
|
|
97
|
+
button: {
|
|
98
|
+
label: 'collapseButton__button',
|
|
99
|
+
// the size of a small IconButton, CollapseButton has no size tokens
|
|
100
|
+
width: componentTheme.smallHeight,
|
|
101
|
+
height: componentTheme.smallHeight,
|
|
102
|
+
borderRadius: componentTheme.borderRadius
|
|
66
103
|
}
|
|
67
104
|
};
|
|
68
105
|
};
|
|
69
|
-
exports.
|
|
106
|
+
exports.generateSizeStyle = generateSizeStyle;
|
|
70
107
|
var _default = exports.default = generateStyle;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.InstitutionLogo = void 0;
|
|
8
8
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
var _latest = require("@instructure/ui-text/latest");
|
|
10
9
|
var _uiUtils = require("@instructure/ui-utils");
|
|
11
10
|
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
12
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
@@ -68,9 +67,8 @@ id: GlobalNav.InstitutionLogo
|
|
|
68
67
|
// the visible name labels the logo when it shows
|
|
69
68
|
,
|
|
70
69
|
alt: showName ? '' : logo.name
|
|
71
|
-
}), showName && (0, _jsxRuntime.jsx)(
|
|
72
|
-
|
|
73
|
-
weight: "bold",
|
|
70
|
+
}), showName && (0, _jsxRuntime.jsx)("span", {
|
|
71
|
+
css: styles?.name,
|
|
74
72
|
children: logo.name
|
|
75
73
|
})]
|
|
76
74
|
});
|
|
@@ -69,6 +69,13 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
69
69
|
height: wordmark ? componentTheme.wordmarkHeight : componentTheme.minimizedHeight,
|
|
70
70
|
objectFit: 'contain',
|
|
71
71
|
flexShrink: 0
|
|
72
|
+
},
|
|
73
|
+
name: {
|
|
74
|
+
label: 'institutionLogo__name',
|
|
75
|
+
fontFamily: componentTheme.fontFamily,
|
|
76
|
+
fontWeight: componentTheme.fontWeight,
|
|
77
|
+
fontSize: componentTheme.fontSize,
|
|
78
|
+
lineHeight: componentTheme.lineHeight
|
|
72
79
|
}
|
|
73
80
|
};
|
|
74
81
|
};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _calcBandFocusStyles = require("../utils/calcBandFocusStyles.js");
|
|
7
8
|
/*
|
|
8
9
|
* The MIT License (MIT)
|
|
9
10
|
*
|
|
@@ -79,14 +80,8 @@ const generateStyle = (componentTheme, params) => {
|
|
|
79
80
|
backgroundColor: componentTheme.activeBackgroundColor
|
|
80
81
|
}
|
|
81
82
|
}),
|
|
82
|
-
// the other GlobalNav focus rings animate with calcFocusOutlineStyles,
|
|
83
|
-
// which can't take these tokens, because each theme colors a different ring
|
|
84
|
-
transition: 'box-shadow 0.2s',
|
|
85
83
|
// same focus ring as SideNavBarItem, which has the same focus tokens
|
|
86
|
-
|
|
87
|
-
outline: 'none',
|
|
88
|
-
boxShadow: current ? `inset 0 0 0 0.125rem ${componentTheme.selectedOuterFocusOutlineColor}, inset 0 0 0 0.25rem ${componentTheme.selectedInnerFocusOutlineColor}` : `inset 0 0 0 0.125rem ${componentTheme.outerFocusOutlineColor}, inset 0 0 0 0.25rem ${componentTheme.innerFocusOutlineColor}`
|
|
89
|
-
}
|
|
84
|
+
...(current ? (0, _calcBandFocusStyles.calcBandFocusStyles)(componentTheme.selectedOuterFocusOutlineColor, componentTheme.selectedInnerFocusOutlineColor) : (0, _calcBandFocusStyles.calcBandFocusStyles)(componentTheme.outerFocusOutlineColor, componentTheme.innerFocusOutlineColor))
|
|
90
85
|
},
|
|
91
86
|
icon: {
|
|
92
87
|
label: 'mainNavItem__icon',
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _calcBandFocusStyles = require("../utils/calcBandFocusStyles.js");
|
|
8
8
|
/*
|
|
9
9
|
* The MIT License (MIT)
|
|
10
10
|
*
|
|
@@ -64,13 +64,8 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
64
64
|
textAlign: 'start',
|
|
65
65
|
textDecoration: 'none',
|
|
66
66
|
cursor: 'pointer',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// the `inset` token is 0, so the ring would sit outside the item, where the scrolling panel body clips it
|
|
70
|
-
inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
|
|
71
|
-
}, {
|
|
72
|
-
focusPosition: 'inset'
|
|
73
|
-
}),
|
|
67
|
+
// SubNavItem has no focus color tokens, so it gets the shared focus color on the outer band
|
|
68
|
+
...(0, _calcBandFocusStyles.calcBandFocusStyles)(sharedTokens.focusOutline.infoColor, 'transparent'),
|
|
74
69
|
'&:hover': {
|
|
75
70
|
// a page-wide a:hover rule is more specific than the base class
|
|
76
71
|
textDecoration: 'none',
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.calcBandFocusStyles = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Returns the focus ring of the nav items: a 2px band 1px outside the item and a 2px band 1px
|
|
36
|
+
* inside it. Each theme colors a different band, so calcFocusOutlineStyles, which draws one ring,
|
|
37
|
+
* can't take these tokens.
|
|
38
|
+
*/
|
|
39
|
+
const calcBandFocusStyles = (outerColor, innerColor) => ({
|
|
40
|
+
position: 'relative',
|
|
41
|
+
outlineStyle: 'solid',
|
|
42
|
+
outlineWidth: '0.125rem',
|
|
43
|
+
outlineOffset: '0.0625rem',
|
|
44
|
+
outlineColor: 'transparent',
|
|
45
|
+
transition: 'outline-color 0.2s',
|
|
46
|
+
// forced colors mode draws even a transparent outline, so there the ring only exists on focus
|
|
47
|
+
'@media (forced-colors: active)': {
|
|
48
|
+
outlineStyle: 'none'
|
|
49
|
+
},
|
|
50
|
+
// an element has one outline, so the inner band is a layer with an inset box-shadow
|
|
51
|
+
'&::after': {
|
|
52
|
+
content: '""',
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
inset: '0.0625rem',
|
|
55
|
+
borderRadius: 'inherit',
|
|
56
|
+
boxShadow: 'inset 0 0 0 0.125rem transparent',
|
|
57
|
+
transition: 'box-shadow 0.2s',
|
|
58
|
+
pointerEvents: 'none'
|
|
59
|
+
},
|
|
60
|
+
'&:focus': {
|
|
61
|
+
outlineColor: outerColor,
|
|
62
|
+
'&::after': {
|
|
63
|
+
boxShadow: `inset 0 0 0 0.125rem ${innerColor}`
|
|
64
|
+
},
|
|
65
|
+
// forced colors mode drops the inner band's box-shadow, so the outline is the whole ring there
|
|
66
|
+
'@media (forced-colors: active)': {
|
|
67
|
+
outlineStyle: 'solid'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
exports.calcBandFocusStyles = calcBandFocusStyles;
|
|
72
|
+
var _default = exports.default = calcBandFocusStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-global-nav",
|
|
3
|
-
"version": "11.7.11-snapshot-
|
|
3
|
+
"version": "11.7.11-snapshot-35",
|
|
4
4
|
"description": "Main navigation of an app: a rail with items, sub navigation and an account menu.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,22 +15,22 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.29.7",
|
|
18
|
-
"@instructure/emotion": "11.7.11-snapshot-
|
|
19
|
-
"@instructure/shared-types": "11.7.11-snapshot-
|
|
20
|
-
"@instructure/ui-a11y-content": "11.7.11-snapshot-
|
|
21
|
-
"@instructure/ui-badge": "11.7.11-snapshot-
|
|
22
|
-
"@instructure/ui-buttons": "11.7.11-snapshot-
|
|
23
|
-
"@instructure/ui-dom-utils": "11.7.11-snapshot-
|
|
24
|
-
"@instructure/ui-icons": "11.7.11-snapshot-
|
|
25
|
-
"@instructure/ui-react-utils": "11.7.11-snapshot-
|
|
26
|
-
"@instructure/ui-text": "11.7.11-snapshot-
|
|
27
|
-
"@instructure/ui-themes": "11.7.11-snapshot-
|
|
28
|
-
"@instructure/ui-tooltip": "11.7.11-snapshot-
|
|
29
|
-
"@instructure/ui-utils": "11.7.11-snapshot-
|
|
18
|
+
"@instructure/emotion": "11.7.11-snapshot-35",
|
|
19
|
+
"@instructure/shared-types": "11.7.11-snapshot-35",
|
|
20
|
+
"@instructure/ui-a11y-content": "11.7.11-snapshot-35",
|
|
21
|
+
"@instructure/ui-badge": "11.7.11-snapshot-35",
|
|
22
|
+
"@instructure/ui-buttons": "11.7.11-snapshot-35",
|
|
23
|
+
"@instructure/ui-dom-utils": "11.7.11-snapshot-35",
|
|
24
|
+
"@instructure/ui-icons": "11.7.11-snapshot-35",
|
|
25
|
+
"@instructure/ui-react-utils": "11.7.11-snapshot-35",
|
|
26
|
+
"@instructure/ui-text": "11.7.11-snapshot-35",
|
|
27
|
+
"@instructure/ui-themes": "11.7.11-snapshot-35",
|
|
28
|
+
"@instructure/ui-tooltip": "11.7.11-snapshot-35",
|
|
29
|
+
"@instructure/ui-utils": "11.7.11-snapshot-35"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@instructure/ui-axe-check": "11.7.11-snapshot-
|
|
33
|
-
"@instructure/ui-babel-preset": "11.7.11-snapshot-
|
|
32
|
+
"@instructure/ui-axe-check": "11.7.11-snapshot-35",
|
|
33
|
+
"@instructure/ui-babel-preset": "11.7.11-snapshot-35",
|
|
34
34
|
"vitest": "^5.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|