Layout & Global Menus
Micro frontend
If you are working on a micro frontend application, the page layout and the menus will be provided by the shell app and you do not need to use these components.
Installation
- yarn
- pnpm
- npm
yarn add @mercell/global-menu-react
pnpm add @mercell/global-menu-react
npm install --save @mercell/global-menu-react
The GlobalMenu has necessary peerDependencies, please make sure that you have them in your project
"@carbon/icons-react": "^10.49.0",
"@mercell/button-react": "^5.0.0",
"@mercell/dropdown-menu-react": "^6.0.0",
"@mercell/language-selector-react": "^3.0.1",
"@mercell/tailwind": "^6.0.1",
"@mercell/tooltip-react": "^5.0.2",
"classnames": "^2.3.1",
"react": "^17.0.2"
Usage
Include the line below to import the components from the global-menu-react:
import {
CompanyMenu,
GlobalMenu,
Sidebar,
UserMenu,
GridWrapper,
SidebarContainer,
MainContent
} from '@mercell/global-menu-react';
If you are working on a stand alone application:
Below is a simplified example of how you can create a page layout that aligns with the structure of the design system's layout using the menu-components from @mercell/global-menu-react
together with the grid layout styling (css-grid) from @mercell/tailwind
.
We cannot show the component since Docusaurus documentation is using react-router v5 and our components are using v6. We want to apologize for the inconvenience.
const LayoutWrapper = () => {
const navigationData: NavigationData = {
home: {
title: 'Home',
Icon: Home24,
path: '',
},
tenders: {
title: 'Tenders',
Icon: Search24,
path: '',
},
documents: {
title: 'Documents',
Icon: Document24,
path: '',
},
};
const [userIsLoggedIn, setUserIsLoggedIn] = React.useState(false);
const [showSidebar, setShowSidebar] = React.useState(false);
// Custom Mercell logo example, uncomment this line - 'logoProps={customImgProps}' in the GlobalMenu if you want to try it out
const customImgProps = {
src: 'https://cdn.mercell.com/logos/Mercell_Logo_square_rgb_dark.svg',
alt: 'Custom Mercell logo',
width: 70,
height: 20,
};
return (
<Router>
<GridWrapper>
<GlobalMenu
logoPath='/'
// logoProps={customImgProps}
isAuthenticated={userIsLoggedIn}
openSidebarOnMobile={setShowSidebar}
>
{userIsLoggedIn && (
<CompanyMenu
companyName="Mercell"
companyMenuText="My company (not implemented yet)"
/>
)}
<UserMenu
profileText="My profile (not implemented yet)"
loginText="Log in"
logoutText="Log out"
isAuthenticated={userIsLoggedIn}
userNickname="Ola"
login={() =>
new Promise<void>((resolve) => {
setUserIsLoggedIn(true);
resolve();
})
}
logout={() => setUserIsLoggedIn(false)}
/>
</GlobalMenu>
<SidebarContainer>
{userIsLoggedIn && (
<Sidebar
logoPath="/"
navigationData={navigationData}
showSidebar={showSidebar}
openSidebarOnMobile={setShowSidebar}
/>
)}
</SidebarContainer>
<MainContent>
<Routes>
<Route
path="/"
element={
<p className="col-span-full">
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Sed at dignissim justo. Proin
auctor lorem ut dui scelerisque dictum.
Vestibulum vel leo ac tellus tempor iaculis eu
interdum justo. Duis at ligula id dolor suscipit
accumsan. Morbi egestas ex sed sem posuere
dignissim. Cras facilisis pharetra nibh, non
tempor elit malesuada non. Mauris cursus sed
lectus id malesuada. Mauris dictum non eros ut
gravida. Etiam mauris nisi, sodales elementum
laoreet tempor, accumsan quis nisi. Pellentesque
quis magna ornare, blandit ipsum at, rutrum
sapien. Pellentesque tempor ligula sodales nisi
tempor, ac pharetra lacus molestie. Nam sed erat
ex. Fusce nec ligula auctor, viverra risus id,
dictum nisl. Phasellus tincidunt laoreet mauris.
Mauris eget iaculis enim. Integer scelerisque eu
leo id commodo. Fusce maximus luctus tellus, sit
amet cursus elit condimentum elementum.
Curabitur odio justo, venenatis consequat sapien
eget, interdum venenatis ligula. Nullam nec eros
non dolor luctus dictum. Praesent dui nibh,
cursus sit amet enim a, suscipit sollicitudin
tortor. Proin hendrerit magna sit amet enim
cursus interdum. Donec porttitor sagittis
malesuada. Quisque sit amet ipsum convallis,
vehicula velit sed, dignissim arcu. Maecenas
maximus aliquet eros, vitae hendrerit turpis
convallis id. Curabitur mattis sapien sit amet
dictum pharetra. Mauris sodales justo eros, id
posuere orci semper non. Curabitur venenatis
ante in ullamcorper aliquam. Sed sagittis
tincidunt lobortis. Proin nec sollicitudin nisi.
Suspendisse ac lorem metus. Morbi facilisis
mauris et nibh bibendum congue. Donec in ipsum
id urna eleifend vehicula mattis nec ante.
Curabitur iaculis, metus ac imperdiet tristique,
ex nulla rutrum tellus, nec mattis turpis odio
vel lacus. Sed auctor pretium erat quis
facilisis.
</p>
}
/>
</MainContent>
</div>
</Router>
Types, Figma
- Types
- Changelog
- Figma
GlobalMenuProps
type GlobalMenuProps = {
logoPath: string;
isAuthenticated: boolean;
openSidebarOnMobile?: (isSidebarOpen: boolean) => void;
logoProps?: JSX.IntrinsicElements['img']; //allows you to add/change props of the logo img tag (src, alt, width, height, className)
trackingAction?: TrackingActionType;
additionalTrackingParams?: Record<string, string | string[]>;
children: ReactNode;
className: string;
};
CompanyMenuProps
type CompanyMenuProps = {
companyName: string;
companyMenuText: string;
};
UserMenuProps
type UserMenuProps = {
profileText: string;
loginText: string;
logoutText: string;
isAuthenticated: boolean;
userNickname: string;
logout: () => void;
login: () => Promise<void>;
dropdownItems?: DropdownItem[];
dropdownExternalItems?: DropdownItem[];
trackingAction?: TrackingActionType;
additionalTrackingParams?: Record<string, string | string[]>;
};
type DropdownItem = {
title: string;
path: string;
ariaLabel?: string;
};
SidebarProps
type SidebarProps = {
navigationData: NavigationData;
showSidebar: boolean;
logoPath: string;
openSidebarOnMobile: (isSidebarOpen: boolean) => void;
trackingAction?: TrackingActionType;
additionalTrackingParams?: Record<string, string | string[]>;
};
NavigationData
type NavigationData = {
[key: string]: NavigationItem;
};
NavigationItem
type NavigationItem = {
title: string;
Icon: CarbonIconType;
path: string;
};
Change Log - @mercell/global-menu-react
This log was last generated on Mon, 30 Jan 2023 15:41:57 GMT and should not be manually modified.
5.1.0
Mon, 30 Jan 2023 15:41:57 GMT
Minor changes
- enable classname as prop to globalmenu component
5.0.2
Mon, 05 Dec 2022 14:56:05 GMT
Patches
- Export MainContent component to wrap content in global grid structure
5.0.1
Mon, 14 Nov 2022 11:48:36 GMT
Patches
- Add SidebarContainer to wrap sidebar with classNames necessary to work regarding the design
5.0.0
Fri, 11 Nov 2022 09:18:57 GMT
Breaking changes
- New styling approach - use only tailwind classes, add tailwind-merge library
4.1.0
Fri, 16 Sep 2022 08:14:10 GMT
Minor changes
- Migration to react router 6
4.0.1
Thu, 15 Sep 2022 10:25:51 GMT
Patches
- Fix global menu burger button regarding recent changes in outside-click-hook
4.0.0
Thu, 15 Sep 2022 06:07:41 GMT
Breaking changes
- Migration to Tailwind3, React 18 and ViteJS from webpack.
3.4.15
Wed, 07 Sep 2022 08:33:00 GMT
Patches
- UserMenu: highlight the user menu button when the dropdown is open"
3.4.14
Thu, 01 Sep 2022 08:16:05 GMT
Patches
- don't highlight any items in the sidebar when the current path is not in the navigationData, higlight the UserMenu button when user is on mypage
3.4.13
Thu, 14 Jul 2022 13:28:46 GMT
Patches
- Updated hover state to remove sticky hover on mobile
3.4.12
Tue, 12 Jul 2022 10:42:52 GMT
Patches
- Adjustment of component to use new version of outsideClickHook
3.4.11
Tue, 05 Jul 2022 11:30:26 GMT
Patches
- fix the opacity of the tooltip in the sidebar menu
3.4.10
Thu, 30 Jun 2022 10:57:49 GMT
Patches
- Fix typings
- Package.json refactor, add test suite, more tests soon
3.4.9
Thu, 23 Jun 2022 08:38:00 GMT
Patches
- Sidebar update to use english version of title in tracking context action and text
3.4.8
Wed, 22 Jun 2022 10:35:53 GMT
Patches
- Fix user menu dropdown items split and lowerCase method invoke
3.4.7
Wed, 22 Jun 2022 09:57:29 GMT
Patches
- Add missing tracking param into dropdown item in user menu
3.4.6
Wed, 22 Jun 2022 08:30:02 GMT
Patches
- Adjustment in UserMenu regarding action_context param for tracking
3.4.5
Thu, 16 Jun 2022 09:31:06 GMT
Patches
- Update sidebar keys for construction menu, fix for title lowerCase method in user menu
3.4.4
Wed, 15 Jun 2022 15:57:11 GMT
Patches
- Update example in dev folder
3.4.3
Wed, 15 Jun 2022 15:28:54 GMT
Patches
- Manual package bump - tracking action update
3.4.2
Wed, 15 Jun 2022 15:10:09 GMT
Patches
- Add updated version of tracking PoC to the component
3.4.1
Mon, 13 Jun 2022 09:20:15 GMT
Patches
- Add tracking PoC to the component
3.4.0
Fri, 03 Jun 2022 13:29:59 GMT
Minor changes
- GlobalMenu: The
logoImgUrl
property is replaced with another optional propertylogoProps
that allows you to add/change properties on the logo img tag
3.3.7
Tue, 31 May 2022 13:50:18 GMT
Patches
- smaller login button
3.3.6
Fri, 06 May 2022 11:01:34 GMT
Patches
- Add possibility to hide burger menu if teams are not using sidebar, add property to pass url of logo to header
3.3.5
Tue, 03 May 2022 10:38:35 GMT
Patches
- Adjustment regarding new dropdown
3.3.4
Wed, 20 Apr 2022 08:31:19 GMT
Patches
- fix li keys in the UserMenu
3.3.3
Fri, 08 Apr 2022 10:19:50 GMT
Patches
- Bump dependencies
3.3.2
Tue, 05 Apr 2022 09:01:16 GMT
Patches
- fix logout button - the whole button area is clickable now
- menu buttons -fixed focus/clickable area
3.3.1
Thu, 10 Mar 2022 16:02:45 GMT
Patches
- sidebar bugfix
3.3.0
Tue, 08 Mar 2022 11:26:42 GMT
Minor changes
- fix sidebar styling(mobile view), close on click outside/navigation to another page
3.2.0
Mon, 07 Mar 2022 09:46:58 GMT
Minor changes
- Added mobile and tablet friendly menu
3.1.6
Tue, 01 Mar 2022 11:32:03 GMT
Patches
- global-menu changes styling on scroll, UserMenu takes optional dropdaown menu items, GlobalMenu cleanup - remove placeholders
- sidebar: z-index:110
3.1.5
Mon, 28 Feb 2022 12:45:49 GMT
Patches
- Dependency update
3.1.4
Mon, 28 Feb 2022 10:55:32 GMT
Patches
- Bump typescript
3.1.3
Wed, 26 Jan 2022 16:19:19 GMT
Patches
- Move dependencies to peerDependencies to avoid duplication in installation process in project
- Adding the same peerDependencies to devDependencies
3.1.2
Fri, 21 Jan 2022 13:08:25 GMT
Patches
- Fix issue with scroll related to the sidebar
3.1.1
Tue, 18 Jan 2022 14:33:13 GMT
Patches
- Breakpoints adjustment
3.1.0
Wed, 12 Jan 2022 14:57:10 GMT
Minor changes
- 1.User menu: random color in the user cicrle, 2.Global menu: added GlobalMenuProps - isAuthenticated: boolean; notifications&messages are hidden if user is not authenticated 3.User/Company menu: name to upper case in the circle
3.0.1
Wed, 05 Jan 2022 13:06:22 GMT
Patches
- new design + added company menu
3.0.0
Wed, 15 Dec 2021 22:20:34 GMT
Breaking changes
- Update to match figma design
2.0.0
Wed, 24 Nov 2021 10:21:16 GMT
Breaking changes
- rename ContextMenu to Sidebar, contextData to navigationData etc.
1.0.2
Thu, 18 Nov 2021 14:00:43 GMT
Version update only
1.0.1
Thu, 18 Nov 2021 13:39:24 GMT
Patches
- Fix for sidebar to match new location outside of its context
1.0.0
Mon, 15 Nov 2021 16:08:43 GMT
Breaking changes
- Language Selector is no longer a part of the global-menu-react, auth props were changed
Patches
- tooltip in the context menu
0.0.7
Fri, 12 Nov 2021 13:08:30 GMT
Patches
- Add @mercell/tailwind to devDeps to be always up to date
0.0.6
Tue, 09 Nov 2021 13:18:28 GMT
Patches
- adjust styling/structure to mfe
0.0.5
Fri, 05 Nov 2021 11:10:13 GMT
Patches
- Bump peerDependency
0.0.4
Thu, 04 Nov 2021 10:10:16 GMT
Patches
- Tailwind type fix
- Revert tailwind version
0.0.3
Wed, 03 Nov 2021 15:28:42 GMT
Patches
- build with tsconfig-tailwind
- react types >=17
0.0.2
Mon, 01 Nov 2021 13:08:34 GMT
Patches
- new global menu/layout component