@instructure/ui-global-nav 0.0.0-stage → 11.7.10

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/LICENSE.md +28 -0
  3. package/README.md +25 -2
  4. package/es/GlobalNav/v1/CollapseButton/index.js +80 -0
  5. package/es/GlobalNav/v1/CollapseButton/props.js +1 -0
  6. package/es/GlobalNav/v1/CollapseButton/styles.js +64 -0
  7. package/es/GlobalNav/v1/CollapsedSubNav/index.js +59 -0
  8. package/es/GlobalNav/v1/CollapsedSubNav/props.js +1 -0
  9. package/es/GlobalNav/v1/CollapsedSubNav/styles.js +82 -0
  10. package/es/GlobalNav/v1/InstitutionLogo/index.js +93 -0
  11. package/es/GlobalNav/v1/InstitutionLogo/props.js +1 -0
  12. package/es/GlobalNav/v1/InstitutionLogo/styles.js +69 -0
  13. package/es/GlobalNav/v1/MainNavItem/index.js +129 -0
  14. package/es/GlobalNav/v1/MainNavItem/props.js +1 -0
  15. package/es/GlobalNav/v1/MainNavItem/styles.js +117 -0
  16. package/es/GlobalNav/v1/SubNav/index.js +121 -0
  17. package/es/GlobalNav/v1/SubNav/props.js +1 -0
  18. package/es/GlobalNav/v1/SubNav/styles.js +52 -0
  19. package/es/GlobalNav/v1/SubNavItem/index.js +78 -0
  20. package/es/GlobalNav/v1/SubNavItem/props.js +1 -0
  21. package/es/GlobalNav/v1/SubNavItem/styles.js +94 -0
  22. package/es/GlobalNav/v1/SubNavLevel/index.js +160 -0
  23. package/es/GlobalNav/v1/SubNavLevel/props.js +1 -0
  24. package/es/GlobalNav/v1/SubNavLevel/styles.js +94 -0
  25. package/es/GlobalNav/v1/index.js +222 -0
  26. package/es/GlobalNav/v1/props.js +28 -0
  27. package/es/GlobalNav/v1/styles.js +110 -0
  28. package/es/GlobalNav/v1/utils/getItemElementProps.js +64 -0
  29. package/es/exports/a.js +24 -0
  30. package/lib/GlobalNav/v1/CollapseButton/index.js +85 -0
  31. package/lib/GlobalNav/v1/CollapseButton/props.js +5 -0
  32. package/lib/GlobalNav/v1/CollapseButton/styles.js +70 -0
  33. package/lib/GlobalNav/v1/CollapsedSubNav/index.js +64 -0
  34. package/lib/GlobalNav/v1/CollapsedSubNav/props.js +5 -0
  35. package/lib/GlobalNav/v1/CollapsedSubNav/styles.js +88 -0
  36. package/lib/GlobalNav/v1/InstitutionLogo/index.js +98 -0
  37. package/lib/GlobalNav/v1/InstitutionLogo/props.js +5 -0
  38. package/lib/GlobalNav/v1/InstitutionLogo/styles.js +75 -0
  39. package/lib/GlobalNav/v1/MainNavItem/index.js +134 -0
  40. package/lib/GlobalNav/v1/MainNavItem/props.js +5 -0
  41. package/lib/GlobalNav/v1/MainNavItem/styles.js +123 -0
  42. package/lib/GlobalNav/v1/SubNav/index.js +128 -0
  43. package/lib/GlobalNav/v1/SubNav/props.js +5 -0
  44. package/lib/GlobalNav/v1/SubNav/styles.js +58 -0
  45. package/lib/GlobalNav/v1/SubNavItem/index.js +83 -0
  46. package/lib/GlobalNav/v1/SubNavItem/props.js +5 -0
  47. package/lib/GlobalNav/v1/SubNavItem/styles.js +100 -0
  48. package/lib/GlobalNav/v1/SubNavLevel/index.js +165 -0
  49. package/lib/GlobalNav/v1/SubNavLevel/props.js +5 -0
  50. package/lib/GlobalNav/v1/SubNavLevel/styles.js +100 -0
  51. package/lib/GlobalNav/v1/index.js +228 -0
  52. package/lib/GlobalNav/v1/props.js +33 -0
  53. package/lib/GlobalNav/v1/styles.js +116 -0
  54. package/lib/GlobalNav/v1/utils/getItemElementProps.js +70 -0
  55. package/lib/exports/a.js +12 -0
  56. package/lib/package.json +1 -0
  57. package/package.json +77 -3
  58. package/src/GlobalNav/v1/CollapseButton/index.tsx +87 -0
  59. package/src/GlobalNav/v1/CollapseButton/props.ts +64 -0
  60. package/src/GlobalNav/v1/CollapseButton/styles.ts +76 -0
  61. package/src/GlobalNav/v1/CollapsedSubNav/index.tsx +60 -0
  62. package/src/GlobalNav/v1/CollapsedSubNav/props.ts +42 -0
  63. package/src/GlobalNav/v1/CollapsedSubNav/styles.ts +92 -0
  64. package/src/GlobalNav/v1/InstitutionLogo/index.tsx +86 -0
  65. package/src/GlobalNav/v1/InstitutionLogo/props.ts +42 -0
  66. package/src/GlobalNav/v1/InstitutionLogo/styles.ts +82 -0
  67. package/src/GlobalNav/v1/MainNavItem/index.tsx +132 -0
  68. package/src/GlobalNav/v1/MainNavItem/props.ts +65 -0
  69. package/src/GlobalNav/v1/MainNavItem/styles.ts +137 -0
  70. package/src/GlobalNav/v1/README.md +234 -0
  71. package/src/GlobalNav/v1/SubNav/index.tsx +132 -0
  72. package/src/GlobalNav/v1/SubNav/props.ts +81 -0
  73. package/src/GlobalNav/v1/SubNav/styles.ts +58 -0
  74. package/src/GlobalNav/v1/SubNavItem/index.tsx +79 -0
  75. package/src/GlobalNav/v1/SubNavItem/props.ts +48 -0
  76. package/src/GlobalNav/v1/SubNavItem/styles.ts +110 -0
  77. package/src/GlobalNav/v1/SubNavLevel/index.tsx +193 -0
  78. package/src/GlobalNav/v1/SubNavLevel/props.ts +75 -0
  79. package/src/GlobalNav/v1/SubNavLevel/styles.ts +103 -0
  80. package/src/GlobalNav/v1/index.tsx +256 -0
  81. package/src/GlobalNav/v1/props.ts +328 -0
  82. package/src/GlobalNav/v1/styles.ts +132 -0
  83. package/src/GlobalNav/v1/utils/getItemElementProps.ts +80 -0
  84. package/src/exports/a.ts +35 -0
  85. package/tsconfig.build.json +53 -0
  86. package/tsconfig.build.tsbuildinfo +1 -0
  87. package/tsconfig.json +4 -0
  88. package/types/GlobalNav/v1/CollapseButton/index.d.ts +11 -0
  89. package/types/GlobalNav/v1/CollapseButton/index.d.ts.map +1 -0
  90. package/types/GlobalNav/v1/CollapseButton/props.d.ts +31 -0
  91. package/types/GlobalNav/v1/CollapseButton/props.d.ts.map +1 -0
  92. package/types/GlobalNav/v1/CollapseButton/styles.d.ts +22 -0
  93. package/types/GlobalNav/v1/CollapseButton/styles.d.ts.map +1 -0
  94. package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts +11 -0
  95. package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts.map +1 -0
  96. package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts +15 -0
  97. package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts.map +1 -0
  98. package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts +14 -0
  99. package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts.map +1 -0
  100. package/types/GlobalNav/v1/InstitutionLogo/index.d.ts +11 -0
  101. package/types/GlobalNav/v1/InstitutionLogo/index.d.ts.map +1 -0
  102. package/types/GlobalNav/v1/InstitutionLogo/props.d.ts +15 -0
  103. package/types/GlobalNav/v1/InstitutionLogo/props.d.ts.map +1 -0
  104. package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts +20 -0
  105. package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts.map +1 -0
  106. package/types/GlobalNav/v1/MainNavItem/index.d.ts +11 -0
  107. package/types/GlobalNav/v1/MainNavItem/index.d.ts.map +1 -0
  108. package/types/GlobalNav/v1/MainNavItem/props.d.ts +32 -0
  109. package/types/GlobalNav/v1/MainNavItem/props.d.ts.map +1 -0
  110. package/types/GlobalNav/v1/MainNavItem/styles.d.ts +19 -0
  111. package/types/GlobalNav/v1/MainNavItem/styles.d.ts.map +1 -0
  112. package/types/GlobalNav/v1/SubNav/index.d.ts +11 -0
  113. package/types/GlobalNav/v1/SubNav/index.d.ts.map +1 -0
  114. package/types/GlobalNav/v1/SubNav/props.d.ts +52 -0
  115. package/types/GlobalNav/v1/SubNav/props.d.ts.map +1 -0
  116. package/types/GlobalNav/v1/SubNav/styles.d.ts +13 -0
  117. package/types/GlobalNav/v1/SubNav/styles.d.ts.map +1 -0
  118. package/types/GlobalNav/v1/SubNavItem/index.d.ts +11 -0
  119. package/types/GlobalNav/v1/SubNavItem/index.d.ts.map +1 -0
  120. package/types/GlobalNav/v1/SubNavItem/props.d.ts +20 -0
  121. package/types/GlobalNav/v1/SubNavItem/props.d.ts.map +1 -0
  122. package/types/GlobalNav/v1/SubNavItem/styles.d.ts +18 -0
  123. package/types/GlobalNav/v1/SubNavItem/styles.d.ts.map +1 -0
  124. package/types/GlobalNav/v1/SubNavLevel/index.d.ts +11 -0
  125. package/types/GlobalNav/v1/SubNavLevel/index.d.ts.map +1 -0
  126. package/types/GlobalNav/v1/SubNavLevel/props.d.ts +45 -0
  127. package/types/GlobalNav/v1/SubNavLevel/props.d.ts.map +1 -0
  128. package/types/GlobalNav/v1/SubNavLevel/styles.d.ts +14 -0
  129. package/types/GlobalNav/v1/SubNavLevel/styles.d.ts.map +1 -0
  130. package/types/GlobalNav/v1/index.d.ts +59 -0
  131. package/types/GlobalNav/v1/index.d.ts.map +1 -0
  132. package/types/GlobalNav/v1/props.d.ts +247 -0
  133. package/types/GlobalNav/v1/props.d.ts.map +1 -0
  134. package/types/GlobalNav/v1/styles.d.ts +23 -0
  135. package/types/GlobalNav/v1/styles.d.ts.map +1 -0
  136. package/types/GlobalNav/v1/utils/getItemElementProps.d.ts +37 -0
  137. package/types/GlobalNav/v1/utils/getItemElementProps.d.ts.map +1 -0
  138. package/types/exports/a.d.ts +3 -0
  139. package/types/exports/a.d.ts.map +1 -0
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateIconStyle = exports.default = 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
+ * Generates the style object from the theme and provided additional information
36
+ * @param componentTheme The theme variable object.
37
+ * @param params Additional parameters to customize the style.
38
+ * @return The final style object, which will be used in the component
39
+ */
40
+ const generateStyle = (componentTheme, params) => {
41
+ const {
42
+ collapsed
43
+ } = params;
44
+ return {
45
+ collapseButton: {
46
+ label: 'collapseButton',
47
+ // the collapsed rail centers the button
48
+ marginInlineEnd: collapsed ? 0 : componentTheme.rightMargin
49
+ },
50
+ iconButtonThemeOverride: {
51
+ secondaryGhostHoverBackground: componentTheme.hoverBackgroundColor,
52
+ secondaryGhostActiveBackground: componentTheme.activeBackgroundColor
53
+ }
54
+ };
55
+ };
56
+
57
+ /**
58
+ * Generates the icon color from the `MainNavItem` tokens
59
+ */
60
+ const generateIconStyle = componentTheme => {
61
+ return {
62
+ // the default IconButton icon is unreadable on the dark legacy rail, and the
63
+ // CollapseButton tokens have no icon color
64
+ iconButtonThemeOverride: {
65
+ secondaryGhostColor: componentTheme.fontColor
66
+ }
67
+ };
68
+ };
69
+ exports.generateIconStyle = generateIconStyle;
70
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.CollapsedSubNav = void 0;
8
+ var _emotion = require("@instructure/emotion");
9
+ var _uiIcons = require("@instructure/ui-icons");
10
+ var _styles = _interopRequireDefault(require("./styles.js"));
11
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ /*
13
+ * The MIT License (MIT)
14
+ *
15
+ * Copyright (c) 2015 - present Instructure, Inc.
16
+ *
17
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ * of this software and associated documentation files (the "Software"), to deal
19
+ * in the Software without restriction, including without limitation the rights
20
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ * copies of the Software, and to permit persons to whom the Software is
22
+ * furnished to do so, subject to the following conditions:
23
+ *
24
+ * The above copyright notice and this permission notice shall be included in all
25
+ * copies or substantial portions of the Software.
26
+ *
27
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ * SOFTWARE.
34
+ */
35
+
36
+ /**
37
+ ---
38
+ private: true
39
+ id: GlobalNav.CollapsedSubNav
40
+ ---
41
+ **/const CollapsedSubNav = props => {
42
+ const {
43
+ label,
44
+ onExpand
45
+ } = props;
46
+ const styles = (0, _emotion.useStyleNew)({
47
+ generateStyle: _styles.default,
48
+ componentId: 'SubNav'
49
+ });
50
+ return (0, _jsxRuntime.jsx)("button", {
51
+ type: "button",
52
+ "aria-label": label,
53
+ css: styles?.collapsedSubNav,
54
+ onClick: onExpand,
55
+ children: (0, _jsxRuntime.jsx)("span", {
56
+ css: styles?.icon,
57
+ children: (0, _jsxRuntime.jsx)(_uiIcons.PanelLeftOpenInstUIIcon, {
58
+ size: "sm"
59
+ })
60
+ })
61
+ });
62
+ };
63
+ exports.CollapsedSubNav = CollapsedSubNav;
64
+ var _default = exports.default = CollapsedSubNav;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param componentTheme The theme variable object.
38
+ * @param sharedTokens Shared token object that stores common values for the theme.
39
+ * @return The final style object, which will be used in the component
40
+ */
41
+ const generateStyle = (componentTheme, _params, sharedTokens) => {
42
+ // SubNav has no border width token
43
+ const borderWidth = '0.0625rem';
44
+ return {
45
+ collapsedSubNav: {
46
+ label: 'collapsedSubNav',
47
+ width: componentTheme.minimizedWidth,
48
+ flexShrink: 0,
49
+ boxSizing: 'border-box',
50
+ display: 'flex',
51
+ flexDirection: 'column',
52
+ // the strip widens on hover, and the icon moves out with its outer edge
53
+ alignItems: 'flex-end',
54
+ margin: 0,
55
+ padding: 0,
56
+ paddingTop: `var(--globalNav-collapseButtonTop, ${componentTheme.minimizedVerticalPadding})`,
57
+ border: 'none',
58
+ borderInlineStart: `${borderWidth} solid ${componentTheme.borderColor}`,
59
+ // the strip is the end of the rail card, so it takes the card's end corners
60
+ borderStartEndRadius: 'inherit',
61
+ borderEndEndRadius: 'inherit',
62
+ backgroundColor: componentTheme.backgroundColor,
63
+ color: componentTheme.textColor,
64
+ cursor: 'pointer',
65
+ ...(0, _emotion.calcFocusOutlineStyles)({
66
+ ...sharedTokens.focusOutline,
67
+ // an outside ring would cover the main nav divider and the card border
68
+ inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
69
+ }, {
70
+ focusPosition: 'inset'
71
+ }),
72
+ '&:hover': {
73
+ width: componentTheme.minimizedHoverWidth
74
+ }
75
+ },
76
+ icon: {
77
+ label: 'collapsedSubNav__icon',
78
+ display: 'flex',
79
+ alignItems: 'center',
80
+ justifyContent: 'center',
81
+ // the width of the strip at rest, so the icon is centered until the strip widens
82
+ width: `calc(${componentTheme.minimizedWidth} - ${borderWidth})`,
83
+ // the height of the rail's collapse button, so both icons share a center line
84
+ height: 'var(--globalNav-collapseButtonHeight)'
85
+ }
86
+ };
87
+ };
88
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.InstitutionLogo = void 0;
8
+ var _emotion = require("@instructure/emotion");
9
+ var _latest = require("@instructure/ui-text/latest");
10
+ var _uiUtils = require("@instructure/ui-utils");
11
+ var _styles = _interopRequireDefault(require("./styles.js"));
12
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
13
+ /*
14
+ * The MIT License (MIT)
15
+ *
16
+ * Copyright (c) 2015 - present Instructure, Inc.
17
+ *
18
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ * of this software and associated documentation files (the "Software"), to deal
20
+ * in the Software without restriction, including without limitation the rights
21
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ * copies of the Software, and to permit persons to whom the Software is
23
+ * furnished to do so, subject to the following conditions:
24
+ *
25
+ * The above copyright notice and this permission notice shall be included in all
26
+ * copies or substantial portions of the Software.
27
+ *
28
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
+ * SOFTWARE.
35
+ */
36
+
37
+ /**
38
+ ---
39
+ private: true
40
+ id: GlobalNav.InstitutionLogo
41
+ ---
42
+ **/const InstitutionLogo = props => {
43
+ const {
44
+ logo,
45
+ collapsed
46
+ } = props;
47
+ const isLink = !!logo.href;
48
+ const {
49
+ showName: showNameProp = true
50
+ } = logo;
51
+ const showName = !collapsed && showNameProp;
52
+ const styles = (0, _emotion.useStyleNew)({
53
+ generateStyle: _styles.default,
54
+ params: {
55
+ collapsed,
56
+ isLink,
57
+ wordmark: !showNameProp
58
+ },
59
+ componentId: 'MainNavInstitutionLogo'
60
+ });
61
+ if (!logo.src && !showName) {
62
+ return null;
63
+ }
64
+ const content = (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
65
+ children: [logo.src && (0, _jsxRuntime.jsx)("img", {
66
+ css: styles?.mark,
67
+ src: logo.src
68
+ // the visible name labels the logo when it shows
69
+ ,
70
+ alt: showName ? '' : logo.name
71
+ }), showName && (0, _jsxRuntime.jsx)(_latest.Text, {
72
+ color: "inherit",
73
+ weight: "bold",
74
+ children: logo.name
75
+ })]
76
+ });
77
+ if (isLink) {
78
+ // drops unsafe hrefs, for example javascript: URLs that would run code on click
79
+ const {
80
+ href
81
+ } = (0, _uiUtils.safeLinkProps)({
82
+ href: logo.href,
83
+ tag: 'a',
84
+ attr: 'href'
85
+ });
86
+ return (0, _jsxRuntime.jsx)("a", {
87
+ css: styles?.logo,
88
+ href: href,
89
+ children: content
90
+ });
91
+ }
92
+ return (0, _jsxRuntime.jsx)("div", {
93
+ css: styles?.logo,
94
+ children: content
95
+ });
96
+ };
97
+ exports.InstitutionLogo = InstitutionLogo;
98
+ var _default = exports.default = InstitutionLogo;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _emotion = require("@instructure/emotion");
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param componentTheme The theme variable object.
38
+ * @param params Additional parameters to customize the style.
39
+ * @param sharedTokens Shared token object that stores common values for the theme.
40
+ * @return The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, params, sharedTokens) => {
43
+ const {
44
+ collapsed,
45
+ isLink,
46
+ wordmark
47
+ } = params;
48
+ return {
49
+ logo: {
50
+ label: 'institutionLogo',
51
+ display: 'flex',
52
+ alignItems: 'center',
53
+ gap: componentTheme.gap,
54
+ padding: collapsed ? 0 : componentTheme.padding,
55
+ flex: collapsed ? undefined : 1,
56
+ ...(collapsed && {
57
+ width: componentTheme.minimizedWidth,
58
+ height: componentTheme.minimizedHeight,
59
+ justifyContent: 'center'
60
+ }),
61
+ color: componentTheme.textColor,
62
+ textDecoration: 'none',
63
+ ...(isLink && (0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline))
64
+ },
65
+ mark: {
66
+ label: 'institutionLogo__mark',
67
+ // the mark has the collapsed logo size in both rail states
68
+ width: wordmark ? 'auto' : componentTheme.minimizedWidth,
69
+ height: wordmark ? componentTheme.wordmarkHeight : componentTheme.minimizedHeight,
70
+ objectFit: 'contain',
71
+ flexShrink: 0
72
+ }
73
+ };
74
+ };
75
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.MainNavItem = void 0;
8
+ var _emotion = require("@instructure/emotion");
9
+ var _uiA11yContent = require("@instructure/ui-a11y-content");
10
+ var _latest = require("@instructure/ui-badge/latest");
11
+ var _uiIcons = require("@instructure/ui-icons");
12
+ var _uiReactUtils = require("@instructure/ui-react-utils");
13
+ var _latest2 = require("@instructure/ui-tooltip/latest");
14
+ var _getItemElementProps = require("../utils/getItemElementProps.js");
15
+ var _styles = _interopRequireDefault(require("./styles.js"));
16
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
+ /*
18
+ * The MIT License (MIT)
19
+ *
20
+ * Copyright (c) 2015 - present Instructure, Inc.
21
+ *
22
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ * of this software and associated documentation files (the "Software"), to deal
24
+ * in the Software without restriction, including without limitation the rights
25
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ * copies of the Software, and to permit persons to whom the Software is
27
+ * furnished to do so, subject to the following conditions:
28
+ *
29
+ * The above copyright notice and this permission notice shall be included in all
30
+ * copies or substantial portions of the Software.
31
+ *
32
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ * SOFTWARE.
39
+ */
40
+
41
+ /**
42
+ ---
43
+ private: true
44
+ id: GlobalNav.MainNavItem
45
+ ---
46
+ **/const MainNavItem = props => {
47
+ const {
48
+ item,
49
+ collapsed,
50
+ open,
51
+ subNavId,
52
+ onActivate,
53
+ elementRef
54
+ } = props;
55
+ const current = !!item.current;
56
+ const styles = (0, _emotion.useStyleNew)({
57
+ generateStyle: _styles.default,
58
+ params: {
59
+ collapsed,
60
+ current,
61
+ open
62
+ },
63
+ componentId: 'MainNavItem'
64
+ });
65
+ const label = item.label;
66
+ const badgeCount = item.badgeCount ?? 0;
67
+ const badgeLabel = typeof item.badgeLabel === 'function' ? item.badgeLabel(badgeCount) : item.badgeLabel;
68
+ const formatBadge = formattedCount => badgeLabel ? (0, _jsxRuntime.jsx)(_uiA11yContent.AccessibleContent, {
69
+ alt: badgeLabel,
70
+ children: formattedCount
71
+ }) : formattedCount;
72
+ const badge = badgeCount > 0 && (0, _jsxRuntime.jsx)(_latest.Badge, {
73
+ standalone: true,
74
+ count: badgeCount,
75
+ formatOutput: formatBadge
76
+ });
77
+ const content = collapsed ? (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
78
+ children: [(0, _jsxRuntime.jsx)(_uiA11yContent.ScreenReaderContent, {
79
+ children: label
80
+ }), (0, _jsxRuntime.jsxs)("span", {
81
+ css: styles?.icon,
82
+ children: [(0, _uiReactUtils.callRenderProp)(item.icon), badge && (0, _jsxRuntime.jsx)("span", {
83
+ css: styles?.badge,
84
+ children: badge
85
+ })]
86
+ })]
87
+ }) : (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
88
+ children: [(0, _jsxRuntime.jsx)("span", {
89
+ css: styles?.icon,
90
+ children: (0, _uiReactUtils.callRenderProp)(item.icon)
91
+ }), (0, _jsxRuntime.jsx)("span", {
92
+ css: styles?.label,
93
+ children: label
94
+ }), badge, item.subNav && (0, _jsxRuntime.jsx)("span", {
95
+ css: styles?.chevron,
96
+ children: (0, _jsxRuntime.jsx)(_uiIcons.ChevronRightInstUIIcon, {})
97
+ })]
98
+ });
99
+ const {
100
+ isLink,
101
+ props: mergedProps
102
+ } = (0, _getItemElementProps.getItemElementProps)(item, event => onActivate(event, item), item.subNav ? {
103
+ 'aria-expanded': open,
104
+ 'aria-controls': subNavId
105
+ } : undefined);
106
+ let element;
107
+ if (isLink) {
108
+ element = (0, _jsxRuntime.jsx)("a", {
109
+ ...mergedProps,
110
+ ref: elementRef,
111
+ css: styles?.item,
112
+ children: content
113
+ });
114
+ } else {
115
+ element = (0, _jsxRuntime.jsx)("button", {
116
+ ...mergedProps,
117
+ ref: elementRef,
118
+ css: styles?.item,
119
+ children: content
120
+ });
121
+ }
122
+ return (0, _jsxRuntime.jsx)("li", {
123
+ children: collapsed ? (0, _jsxRuntime.jsx)(_latest2.Tooltip, {
124
+ renderTip: label,
125
+ placement: "end",
126
+ children: (0, _jsxRuntime.jsx)("span", {
127
+ css: styles?.tooltipTrigger,
128
+ children: element
129
+ })
130
+ }) : element
131
+ });
132
+ };
133
+ exports.MainNavItem = MainNavItem;
134
+ var _default = exports.default = MainNavItem;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = 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
+ * Generates the style object from the theme and provided additional information
36
+ * @param componentTheme The theme variable object.
37
+ * @param params Additional parameters to customize the style.
38
+ * @return The final style object, which will be used in the component
39
+ */
40
+ const generateStyle = (componentTheme, params) => {
41
+ const {
42
+ collapsed,
43
+ current,
44
+ open
45
+ } = params;
46
+ return {
47
+ item: {
48
+ label: 'mainNavItem',
49
+ display: 'flex',
50
+ alignItems: 'center',
51
+ // MainNavItem has no gap token
52
+ gap: componentTheme.horizontalPadding,
53
+ boxSizing: 'border-box',
54
+ width: collapsed ? componentTheme.minimizedItemSize : '100%',
55
+ height: collapsed ? componentTheme.minimizedItemSize : undefined,
56
+ justifyContent: collapsed ? 'center' : undefined,
57
+ margin: 0,
58
+ padding: collapsed ? 0 : `${componentTheme.verticalPadding} ${componentTheme.horizontalPadding}`,
59
+ border: 'none',
60
+ borderRadius: componentTheme.borderRadius,
61
+ backgroundColor: current ? componentTheme.currentBackgroundColor : open ? componentTheme.activeBackgroundColor : componentTheme.backgroundColor,
62
+ color: current ? componentTheme.currentTextColor : componentTheme.fontColor,
63
+ fontFamily: componentTheme.fontFamily,
64
+ fontSize: componentTheme.fontSize,
65
+ fontWeight: componentTheme.fontWeight,
66
+ lineHeight: componentTheme.lineHeight,
67
+ textAlign: 'start',
68
+ textDecoration: componentTheme.linkTextDecoration,
69
+ cursor: 'pointer',
70
+ '&:hover': {
71
+ // a page-wide a:hover rule is more specific than the base class
72
+ textDecoration: componentTheme.linkTextDecoration,
73
+ ...(!current && !open && {
74
+ backgroundColor: componentTheme.hoverBackgroundColor
75
+ })
76
+ },
77
+ ...(!current && !open && {
78
+ '&:active': {
79
+ backgroundColor: componentTheme.activeBackgroundColor
80
+ }
81
+ }),
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
+ // same focus ring as SideNavBarItem, which has the same focus tokens
86
+ '&:focus': {
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
+ }
90
+ },
91
+ icon: {
92
+ label: 'mainNavItem__icon',
93
+ position: 'relative',
94
+ display: 'flex',
95
+ alignItems: 'center',
96
+ flexShrink: 0,
97
+ height: componentTheme.iconWrapperHeight
98
+ },
99
+ badge: {
100
+ label: 'mainNavItem__badge',
101
+ position: 'absolute',
102
+ top: 0,
103
+ // the badge starts at the icon's center, so a longer count grows away from the icon
104
+ insetInlineStart: '50%',
105
+ // flex, so the item's line height doesn't push the badge down
106
+ display: 'flex'
107
+ },
108
+ label: {
109
+ label: 'mainNavItem__label',
110
+ flex: 1
111
+ },
112
+ chevron: {
113
+ label: 'mainNavItem__chevron',
114
+ display: 'flex',
115
+ flexShrink: 0
116
+ },
117
+ tooltipTrigger: {
118
+ label: 'mainNavItem__tooltipTrigger',
119
+ display: 'block'
120
+ }
121
+ };
122
+ };
123
+ var _default = exports.default = generateStyle;