@teambit/component 0.0.692 → 0.0.695
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/aspect.section.tsx +1 -0
- package/dist/aspect.section.d.ts +1 -0
- package/dist/aspect.section.js +2 -1
- package/dist/aspect.section.js.map +1 -1
- package/dist/section/section.d.ts +4 -0
- package/dist/ui/menu/menu-nav.d.ts +4 -3
- package/dist/ui/menu/menu-nav.js +24 -7
- package/dist/ui/menu/menu-nav.js.map +1 -1
- package/dist/ui/menu/menu.js +14 -1
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/menu/menu.module.scss +31 -4
- package/dist/ui/menu/mobile-menu-nav.d.ts +7 -0
- package/dist/ui/menu/mobile-menu-nav.js +191 -0
- package/dist/ui/menu/mobile-menu-nav.js.map +1 -0
- package/dist/ui/menu/mobile-menu-nav.module.scss +70 -0
- package/dist/ui/menu/nav-plugin.d.ts +4 -1
- package/dist/ui/top-bar-nav/top-bar-nav.d.ts +2 -1
- package/dist/ui/top-bar-nav/top-bar-nav.js +34 -20
- package/dist/ui/top-bar-nav/top-bar-nav.js.map +1 -1
- package/dist/ui/use-component.js +3 -3
- package/dist/ui/use-component.js.map +1 -1
- package/package-tar/teambit-component-0.0.695.tgz +0 -0
- package/package.json +27 -23
- package/{preview-1648437892896.js → preview-1648696872583.js} +2 -2
- package/section/section.tsx +4 -0
- package/ui/menu/menu-nav.tsx +12 -8
- package/ui/menu/menu.module.scss +31 -4
- package/ui/menu/menu.tsx +3 -1
- package/ui/menu/mobile-menu-nav.module.scss +70 -0
- package/ui/menu/mobile-menu-nav.tsx +82 -0
- package/ui/menu/nav-plugin.tsx +5 -1
- package/ui/top-bar-nav/top-bar-nav.tsx +10 -9
- package/ui/use-component.tsx +2 -2
- package/package-tar/teambit-component-0.0.692.tgz +0 -0
package/aspect.section.tsx
CHANGED
package/dist/aspect.section.d.ts
CHANGED
package/dist/aspect.section.js
CHANGED
|
@@ -58,7 +58,8 @@ class AspectSection {
|
|
|
58
58
|
children: /*#__PURE__*/_react().default.createElement(_uiFoundationUi().MenuWidgetIcon, {
|
|
59
59
|
icon: "configuration",
|
|
60
60
|
tooltipContent: "Configuration"
|
|
61
|
-
})
|
|
61
|
+
}),
|
|
62
|
+
displayName: 'Configuration'
|
|
62
63
|
});
|
|
63
64
|
(0, _defineProperty2().default)(this, "order", 50);
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["aspect.section.tsx"],"names":["AspectSection","path","children","href"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,aAAN,CAAuC;AAAA;AAAA,mDACpC;AACNC,MAAAA,IAAI,EAAE,SADA;AAENC,MAAAA,QAAQ,eAAE,+BAAC,wBAAD;AAFJ,KADoC;AAAA,4DAK3B;AACfC,MAAAA,IAAI,EAAE,SADS;AAEfD,MAAAA,QAAQ,eAAE,+BAAC,gCAAD;AAAgB,QAAA,IAAI,EAAC,eAArB;AAAqC,QAAA,cAAc,EAAC;AAApD;
|
|
1
|
+
{"version":3,"sources":["aspect.section.tsx"],"names":["AspectSection","path","children","href","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,aAAN,CAAuC;AAAA;AAAA,mDACpC;AACNC,MAAAA,IAAI,EAAE,SADA;AAENC,MAAAA,QAAQ,eAAE,+BAAC,wBAAD;AAFJ,KADoC;AAAA,4DAK3B;AACfC,MAAAA,IAAI,EAAE,SADS;AAEfD,MAAAA,QAAQ,eAAE,+BAAC,gCAAD;AAAgB,QAAA,IAAI,EAAC,eAArB;AAAqC,QAAA,cAAc,EAAC;AAApD,QAFK;AAGfE,MAAAA,WAAW,EAAE;AAHE,KAL2B;AAAA,mDAUpC,EAVoC;AAAA;;AAAA","sourcesContent":["import React from 'react';\nimport { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';\nimport { Section } from './section';\nimport { AspectPage } from './ui/aspect-page';\n\nexport class AspectSection implements Section {\n route = {\n path: '~aspect',\n children: <AspectPage />,\n };\n navigationLink = {\n href: '~aspect',\n children: <MenuWidgetIcon icon=\"configuration\" tooltipContent=\"Configuration\" />,\n displayName: 'Configuration',\n };\n order = 50;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { OrderedNavigationSlot } from './nav-plugin';
|
|
3
|
-
export declare
|
|
3
|
+
export declare type MenuNavProps = {
|
|
4
4
|
navigationSlot: OrderedNavigationSlot;
|
|
5
|
-
}
|
|
5
|
+
} & React.HTMLAttributes<HTMLElement>;
|
|
6
|
+
export declare function MenuNav({ navigationSlot, className }: MenuNavProps): JSX.Element;
|
package/dist/ui/menu/menu-nav.js
CHANGED
|
@@ -22,7 +22,7 @@ function _extends2() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function _react() {
|
|
25
|
-
const data =
|
|
25
|
+
const data = _interopRequireWildcard(require("react"));
|
|
26
26
|
|
|
27
27
|
_react = function () {
|
|
28
28
|
return data;
|
|
@@ -31,6 +31,16 @@ function _react() {
|
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function _classnames() {
|
|
35
|
+
const data = _interopRequireDefault(require("classnames"));
|
|
36
|
+
|
|
37
|
+
_classnames = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
function _topBarNav() {
|
|
35
45
|
const data = require("../top-bar-nav");
|
|
36
46
|
|
|
@@ -51,15 +61,22 @@ function _menuModule() {
|
|
|
51
61
|
return data;
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
65
|
+
|
|
66
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
67
|
+
|
|
54
68
|
function MenuNav({
|
|
55
|
-
navigationSlot
|
|
69
|
+
navigationSlot,
|
|
70
|
+
className
|
|
56
71
|
}) {
|
|
57
|
-
const plugins = navigationSlot.toArray().sort(sortFn);
|
|
72
|
+
const plugins = (0, _react().useMemo)(() => navigationSlot.toArray().sort(sortFn), [navigationSlot]);
|
|
58
73
|
return /*#__PURE__*/_react().default.createElement("nav", {
|
|
59
|
-
className: _menuModule().default.navigation
|
|
60
|
-
}, plugins.map(([id, menuItem]) =>
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
className: (0, _classnames().default)(_menuModule().default.navigation, _menuModule().default.desktopNav, className)
|
|
75
|
+
}, plugins.map(([id, menuItem]) => {
|
|
76
|
+
return /*#__PURE__*/_react().default.createElement(_topBarNav().TopBarNav, (0, _extends2().default)({
|
|
77
|
+
key: id
|
|
78
|
+
}, menuItem.props));
|
|
79
|
+
}));
|
|
63
80
|
}
|
|
64
81
|
|
|
65
82
|
function sortFn([, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["menu-nav.tsx"],"names":["MenuNav","navigationSlot","plugins","toArray","sort","sortFn","styles","navigation","map","id","menuItem","props","order","first","second"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;
|
|
1
|
+
{"version":3,"sources":["menu-nav.tsx"],"names":["MenuNav","navigationSlot","className","plugins","toArray","sort","sortFn","styles","navigation","desktopNav","map","id","menuItem","props","order","first","second"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAOO,SAASA,OAAT,CAAiB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAAjB,EAA8D;AACnE,QAAMC,OAAO,GAAG,sBAAQ,MAAMF,cAAc,CAACG,OAAf,GAAyBC,IAAzB,CAA8BC,MAA9B,CAAd,EAAqD,CAACL,cAAD,CAArD,CAAhB;AAEA,sBACE;AAAK,IAAA,SAAS,EAAE,2BAAWM,sBAAOC,UAAlB,EAA8BD,sBAAOE,UAArC,EAAiDP,SAAjD;AAAhB,KACGC,OAAO,CAACO,GAAR,CAAY,CAAC,CAACC,EAAD,EAAKC,QAAL,CAAD,KAAoB;AAC/B,wBAAO,+BAAC,sBAAD;AAAW,MAAA,GAAG,EAAED;AAAhB,OAAwBC,QAAQ,CAACC,KAAjC,EAAP;AACD,GAFA,CADH,CADF;AAOD;;AAED,SAASP,MAAT,CAAgB,GAAG;AAAEQ,EAAAA,KAAK,EAAEC;AAAT,CAAH,CAAhB,EAA2D,GAAG;AAAED,EAAAA,KAAK,EAAEE;AAAT,CAAH,CAA3D,EAAuG;AACrG;AACA;AACA;AAEA,SAAO,CAACD,KAAD,aAACA,KAAD,cAACA,KAAD,GAAU,CAAV,KAAgBC,MAAhB,aAAgBA,MAAhB,cAAgBA,MAAhB,GAA0B,CAA1B,CAAP;AACD,C,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["import React, { useMemo } from 'react';\nimport classnames from 'classnames';\nimport { TopBarNav } from '../top-bar-nav';\nimport styles from './menu.module.scss';\nimport { NavPlugin, OrderedNavigationSlot } from './nav-plugin';\n\nexport type MenuNavProps = {\n navigationSlot: OrderedNavigationSlot;\n} & React.HTMLAttributes<HTMLElement>;\n\nexport function MenuNav({ navigationSlot, className }: MenuNavProps) {\n const plugins = useMemo(() => navigationSlot.toArray().sort(sortFn), [navigationSlot]);\n\n return (\n <nav className={classnames(styles.navigation, styles.desktopNav, className)}>\n {plugins.map(([id, menuItem]) => {\n return <TopBarNav key={id} {...menuItem.props} />;\n })}\n </nav>\n );\n}\n\nfunction sortFn([, { order: first }]: [string, NavPlugin], [, { order: second }]: [string, NavPlugin]) {\n // 0 - equal\n // <0 - first < second\n // >0 - first > second\n\n return (first ?? 0) - (second ?? 0);\n}\n\n// // this is the aspect-oriented and serialize-able way to sort plugins.\n// const pluginOrder = ['teambit.docs/docs', 'teambit.compositions/compositions', 'teambit.docs/docs'];\n// export function toSortedArray<T>(slot: SlotRegistry<T>, order: string[]) {\n// // sort items according to the order\n// const sorted = order.map((x) => [x, slot.get(x)]).filter(([, val]) => !!val) as [string, T][];\n//\n// // add all other items\n// const unsorted = slot.toArray().filter(([id]) => order.indexOf(id) < 0);\n//\n// return sorted.concat(unsorted);\n// }\n"]}
|
package/dist/ui/menu/menu.js
CHANGED
|
@@ -141,6 +141,16 @@ function _menuNav() {
|
|
|
141
141
|
return data;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
function _mobileMenuNav() {
|
|
145
|
+
const data = require("./mobile-menu-nav");
|
|
146
|
+
|
|
147
|
+
_mobileMenuNav = function () {
|
|
148
|
+
return data;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
|
|
144
154
|
function _menuModule() {
|
|
145
155
|
const data = _interopRequireDefault(require("./menu.module.scss"));
|
|
146
156
|
|
|
@@ -181,6 +191,9 @@ function Menu({
|
|
|
181
191
|
className: _menuModule().default.leftSide
|
|
182
192
|
}, /*#__PURE__*/_react().default.createElement(_menuNav().MenuNav, {
|
|
183
193
|
navigationSlot: navigationSlot
|
|
194
|
+
}), /*#__PURE__*/_react().default.createElement(_mobileMenuNav().MobileMenuNav, {
|
|
195
|
+
navigationSlot: navigationSlot,
|
|
196
|
+
widgetSlot: widgetSlot
|
|
184
197
|
})), /*#__PURE__*/_react().default.createElement("div", {
|
|
185
198
|
className: _menuModule().default.rightSide
|
|
186
199
|
}, /*#__PURE__*/_react().default.createElement("div", {
|
|
@@ -204,7 +217,7 @@ function VersionRelatedDropdowns({
|
|
|
204
217
|
const location = (0, _baseUiRouting().useLocation)();
|
|
205
218
|
const isNew = component.tags.isEmpty();
|
|
206
219
|
const lanesContext = (0, _lanesUi().useLanesContext)();
|
|
207
|
-
const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.
|
|
220
|
+
const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.viewedLane;
|
|
208
221
|
const {
|
|
209
222
|
logs
|
|
210
223
|
} = component;
|
package/dist/ui/menu/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["menu.tsx"],"names":["Menu","navigationSlot","widgetSlot","className","host","menuItemSlot","consumeMethodSlot","component","mainMenuItems","values","styles","topBar","leftSide","rightSide","widgets","VersionRelatedDropdowns","consumeMethods","location","isNew","tags","isEmpty","lanesContext","currentLane","logs","isWorkspace","snaps","filter","log","tag","map","snap","version","hash","tagLookup","Map","forEach","set","toArray","reverse","get","lanes","getLanesByComponentId","id","localVersion","currentVersion","search","includes","methods","useConsumeMethods","length","useBox","name","latest","componentModel","method","x","Component","Title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAASA,IAAT,CAAc;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA,UAAlB;AAA8BC,EAAAA,SAA9B;AAAyCC,EAAAA,IAAzC;AAA+CC,EAAAA,YAA/C;AAA6DC,EAAAA;AAA7D,CAAd,EAA2G;AAChH,QAAM;AAAEC,IAAAA;AAAF,MAAgB,kCAAaH,IAAb,CAAtB;AACA,QAAMI,aAAa,GAAG,sBAAQ,MAAM,uBAAQ,uBAAQH,YAAY,CAACI,MAAb,EAAR,CAAR,EAAwC,UAAxC,CAAd,EAAmE,CAACJ,YAAD,CAAnE,CAAtB;AACA,MAAI,CAACE,SAAL,EAAgB,oBAAO,+BAAC,6BAAD,OAAP;AAChB,sBACE;AAAK,IAAA,SAAS,EAAE,2BAAWG,sBAAOC,MAAlB,EAA0BR,SAA1B;AAAhB,kBACE;AAAK,IAAA,SAAS,EAAEO,sBAAOE;AAAvB,kBACE,+BAAC,kBAAD;AAAS,IAAA,cAAc,EAAEX;AAAzB,IADF,CADF,
|
|
1
|
+
{"version":3,"sources":["menu.tsx"],"names":["Menu","navigationSlot","widgetSlot","className","host","menuItemSlot","consumeMethodSlot","component","mainMenuItems","values","styles","topBar","leftSide","rightSide","widgets","VersionRelatedDropdowns","consumeMethods","location","isNew","tags","isEmpty","lanesContext","currentLane","viewedLane","logs","isWorkspace","snaps","filter","log","tag","map","snap","version","hash","tagLookup","Map","forEach","set","toArray","reverse","get","lanes","getLanesByComponentId","id","localVersion","currentVersion","search","includes","methods","useConsumeMethods","length","useBox","name","latest","componentModel","method","x","Component","Title"],"mappings":"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","sourcesContent":["import { MainDropdown, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';\nimport { VersionDropdown } from '@teambit/component.ui.version-dropdown';\nimport { FullLoader } from '@teambit/ui-foundation.ui.full-loader';\nimport type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { useLocation } from '@teambit/base-ui.routing.routing-provider';\nimport { flatten, groupBy, compact } from 'lodash';\nimport classnames from 'classnames';\nimport React, { useMemo } from 'react';\nimport { UseBoxDropdown } from '@teambit/ui-foundation.ui.use-box.dropdown';\nimport { Menu as ConsumeMethodsMenu } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { LaneModel, useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport type { ComponentModel } from '../component-model';\nimport { useComponent } from '../use-component';\nimport { MenuNav } from './menu-nav';\nimport { MobileMenuNav } from './mobile-menu-nav';\nimport styles from './menu.module.scss';\nimport { OrderedNavigationSlot, ConsumeMethodSlot } from './nav-plugin';\n\nexport type MenuProps = {\n className?: string;\n /**\n * slot for top bar menu nav items\n */\n navigationSlot: OrderedNavigationSlot;\n /**\n * right side menu item slot\n */\n widgetSlot: OrderedNavigationSlot;\n host: string;\n /**\n * main dropdown item slot\n */\n menuItemSlot: MenuItemSlot;\n\n consumeMethodSlot: ConsumeMethodSlot;\n};\n\n/**\n * top bar menu.\n */\nexport function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot, consumeMethodSlot }: MenuProps) {\n const { component } = useComponent(host);\n const mainMenuItems = useMemo(() => groupBy(flatten(menuItemSlot.values()), 'category'), [menuItemSlot]);\n if (!component) return <FullLoader />;\n return (\n <div className={classnames(styles.topBar, className)}>\n <div className={styles.leftSide}>\n <MenuNav navigationSlot={navigationSlot} />\n <MobileMenuNav navigationSlot={navigationSlot} widgetSlot={widgetSlot} />\n </div>\n <div className={styles.rightSide}>\n <div className={styles.widgets}>\n <MenuNav navigationSlot={widgetSlot} />\n </div>\n <VersionRelatedDropdowns component={component} consumeMethods={consumeMethodSlot} host={host} />\n <MainDropdown menuItems={mainMenuItems} />\n </div>\n </div>\n );\n}\n\nfunction VersionRelatedDropdowns({\n component,\n consumeMethods,\n host,\n}: {\n component: ComponentModel;\n consumeMethods: ConsumeMethodSlot;\n host: string;\n}) {\n const location = useLocation();\n const isNew = component.tags.isEmpty();\n const lanesContext = useLanesContext();\n const currentLane = lanesContext?.viewedLane;\n const { logs } = component;\n const isWorkspace = host === 'teambit.workspace/workspace';\n\n const snaps = useMemo(() => {\n return (logs || []).filter((log) => !log.tag).map((snap) => ({ ...snap, version: snap.hash }));\n }, [logs]);\n\n const tags = useMemo(() => {\n const tagLookup = new Map<string, LegacyComponentLog>();\n (logs || [])\n .filter((log) => log.tag)\n .forEach((tag) => {\n tagLookup.set(tag?.tag as string, tag);\n });\n return compact(\n component.tags\n ?.toArray()\n .reverse()\n .map((tag) => tagLookup.get(tag.version.version))\n ).map((tag) => ({ ...tag, version: tag.tag as string }));\n }, [logs]);\n\n const lanes = lanesContext?.getLanesByComponentId(component.id) || [];\n const localVersion = isWorkspace && !isNew && !currentLane;\n\n const currentVersion =\n isWorkspace && !isNew && !location.search.includes('version') ? 'workspace' : component.version;\n\n const methods = useConsumeMethods(consumeMethods, component, currentLane);\n return (\n <>\n {tags.length > 0 && (\n <UseBoxDropdown\n position=\"bottom-end\"\n className={styles.useBox}\n Menu={<ConsumeMethodsMenu methods={methods} componentName={component.id.name} />}\n />\n )}\n <VersionDropdown\n tags={tags}\n snaps={snaps}\n lanes={lanes}\n localVersion={localVersion}\n currentVersion={currentVersion}\n latestVersion={component.latest}\n currentLane={currentLane}\n />\n </>\n );\n}\n\nfunction useConsumeMethods(\n consumeMethods: ConsumeMethodSlot,\n componentModel: ComponentModel,\n currentLane?: LaneModel\n): ConsumeMethod[] {\n return useMemo(\n () =>\n flatten(consumeMethods.values())\n .map((method) => {\n return method?.(componentModel, { currentLane });\n })\n .filter((x) => !!x && x.Component && x.Title) as ConsumeMethod[],\n [consumeMethods, componentModel, currentLane]\n );\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import '~@teambit/base-ui.layout.breakpoints/_breakpoints.scss';
|
|
2
|
+
|
|
1
3
|
.topBar {
|
|
2
4
|
display: flex;
|
|
3
5
|
justify-content: space-between;
|
|
@@ -13,19 +15,36 @@
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
.navigation {
|
|
16
|
-
display: flex;
|
|
17
18
|
list-style: none;
|
|
18
19
|
height: 100%;
|
|
19
20
|
padding-left: 28px;
|
|
20
|
-
@media screen and (max-width:
|
|
21
|
-
padding-left:
|
|
21
|
+
@media screen and (max-width: $br-md) {
|
|
22
|
+
padding-left: 0;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
li {
|
|
25
26
|
display: block;
|
|
26
27
|
margin-right: 16px;
|
|
27
28
|
height: 100%;
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
// show desktop nav on larger res
|
|
32
|
+
&.desktopNav {
|
|
33
|
+
display: flex;
|
|
34
|
+
@media screen and (max-width: $br-lg) {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// show mobile nav on smaller res
|
|
40
|
+
&.mobileNav {
|
|
41
|
+
align-items: center;
|
|
42
|
+
display: none;
|
|
43
|
+
@media screen and (max-width: $br-lg) {
|
|
44
|
+
display: flex;
|
|
45
|
+
margin-right: 8px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
}
|
|
30
49
|
|
|
31
50
|
.rightSide {
|
|
@@ -38,6 +57,11 @@
|
|
|
38
57
|
margin-right: 16px;
|
|
39
58
|
}
|
|
40
59
|
}
|
|
60
|
+
@media screen and (max-width: $br-lg) {
|
|
61
|
+
> * {
|
|
62
|
+
margin-right: 8px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
41
65
|
.widgets {
|
|
42
66
|
height: 100%;
|
|
43
67
|
margin-right: 20px;
|
|
@@ -51,6 +75,9 @@
|
|
|
51
75
|
}
|
|
52
76
|
}
|
|
53
77
|
}
|
|
78
|
+
@media screen and (max-width: $br-lg) {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
54
81
|
}
|
|
55
82
|
.widget {
|
|
56
83
|
font-size: 17px;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OrderedNavigationSlot } from './nav-plugin';
|
|
3
|
+
export declare function MobileMenuNav({ navigationSlot, widgetSlot, className, }: {
|
|
4
|
+
navigationSlot: OrderedNavigationSlot;
|
|
5
|
+
widgetSlot: OrderedNavigationSlot;
|
|
6
|
+
className?: string;
|
|
7
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.array.sort.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.MobileMenuNav = MobileMenuNav;
|
|
13
|
+
|
|
14
|
+
function _objectWithoutProperties2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
|
+
|
|
17
|
+
_objectWithoutProperties2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _extends2() {
|
|
25
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
26
|
+
|
|
27
|
+
_extends2 = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _react() {
|
|
35
|
+
const data = _interopRequireWildcard(require("react"));
|
|
36
|
+
|
|
37
|
+
_react = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _reactRouterDom() {
|
|
45
|
+
const data = require("react-router-dom");
|
|
46
|
+
|
|
47
|
+
_reactRouterDom = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _classnames() {
|
|
55
|
+
const data = _interopRequireDefault(require("classnames"));
|
|
56
|
+
|
|
57
|
+
_classnames = function () {
|
|
58
|
+
return data;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _designElements() {
|
|
65
|
+
const data = require("@teambit/design.elements.icon");
|
|
66
|
+
|
|
67
|
+
_designElements = function () {
|
|
68
|
+
return data;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _designInputs() {
|
|
75
|
+
const data = require("@teambit/design.inputs.dropdown");
|
|
76
|
+
|
|
77
|
+
_designInputs = function () {
|
|
78
|
+
return data;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _uiFoundationUiReactRouter() {
|
|
85
|
+
const data = require("@teambit/ui-foundation.ui.react-router.extend-path");
|
|
86
|
+
|
|
87
|
+
_uiFoundationUiReactRouter = function () {
|
|
88
|
+
return data;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _topBarNav() {
|
|
95
|
+
const data = require("../top-bar-nav");
|
|
96
|
+
|
|
97
|
+
_topBarNav = function () {
|
|
98
|
+
return data;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _menuModule() {
|
|
105
|
+
const data = _interopRequireDefault(require("./menu.module.scss"));
|
|
106
|
+
|
|
107
|
+
_menuModule = function () {
|
|
108
|
+
return data;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _mobileMenuNavModule() {
|
|
115
|
+
const data = _interopRequireDefault(require("./mobile-menu-nav.module.scss"));
|
|
116
|
+
|
|
117
|
+
_mobileMenuNavModule = function () {
|
|
118
|
+
return data;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
125
|
+
|
|
126
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
127
|
+
|
|
128
|
+
function MobileMenuNav({
|
|
129
|
+
navigationSlot,
|
|
130
|
+
widgetSlot,
|
|
131
|
+
className
|
|
132
|
+
}) {
|
|
133
|
+
const {
|
|
134
|
+
url
|
|
135
|
+
} = (0, _reactRouterDom().useRouteMatch)();
|
|
136
|
+
const totalSlots = (0, _react().useMemo)(() => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)], [navigationSlot, widgetSlot]);
|
|
137
|
+
return /*#__PURE__*/_react().default.createElement(_designInputs().Dropdown // @ts-ignore - mismatch between @types/react
|
|
138
|
+
, {
|
|
139
|
+
placeholder: /*#__PURE__*/_react().default.createElement(Placeholder, {
|
|
140
|
+
slots: totalSlots,
|
|
141
|
+
baseUrl: url
|
|
142
|
+
}),
|
|
143
|
+
className: (0, _classnames().default)(_menuModule().default.navigation, _menuModule().default.mobileNav, className),
|
|
144
|
+
dropClass: _mobileMenuNavModule().default.mobileMenu
|
|
145
|
+
}, /*#__PURE__*/_react().default.createElement("nav", null, /*#__PURE__*/_react().default.createElement(_designElements().Icon, {
|
|
146
|
+
of: "x-thick",
|
|
147
|
+
className: _mobileMenuNavModule().default.close
|
|
148
|
+
}), totalSlots.map(([id, menuItem]) => {
|
|
149
|
+
return /*#__PURE__*/_react().default.createElement(_topBarNav().TopBarNav, (0, _extends2().default)({
|
|
150
|
+
key: id
|
|
151
|
+
}, menuItem.props, {
|
|
152
|
+
className: _mobileMenuNavModule().default.mobileMenuLink,
|
|
153
|
+
activeClassName: _mobileMenuNavModule().default.active
|
|
154
|
+
}), typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName);
|
|
155
|
+
})));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function sortFn([, {
|
|
159
|
+
order: first
|
|
160
|
+
}], [, {
|
|
161
|
+
order: second
|
|
162
|
+
}]) {
|
|
163
|
+
// 0 - equal
|
|
164
|
+
// <0 - first < second
|
|
165
|
+
// >0 - first > second
|
|
166
|
+
return (first !== null && first !== void 0 ? first : 0) - (second !== null && second !== void 0 ? second : 0);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function Placeholder(_ref) {
|
|
170
|
+
let {
|
|
171
|
+
slots,
|
|
172
|
+
baseUrl = ''
|
|
173
|
+
} = _ref,
|
|
174
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["slots", "baseUrl"]);
|
|
175
|
+
return /*#__PURE__*/_react().default.createElement("div", (0, _extends2().default)({}, rest, {
|
|
176
|
+
className: _mobileMenuNavModule().default.placeholder
|
|
177
|
+
}), /*#__PURE__*/_react().default.createElement(_reactRouterDom().Switch, null, slots === null || slots === void 0 ? void 0 : slots.map(([id, menuItem]) => {
|
|
178
|
+
var _menuItem$props, _menuItem$props2, _menuItem$props3, _menuItem$props4;
|
|
179
|
+
|
|
180
|
+
const path = (0, _uiFoundationUiReactRouter().extendPath)(baseUrl, menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props = menuItem.props) === null || _menuItem$props === void 0 ? void 0 : _menuItem$props.href);
|
|
181
|
+
return /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
|
|
182
|
+
key: id,
|
|
183
|
+
exact: true,
|
|
184
|
+
path: path
|
|
185
|
+
}, typeof (menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props2 = menuItem.props) === null || _menuItem$props2 === void 0 ? void 0 : _menuItem$props2.children) === 'string' ? menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props3 = menuItem.props) === null || _menuItem$props3 === void 0 ? void 0 : _menuItem$props3.children : menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props4 = menuItem.props) === null || _menuItem$props4 === void 0 ? void 0 : _menuItem$props4.displayName);
|
|
186
|
+
})), /*#__PURE__*/_react().default.createElement(_designElements().Icon, {
|
|
187
|
+
of: "fat-arrow-down"
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//# sourceMappingURL=mobile-menu-nav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["mobile-menu-nav.tsx"],"names":["MobileMenuNav","navigationSlot","widgetSlot","className","url","totalSlots","toArray","sort","sortFn","styles","navigation","mobileNav","mobileStyles","mobileMenu","close","map","id","menuItem","props","mobileMenuLink","active","children","displayName","order","first","second","Placeholder","slots","baseUrl","rest","placeholder","path","href"],"mappings":"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","sourcesContent":["import React, { useMemo } from 'react';\nimport { Switch, Route, useRouteMatch } from 'react-router-dom';\nimport classnames from 'classnames';\nimport { Icon } from '@teambit/design.elements.icon';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';\nimport { TopBarNav } from '../top-bar-nav';\nimport styles from './menu.module.scss';\nimport mobileStyles from './mobile-menu-nav.module.scss';\nimport { NavPlugin, OrderedNavigationSlot } from './nav-plugin';\n\nexport function MobileMenuNav({\n navigationSlot,\n widgetSlot,\n className,\n}: {\n navigationSlot: OrderedNavigationSlot;\n widgetSlot: OrderedNavigationSlot;\n className?: string;\n}) {\n const { url } = useRouteMatch();\n const totalSlots = useMemo(\n () => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)],\n [navigationSlot, widgetSlot]\n );\n\n return (\n <Dropdown\n // @ts-ignore - mismatch between @types/react\n placeholder={<Placeholder slots={totalSlots} baseUrl={url} />}\n className={classnames(styles.navigation, styles.mobileNav, className)}\n dropClass={mobileStyles.mobileMenu}\n >\n <nav>\n <Icon of=\"x-thick\" className={mobileStyles.close} />\n {totalSlots.map(([id, menuItem]) => {\n return (\n <TopBarNav\n key={id}\n {...menuItem.props}\n className={mobileStyles.mobileMenuLink}\n activeClassName={mobileStyles.active}\n >\n {typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName}\n </TopBarNav>\n );\n })}\n </nav>\n </Dropdown>\n );\n}\n\nfunction sortFn([, { order: first }]: [string, NavPlugin], [, { order: second }]: [string, NavPlugin]) {\n // 0 - equal\n // <0 - first < second\n // >0 - first > second\n\n return (first ?? 0) - (second ?? 0);\n}\n\ntype PlaceholderProps = {\n slots: [string, NavPlugin][];\n baseUrl?: string;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nfunction Placeholder({ slots, baseUrl = '', ...rest }: PlaceholderProps) {\n return (\n <div {...rest} className={mobileStyles.placeholder}>\n <Switch>\n {slots?.map(([id, menuItem]) => {\n const path = extendPath(baseUrl, menuItem?.props?.href);\n return (\n <Route key={id} exact path={path}>\n {typeof menuItem?.props?.children === 'string' ? menuItem?.props?.children : menuItem?.props?.displayName}\n </Route>\n );\n })}\n </Switch>\n <Icon of=\"fat-arrow-down\" />\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
+
@import '~@teambit/base-ui.layout.breakpoints/_breakpoints.scss';
|
|
3
|
+
|
|
4
|
+
.mobileMenuLink {
|
|
5
|
+
margin: 0;
|
|
6
|
+
transition: background-color 300ms ease-in-out;
|
|
7
|
+
&:hover {
|
|
8
|
+
background-color: var(--bit-bg-heavy);
|
|
9
|
+
}
|
|
10
|
+
@media screen and (max-width: $br-md) {
|
|
11
|
+
height: 40px;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.mobileMenu {
|
|
17
|
+
> nav {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
.active {
|
|
22
|
+
background-color: var(--bit-accent-bg, #eceaff);
|
|
23
|
+
color: inherit;
|
|
24
|
+
&:after {
|
|
25
|
+
background-color: unset;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.close {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
@media screen and (max-width: $br-md) {
|
|
32
|
+
position: fixed;
|
|
33
|
+
top: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
padding: 0;
|
|
38
|
+
z-index: $modal-z-index;
|
|
39
|
+
.close {
|
|
40
|
+
align-self: self-end;
|
|
41
|
+
padding: 8px;
|
|
42
|
+
display: flex;
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: var(--bit-bg-heavy, #f6f6f6);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.placeholder {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
padding: 0 8px;
|
|
55
|
+
height: 30px;
|
|
56
|
+
border-radius: 6px;
|
|
57
|
+
user-select: none;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: background-color 300ms ease-in-out;
|
|
60
|
+
border: 1px solid var(--bit-border-color, #babec9);
|
|
61
|
+
[data-open='true'] & {
|
|
62
|
+
color: var(--bit-accent-color, #6c5ce7);
|
|
63
|
+
}
|
|
64
|
+
> span {
|
|
65
|
+
padding-left: 8px;
|
|
66
|
+
}
|
|
67
|
+
&:hover {
|
|
68
|
+
background-color: var(--bit-bg-heavy, #f6f6f6);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -3,8 +3,11 @@ import { NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
|
3
3
|
import type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';
|
|
4
4
|
import { LaneModel } from '@teambit/lanes.ui.lanes';
|
|
5
5
|
import { ComponentModel } from '../../ui';
|
|
6
|
+
export declare type NavPluginProps = {
|
|
7
|
+
displayName?: string;
|
|
8
|
+
} & NavLinkProps;
|
|
6
9
|
export declare type NavPlugin = {
|
|
7
|
-
props:
|
|
10
|
+
props: NavPluginProps;
|
|
8
11
|
order?: number;
|
|
9
12
|
};
|
|
10
13
|
export declare type OrderedNavigationSlot = SlotRegistry<NavPlugin>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
3
|
-
export declare
|
|
3
|
+
export declare type TopBarNavProps = {} & NavLinkProps;
|
|
4
|
+
export declare function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps): JSX.Element;
|
|
@@ -19,20 +19,20 @@ function _extends2() {
|
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function
|
|
23
|
-
const data = require("@
|
|
22
|
+
function _objectWithoutProperties2() {
|
|
23
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
_objectWithoutProperties2 = function () {
|
|
26
26
|
return data;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
return data;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function
|
|
33
|
-
const data = require("
|
|
32
|
+
function _react() {
|
|
33
|
+
const data = _interopRequireDefault(require("react"));
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
_react = function () {
|
|
36
36
|
return data;
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -49,20 +49,30 @@ function _classnames() {
|
|
|
49
49
|
return data;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function
|
|
53
|
-
const data =
|
|
52
|
+
function _reactRouterDom() {
|
|
53
|
+
const data = require("react-router-dom");
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
_reactRouterDom = function () {
|
|
56
56
|
return data;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
return data;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function
|
|
63
|
-
const data = require("
|
|
62
|
+
function _baseUiRouting() {
|
|
63
|
+
const data = require("@teambit/base-ui.routing.nav-link");
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
_baseUiRouting = function () {
|
|
66
|
+
return data;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function _uiFoundationUiReactRouter() {
|
|
73
|
+
const data = require("@teambit/ui-foundation.ui.react-router.extend-path");
|
|
74
|
+
|
|
75
|
+
_uiFoundationUiReactRouter = function () {
|
|
66
76
|
return data;
|
|
67
77
|
};
|
|
68
78
|
|
|
@@ -79,7 +89,14 @@ function _topBarNavModule() {
|
|
|
79
89
|
return data;
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
function TopBarNav(
|
|
92
|
+
function TopBarNav(_ref) {
|
|
93
|
+
let {
|
|
94
|
+
href,
|
|
95
|
+
className,
|
|
96
|
+
activeClassName,
|
|
97
|
+
children
|
|
98
|
+
} = _ref,
|
|
99
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["href", "className", "activeClassName", "children"]);
|
|
83
100
|
const {
|
|
84
101
|
url
|
|
85
102
|
} = (0, _reactRouterDom().useRouteMatch)();
|
|
@@ -87,15 +104,12 @@ function TopBarNav(props) {
|
|
|
87
104
|
search
|
|
88
105
|
} = (0, _reactRouterDom().useLocation)(); // sticky query params
|
|
89
106
|
|
|
90
|
-
const {
|
|
91
|
-
href
|
|
92
|
-
} = props;
|
|
93
107
|
const target = `${(0, _uiFoundationUiReactRouter().extendPath)(url, href)}${search}`;
|
|
94
|
-
return /*#__PURE__*/_react().default.createElement(_baseUiRouting().NavLink, (0, _extends2().default)({},
|
|
95
|
-
className: (0, _classnames().default)(
|
|
96
|
-
activeClassName: (0, _classnames().default)(
|
|
108
|
+
return /*#__PURE__*/_react().default.createElement(_baseUiRouting().NavLink, (0, _extends2().default)({}, rest, {
|
|
109
|
+
className: (0, _classnames().default)(className, _topBarNavModule().default.topBarLink),
|
|
110
|
+
activeClassName: (0, _classnames().default)(activeClassName, _topBarNavModule().default.active),
|
|
97
111
|
href: target
|
|
98
|
-
}), /*#__PURE__*/_react().default.createElement("div", null,
|
|
112
|
+
}), /*#__PURE__*/_react().default.createElement("div", null, children));
|
|
99
113
|
}
|
|
100
114
|
|
|
101
115
|
//# sourceMappingURL=top-bar-nav.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["top-bar-nav.tsx"],"names":["TopBarNav","
|
|
1
|
+
{"version":3,"sources":["top-bar-nav.tsx"],"names":["TopBarNav","href","className","activeClassName","children","rest","url","search","target","styles","topBarLink","active"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIO,SAASA,SAAT,OAA4F;AAAA,MAAzE;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,SAAR;AAAmBC,IAAAA,eAAnB;AAAoCC,IAAAA;AAApC,GAAyE;AAAA,MAAxBC,IAAwB;AACjG,QAAM;AAAEC,IAAAA;AAAF,MAAU,sCAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,oCAAnB,CAFiG,CAE/D;;AAElC,QAAMC,MAAM,GAAI,GAAE,6CAAWF,GAAX,EAAgBL,IAAhB,CAAsB,GAAEM,MAAO,EAAjD;AAEA,sBACE,+BAAC,wBAAD,+BACMF,IADN;AAEE,IAAA,SAAS,EAAE,2BAAWH,SAAX,EAAsBO,2BAAOC,UAA7B,CAFb;AAGE,IAAA,eAAe,EAAE,2BAAWP,eAAX,EAA4BM,2BAAOE,MAAnC,CAHnB;AAIE,IAAA,IAAI,EAAEH;AAJR,mBAME,4CAAMJ,QAAN,CANF,CADF;AAUD","sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { useRouteMatch, useLocation } from 'react-router-dom';\nimport { NavLink, NavLinkProps } from '@teambit/base-ui.routing.nav-link';\nimport { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';\n\nimport styles from './top-bar-nav.module.scss';\n\nexport type TopBarNavProps = {} & NavLinkProps;\n\nexport function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps) {\n const { url } = useRouteMatch();\n const { search } = useLocation(); // sticky query params\n\n const target = `${extendPath(url, href)}${search}`;\n\n return (\n <NavLink\n {...rest}\n className={classnames(className, styles.topBarLink)}\n activeClassName={classnames(activeClassName, styles.active)}\n href={target}\n >\n <div>{children}</div>\n </NavLink>\n );\n}\n"]}
|
package/dist/ui/use-component.js
CHANGED
|
@@ -46,7 +46,7 @@ function _useComponentQuery() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function useComponent(host, id) {
|
|
49
|
-
var _lanesContext$
|
|
49
|
+
var _lanesContext$viewedL, _lanesContext$viewedL2;
|
|
50
50
|
|
|
51
51
|
const {
|
|
52
52
|
params: {
|
|
@@ -60,9 +60,9 @@ function useComponent(host, id) {
|
|
|
60
60
|
ignoreVersion: true
|
|
61
61
|
})) || componentId;
|
|
62
62
|
if (!targetId) throw new TypeError('useComponent received no component id');
|
|
63
|
-
const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.
|
|
63
|
+
const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.viewedLane; // when on a lane, always fetch all the logs starting from the 'head' version
|
|
64
64
|
|
|
65
|
-
const logHead = lanesContext === null || lanesContext === void 0 ? void 0 : (_lanesContext$
|
|
65
|
+
const logHead = lanesContext === null || lanesContext === void 0 ? void 0 : (_lanesContext$viewedL = lanesContext.viewedLane) === null || _lanesContext$viewedL === void 0 ? void 0 : (_lanesContext$viewedL2 = _lanesContext$viewedL.components.find(component => component.model.id.fullName === targetId)) === null || _lanesContext$viewedL2 === void 0 ? void 0 : _lanesContext$viewedL2.model.id.version;
|
|
66
66
|
const logFilters = currentLane ? {
|
|
67
67
|
log: {
|
|
68
68
|
logHead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["use-component.tsx"],"names":["useComponent","host","id","params","componentId","query","version","get","undefined","lanesContext","targetId","toString","ignoreVersion","TypeError","currentLane","logHead","components","find","component","model","fullName","logFilters","log","withVersion","includes"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAYO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,EAApC,EAAiE;AAAA;;AACtE,QAAM;AACJC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADJ,MAEF,sCAFJ;AAGA,QAAMC,KAAK,GAAG,4CAAd;AACA,QAAMC,OAAO,GAAGD,KAAK,CAACE,GAAN,CAAU,SAAV,KAAwBC,SAAxC;AACA,QAAMC,YAAY,GAAG,iCAArB;AACA,QAAMC,QAAQ,GAAG,CAAAR,EAAE,SAAF,IAAAA,EAAE,WAAF,YAAAA,EAAE,CAAES,QAAJ,CAAa;AAAEC,IAAAA,aAAa,EAAE;AAAjB,GAAb,MAAyCR,WAA1D;AACA,MAAI,CAACM,QAAL,EAAe,MAAM,IAAIG,SAAJ,CAAc,uCAAd,CAAN;AACf,QAAMC,WAAW,GAAGL,YAAH,aAAGA,YAAH,uBAAGA,YAAY,
|
|
1
|
+
{"version":3,"sources":["use-component.tsx"],"names":["useComponent","host","id","params","componentId","query","version","get","undefined","lanesContext","targetId","toString","ignoreVersion","TypeError","currentLane","viewedLane","logHead","components","find","component","model","fullName","logFilters","log","withVersion","includes"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAYO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,EAApC,EAAiE;AAAA;;AACtE,QAAM;AACJC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADJ,MAEF,sCAFJ;AAGA,QAAMC,KAAK,GAAG,4CAAd;AACA,QAAMC,OAAO,GAAGD,KAAK,CAACE,GAAN,CAAU,SAAV,KAAwBC,SAAxC;AACA,QAAMC,YAAY,GAAG,iCAArB;AACA,QAAMC,QAAQ,GAAG,CAAAR,EAAE,SAAF,IAAAA,EAAE,WAAF,YAAAA,EAAE,CAAES,QAAJ,CAAa;AAAEC,IAAAA,aAAa,EAAE;AAAjB,GAAb,MAAyCR,WAA1D;AACA,MAAI,CAACM,QAAL,EAAe,MAAM,IAAIG,SAAJ,CAAc,uCAAd,CAAN;AACf,QAAMC,WAAW,GAAGL,YAAH,aAAGA,YAAH,uBAAGA,YAAY,CAAEM,UAAlC,CATsE,CAUtE;;AACA,QAAMC,OAAO,GAAGP,YAAH,aAAGA,YAAH,gDAAGA,YAAY,CAAEM,UAAjB,oFAAG,sBAA0BE,UAA1B,CAAqCC,IAArC,CAA2CC,SAAD,IAAeA,SAAS,CAACC,KAAV,CAAgBlB,EAAhB,CAAmBmB,QAAnB,KAAgCX,QAAzF,CAAH,2DAAG,uBACZU,KADY,CACNlB,EADM,CACHI,OADb;AAEA,QAAMgB,UAAU,GAAGR,WAAW,GAC1B;AACES,IAAAA,GAAG,EAAE;AACHP,MAAAA;AADG;AADP,GAD0B,GAM1BR,SANJ;AAQA,SAAO,4CAAkBgB,WAAW,CAACd,QAAD,EAAWJ,OAAX,CAA7B,EAAkDL,IAAlD,EAAwDqB,UAAxD,CAAP;AACD;;AAED,SAASE,WAAT,CAAqBtB,EAArB,EAAiCI,OAAjC,EAAmD;AACjD,MAAI,CAACA,OAAL,EAAc,OAAOJ,EAAP;AACd,MAAIA,EAAE,CAACuB,QAAH,CAAY,GAAZ,CAAJ,EAAsB,OAAOvB,EAAP;AACtB,SAAQ,GAAEA,EAAG,IAAGI,OAAQ,EAAxB;AACD","sourcesContent":["import { useRouteMatch } from 'react-router-dom';\nimport { ComponentID } from '@teambit/component-id';\nimport { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\nimport { useComponentQuery } from './use-component-query';\n\nexport type Component = {\n component?: ComponentModel;\n error?: ComponentError;\n componentDescriptor?: ComponentDescriptor;\n};\n\ntype ComponentRoute = {\n componentId?: string;\n};\n\nexport function useComponent(host: string, id?: ComponentID): Component {\n const {\n params: { componentId },\n } = useRouteMatch<ComponentRoute>();\n const query = useQuery();\n const version = query.get('version') || undefined;\n const lanesContext = useLanesContext();\n const targetId = id?.toString({ ignoreVersion: true }) || componentId;\n if (!targetId) throw new TypeError('useComponent received no component id');\n const currentLane = lanesContext?.viewedLane;\n // when on a lane, always fetch all the logs starting from the 'head' version\n const logHead = lanesContext?.viewedLane?.components.find((component) => component.model.id.fullName === targetId)\n ?.model.id.version;\n const logFilters = currentLane\n ? {\n log: {\n logHead,\n },\n }\n : undefined;\n\n return useComponentQuery(withVersion(targetId, version), host, logFilters);\n}\n\nfunction withVersion(id: string, version?: string) {\n if (!version) return id;\n if (id.includes('@')) return id;\n return `${id}@${version}`;\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.695",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "component",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.695"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/any-fs": "0.0.5",
|
|
@@ -26,43 +26,47 @@
|
|
|
26
26
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
|
27
27
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
28
28
|
"@teambit/documenter.ui.separator": "4.1.1",
|
|
29
|
+
"@teambit/base-ui.layout.breakpoints": "1.0.0",
|
|
29
30
|
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
31
|
+
"@teambit/design.elements.icon": "1.0.5",
|
|
32
|
+
"@teambit/design.inputs.dropdown": "0.0.7",
|
|
30
33
|
"@teambit/component-id": "0.0.402",
|
|
31
34
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.488",
|
|
32
|
-
"@teambit/aspect-loader": "0.0.
|
|
35
|
+
"@teambit/aspect-loader": "0.0.695",
|
|
33
36
|
"@teambit/legacy-bit-id": "0.0.399",
|
|
34
37
|
"@teambit/toolbox.string.capitalize": "0.0.483",
|
|
35
|
-
"@teambit/cli": "0.0.
|
|
36
|
-
"@teambit/config": "0.0.
|
|
37
|
-
"@teambit/express": "0.0.
|
|
38
|
-
"@teambit/graphql": "0.0.
|
|
38
|
+
"@teambit/cli": "0.0.464",
|
|
39
|
+
"@teambit/config": "0.0.477",
|
|
40
|
+
"@teambit/express": "0.0.560",
|
|
41
|
+
"@teambit/graphql": "0.0.695",
|
|
39
42
|
"@teambit/bit-error": "0.0.394",
|
|
40
|
-
"@teambit/command-bar": "0.0.
|
|
41
|
-
"@teambit/preview": "0.0.
|
|
42
|
-
"@teambit/pubsub": "0.0.
|
|
43
|
+
"@teambit/command-bar": "0.0.695",
|
|
44
|
+
"@teambit/preview": "0.0.695",
|
|
45
|
+
"@teambit/pubsub": "0.0.695",
|
|
43
46
|
"@teambit/ui-foundation.ui.is-browser": "0.0.486",
|
|
44
47
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.486",
|
|
45
48
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.488",
|
|
46
49
|
"@teambit/ui-foundation.ui.use-box.menu": "0.0.114",
|
|
47
|
-
"@teambit/ui": "0.0.
|
|
48
|
-
"@teambit/component-issues": "0.0.
|
|
50
|
+
"@teambit/ui": "0.0.695",
|
|
51
|
+
"@teambit/component-issues": "0.0.49",
|
|
49
52
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.487",
|
|
50
53
|
"@teambit/cli-table": "0.0.33",
|
|
51
|
-
"@teambit/component-descriptor": "0.0.
|
|
52
|
-
"@teambit/lanes.ui.lanes": "0.0.
|
|
54
|
+
"@teambit/component-descriptor": "0.0.28",
|
|
55
|
+
"@teambit/lanes.ui.lanes": "0.0.29",
|
|
53
56
|
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.486",
|
|
54
|
-
"@teambit/design.ui.pages.not-found": "0.0.354",
|
|
55
|
-
"@teambit/design.ui.pages.server-error": "0.0.354",
|
|
56
57
|
"@teambit/design.ui.empty-box": "0.0.353",
|
|
57
58
|
"@teambit/harmony.ui.aspect-box": "0.0.486",
|
|
58
|
-
"@teambit/
|
|
59
|
-
"@teambit/
|
|
60
|
-
"@teambit/
|
|
59
|
+
"@teambit/design.ui.pages.not-found": "0.0.354",
|
|
60
|
+
"@teambit/design.ui.pages.server-error": "0.0.354",
|
|
61
|
+
"@teambit/compositions": "0.0.695",
|
|
62
|
+
"@teambit/deprecation": "0.0.695",
|
|
63
|
+
"@teambit/envs": "0.0.695",
|
|
61
64
|
"@teambit/legacy-component-log": "0.0.392",
|
|
62
|
-
"@teambit/
|
|
65
|
+
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.486",
|
|
66
|
+
"@teambit/component.ui.version-dropdown": "0.0.514",
|
|
63
67
|
"@teambit/ui-foundation.ui.full-loader": "0.0.486",
|
|
64
68
|
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.114",
|
|
65
|
-
"@teambit/ui-foundation.ui.
|
|
69
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@types/react": "^17.0.8",
|
|
@@ -81,7 +85,7 @@
|
|
|
81
85
|
},
|
|
82
86
|
"peerDependencies": {
|
|
83
87
|
"@apollo/client": "^3.0.0",
|
|
84
|
-
"@teambit/legacy": "1.0.
|
|
88
|
+
"@teambit/legacy": "1.0.242",
|
|
85
89
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
86
90
|
"react": "^16.8.0 || ^17.0.0"
|
|
87
91
|
},
|
|
@@ -109,7 +113,7 @@
|
|
|
109
113
|
"react": "-"
|
|
110
114
|
},
|
|
111
115
|
"peerDependencies": {
|
|
112
|
-
"@teambit/legacy": "1.0.
|
|
116
|
+
"@teambit/legacy": "1.0.242",
|
|
113
117
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
114
118
|
"react": "^16.8.0 || ^17.0.0"
|
|
115
119
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.695/dist/component.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.695/dist/component.docs.mdx')]
|
package/section/section.tsx
CHANGED
package/ui/menu/menu-nav.tsx
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
3
|
import { TopBarNav } from '../top-bar-nav';
|
|
4
4
|
import styles from './menu.module.scss';
|
|
5
5
|
import { NavPlugin, OrderedNavigationSlot } from './nav-plugin';
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export type MenuNavProps = {
|
|
8
|
+
navigationSlot: OrderedNavigationSlot;
|
|
9
|
+
} & React.HTMLAttributes<HTMLElement>;
|
|
10
|
+
|
|
11
|
+
export function MenuNav({ navigationSlot, className }: MenuNavProps) {
|
|
12
|
+
const plugins = useMemo(() => navigationSlot.toArray().sort(sortFn), [navigationSlot]);
|
|
9
13
|
|
|
10
14
|
return (
|
|
11
|
-
<nav className={styles.navigation}>
|
|
12
|
-
{plugins.map(([id, menuItem]) =>
|
|
13
|
-
<TopBarNav key={id} {...menuItem.props}
|
|
14
|
-
)
|
|
15
|
+
<nav className={classnames(styles.navigation, styles.desktopNav, className)}>
|
|
16
|
+
{plugins.map(([id, menuItem]) => {
|
|
17
|
+
return <TopBarNav key={id} {...menuItem.props} />;
|
|
18
|
+
})}
|
|
15
19
|
</nav>
|
|
16
20
|
);
|
|
17
21
|
}
|
package/ui/menu/menu.module.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import '~@teambit/base-ui.layout.breakpoints/_breakpoints.scss';
|
|
2
|
+
|
|
1
3
|
.topBar {
|
|
2
4
|
display: flex;
|
|
3
5
|
justify-content: space-between;
|
|
@@ -13,19 +15,36 @@
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
.navigation {
|
|
16
|
-
display: flex;
|
|
17
18
|
list-style: none;
|
|
18
19
|
height: 100%;
|
|
19
20
|
padding-left: 28px;
|
|
20
|
-
@media screen and (max-width:
|
|
21
|
-
padding-left:
|
|
21
|
+
@media screen and (max-width: $br-md) {
|
|
22
|
+
padding-left: 0;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
li {
|
|
25
26
|
display: block;
|
|
26
27
|
margin-right: 16px;
|
|
27
28
|
height: 100%;
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
// show desktop nav on larger res
|
|
32
|
+
&.desktopNav {
|
|
33
|
+
display: flex;
|
|
34
|
+
@media screen and (max-width: $br-lg) {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// show mobile nav on smaller res
|
|
40
|
+
&.mobileNav {
|
|
41
|
+
align-items: center;
|
|
42
|
+
display: none;
|
|
43
|
+
@media screen and (max-width: $br-lg) {
|
|
44
|
+
display: flex;
|
|
45
|
+
margin-right: 8px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
}
|
|
30
49
|
|
|
31
50
|
.rightSide {
|
|
@@ -38,6 +57,11 @@
|
|
|
38
57
|
margin-right: 16px;
|
|
39
58
|
}
|
|
40
59
|
}
|
|
60
|
+
@media screen and (max-width: $br-lg) {
|
|
61
|
+
> * {
|
|
62
|
+
margin-right: 8px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
41
65
|
.widgets {
|
|
42
66
|
height: 100%;
|
|
43
67
|
margin-right: 20px;
|
|
@@ -51,6 +75,9 @@
|
|
|
51
75
|
}
|
|
52
76
|
}
|
|
53
77
|
}
|
|
78
|
+
@media screen and (max-width: $br-lg) {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
54
81
|
}
|
|
55
82
|
.widget {
|
|
56
83
|
font-size: 17px;
|
package/ui/menu/menu.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { LegacyComponentLog } from '@teambit/legacy-component-log';
|
|
|
13
13
|
import type { ComponentModel } from '../component-model';
|
|
14
14
|
import { useComponent } from '../use-component';
|
|
15
15
|
import { MenuNav } from './menu-nav';
|
|
16
|
+
import { MobileMenuNav } from './mobile-menu-nav';
|
|
16
17
|
import styles from './menu.module.scss';
|
|
17
18
|
import { OrderedNavigationSlot, ConsumeMethodSlot } from './nav-plugin';
|
|
18
19
|
|
|
@@ -46,6 +47,7 @@ export function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot
|
|
|
46
47
|
<div className={classnames(styles.topBar, className)}>
|
|
47
48
|
<div className={styles.leftSide}>
|
|
48
49
|
<MenuNav navigationSlot={navigationSlot} />
|
|
50
|
+
<MobileMenuNav navigationSlot={navigationSlot} widgetSlot={widgetSlot} />
|
|
49
51
|
</div>
|
|
50
52
|
<div className={styles.rightSide}>
|
|
51
53
|
<div className={styles.widgets}>
|
|
@@ -70,7 +72,7 @@ function VersionRelatedDropdowns({
|
|
|
70
72
|
const location = useLocation();
|
|
71
73
|
const isNew = component.tags.isEmpty();
|
|
72
74
|
const lanesContext = useLanesContext();
|
|
73
|
-
const currentLane = lanesContext?.
|
|
75
|
+
const currentLane = lanesContext?.viewedLane;
|
|
74
76
|
const { logs } = component;
|
|
75
77
|
const isWorkspace = host === 'teambit.workspace/workspace';
|
|
76
78
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
+
@import '~@teambit/base-ui.layout.breakpoints/_breakpoints.scss';
|
|
3
|
+
|
|
4
|
+
.mobileMenuLink {
|
|
5
|
+
margin: 0;
|
|
6
|
+
transition: background-color 300ms ease-in-out;
|
|
7
|
+
&:hover {
|
|
8
|
+
background-color: var(--bit-bg-heavy);
|
|
9
|
+
}
|
|
10
|
+
@media screen and (max-width: $br-md) {
|
|
11
|
+
height: 40px;
|
|
12
|
+
font-size: 16px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.mobileMenu {
|
|
17
|
+
> nav {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
.active {
|
|
22
|
+
background-color: var(--bit-accent-bg, #eceaff);
|
|
23
|
+
color: inherit;
|
|
24
|
+
&:after {
|
|
25
|
+
background-color: unset;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.close {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
@media screen and (max-width: $br-md) {
|
|
32
|
+
position: fixed;
|
|
33
|
+
top: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
padding: 0;
|
|
38
|
+
z-index: $modal-z-index;
|
|
39
|
+
.close {
|
|
40
|
+
align-self: self-end;
|
|
41
|
+
padding: 8px;
|
|
42
|
+
display: flex;
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: var(--bit-bg-heavy, #f6f6f6);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.placeholder {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
padding: 0 8px;
|
|
55
|
+
height: 30px;
|
|
56
|
+
border-radius: 6px;
|
|
57
|
+
user-select: none;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: background-color 300ms ease-in-out;
|
|
60
|
+
border: 1px solid var(--bit-border-color, #babec9);
|
|
61
|
+
[data-open='true'] & {
|
|
62
|
+
color: var(--bit-accent-color, #6c5ce7);
|
|
63
|
+
}
|
|
64
|
+
> span {
|
|
65
|
+
padding-left: 8px;
|
|
66
|
+
}
|
|
67
|
+
&:hover {
|
|
68
|
+
background-color: var(--bit-bg-heavy, #f6f6f6);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Switch, Route, useRouteMatch } from 'react-router-dom';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Icon } from '@teambit/design.elements.icon';
|
|
5
|
+
import { Dropdown } from '@teambit/design.inputs.dropdown';
|
|
6
|
+
import { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';
|
|
7
|
+
import { TopBarNav } from '../top-bar-nav';
|
|
8
|
+
import styles from './menu.module.scss';
|
|
9
|
+
import mobileStyles from './mobile-menu-nav.module.scss';
|
|
10
|
+
import { NavPlugin, OrderedNavigationSlot } from './nav-plugin';
|
|
11
|
+
|
|
12
|
+
export function MobileMenuNav({
|
|
13
|
+
navigationSlot,
|
|
14
|
+
widgetSlot,
|
|
15
|
+
className,
|
|
16
|
+
}: {
|
|
17
|
+
navigationSlot: OrderedNavigationSlot;
|
|
18
|
+
widgetSlot: OrderedNavigationSlot;
|
|
19
|
+
className?: string;
|
|
20
|
+
}) {
|
|
21
|
+
const { url } = useRouteMatch();
|
|
22
|
+
const totalSlots = useMemo(
|
|
23
|
+
() => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)],
|
|
24
|
+
[navigationSlot, widgetSlot]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Dropdown
|
|
29
|
+
// @ts-ignore - mismatch between @types/react
|
|
30
|
+
placeholder={<Placeholder slots={totalSlots} baseUrl={url} />}
|
|
31
|
+
className={classnames(styles.navigation, styles.mobileNav, className)}
|
|
32
|
+
dropClass={mobileStyles.mobileMenu}
|
|
33
|
+
>
|
|
34
|
+
<nav>
|
|
35
|
+
<Icon of="x-thick" className={mobileStyles.close} />
|
|
36
|
+
{totalSlots.map(([id, menuItem]) => {
|
|
37
|
+
return (
|
|
38
|
+
<TopBarNav
|
|
39
|
+
key={id}
|
|
40
|
+
{...menuItem.props}
|
|
41
|
+
className={mobileStyles.mobileMenuLink}
|
|
42
|
+
activeClassName={mobileStyles.active}
|
|
43
|
+
>
|
|
44
|
+
{typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName}
|
|
45
|
+
</TopBarNav>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
</nav>
|
|
49
|
+
</Dropdown>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function sortFn([, { order: first }]: [string, NavPlugin], [, { order: second }]: [string, NavPlugin]) {
|
|
54
|
+
// 0 - equal
|
|
55
|
+
// <0 - first < second
|
|
56
|
+
// >0 - first > second
|
|
57
|
+
|
|
58
|
+
return (first ?? 0) - (second ?? 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type PlaceholderProps = {
|
|
62
|
+
slots: [string, NavPlugin][];
|
|
63
|
+
baseUrl?: string;
|
|
64
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
65
|
+
|
|
66
|
+
function Placeholder({ slots, baseUrl = '', ...rest }: PlaceholderProps) {
|
|
67
|
+
return (
|
|
68
|
+
<div {...rest} className={mobileStyles.placeholder}>
|
|
69
|
+
<Switch>
|
|
70
|
+
{slots?.map(([id, menuItem]) => {
|
|
71
|
+
const path = extendPath(baseUrl, menuItem?.props?.href);
|
|
72
|
+
return (
|
|
73
|
+
<Route key={id} exact path={path}>
|
|
74
|
+
{typeof menuItem?.props?.children === 'string' ? menuItem?.props?.children : menuItem?.props?.displayName}
|
|
75
|
+
</Route>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</Switch>
|
|
79
|
+
<Icon of="fat-arrow-down" />
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
package/ui/menu/nav-plugin.tsx
CHANGED
|
@@ -5,8 +5,12 @@ import type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';
|
|
|
5
5
|
import { LaneModel } from '@teambit/lanes.ui.lanes';
|
|
6
6
|
import { ComponentModel } from '../../ui';
|
|
7
7
|
|
|
8
|
+
export type NavPluginProps = {
|
|
9
|
+
displayName?: string;
|
|
10
|
+
} & NavLinkProps;
|
|
11
|
+
|
|
8
12
|
export type NavPlugin = {
|
|
9
|
-
props:
|
|
13
|
+
props: NavPluginProps;
|
|
10
14
|
order?: number;
|
|
11
15
|
};
|
|
12
16
|
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { NavLink, NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
2
|
-
import { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
1
|
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
5
3
|
import { useRouteMatch, useLocation } from 'react-router-dom';
|
|
4
|
+
import { NavLink, NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
5
|
+
import { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';
|
|
6
6
|
|
|
7
7
|
import styles from './top-bar-nav.module.scss';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export type TopBarNavProps = {} & NavLinkProps;
|
|
10
|
+
|
|
11
|
+
export function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps) {
|
|
10
12
|
const { url } = useRouteMatch();
|
|
11
13
|
const { search } = useLocation(); // sticky query params
|
|
12
|
-
const { href } = props;
|
|
13
14
|
|
|
14
15
|
const target = `${extendPath(url, href)}${search}`;
|
|
15
16
|
|
|
16
17
|
return (
|
|
17
18
|
<NavLink
|
|
18
|
-
{...
|
|
19
|
-
className={classnames(
|
|
20
|
-
activeClassName={classnames(
|
|
19
|
+
{...rest}
|
|
20
|
+
className={classnames(className, styles.topBarLink)}
|
|
21
|
+
activeClassName={classnames(activeClassName, styles.active)}
|
|
21
22
|
href={target}
|
|
22
23
|
>
|
|
23
|
-
<div>{
|
|
24
|
+
<div>{children}</div>
|
|
24
25
|
</NavLink>
|
|
25
26
|
);
|
|
26
27
|
}
|
package/ui/use-component.tsx
CHANGED
|
@@ -26,9 +26,9 @@ export function useComponent(host: string, id?: ComponentID): Component {
|
|
|
26
26
|
const lanesContext = useLanesContext();
|
|
27
27
|
const targetId = id?.toString({ ignoreVersion: true }) || componentId;
|
|
28
28
|
if (!targetId) throw new TypeError('useComponent received no component id');
|
|
29
|
-
const currentLane = lanesContext?.
|
|
29
|
+
const currentLane = lanesContext?.viewedLane;
|
|
30
30
|
// when on a lane, always fetch all the logs starting from the 'head' version
|
|
31
|
-
const logHead = lanesContext?.
|
|
31
|
+
const logHead = lanesContext?.viewedLane?.components.find((component) => component.model.id.fullName === targetId)
|
|
32
32
|
?.model.id.version;
|
|
33
33
|
const logFilters = currentLane
|
|
34
34
|
? {
|
|
Binary file
|