Skip to content

Commit

Permalink
Add position config for menu popover (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
nowyDEV authored Jun 14, 2023
1 parent 3b2f3a1 commit ebed905
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nordcloud/gnui",
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
"version": "8.6.1",
"version": "8.7.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
8 changes: 3 additions & 5 deletions src/components/navigationBar/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function MenuItem({ caption, icon, children }: MenuItemProps) {
const { expanded, expandedDone, popoverConfig } = useMenuBarConfiguration();

if (children != null) {
const triggerEl = (
const triggerElement = (
<FlexContainer justifyContent={expanded ? "start" : "center"}>
<Trigger expanded={expandedDone} icon={icon} caption={caption} />
</FlexContainer>
Expand All @@ -22,12 +22,10 @@ export function MenuItem({ caption, icon, children }: MenuItemProps) {
return (
<StyledTriggerWrapper>
<ExtendedPopover
trigger={triggerEl}
position="start"
triggerOn={popoverConfig?.triggerOn}
closeOn={popoverConfig?.closeOn}
trigger={triggerElement}
margin={{ left: 20 }}
content={children}
{...popoverConfig}
/>
</StyledTriggerWrapper>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/navigationBar/NavigationBar.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ expandableConfig = {
type PopoverConfig = {
triggerOn: ExtendedPopoverAction,
closeOn: ExtendedPopoverAction,
position: Position,
};
```

Expand All @@ -56,6 +57,7 @@ type PopoverConfig = {
popoverConfig = {
triggerOn: "hover",
closeOn: "hover",
position: "start",
};
```

Expand Down
4 changes: 3 additions & 1 deletion src/components/navigationBar/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from "react";
import { Position } from "../../utils/position";
import { ExtendedPopoverAction } from "../extendedPopover";
import { PathName } from "../svgicon/paths";

Expand Down Expand Up @@ -26,9 +27,10 @@ export type MenuItemProps = {
export type PopoverConfig = {
triggerOn: ExtendedPopoverAction;
closeOn: ExtendedPopoverAction;
position: Position;
};

export type ExpandableConfig = {
timingFunction?: "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out";
timingFunction?: "ease-in-out" | "ease-in" | "ease-out" | "ease" | "linear";
duration?: string;
};
11 changes: 7 additions & 4 deletions src/components/navigationBar/utils/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ type Props = {
popoverConfig?: PopoverConfig;
};

const popoverConfigDefault = {
triggerOn: "hover",
closeOn: "hover",
position: "start",
} as const;

export function NavigationBarProvider({
children,
popoverConfig = {
triggerOn: "hover",
closeOn: "hover",
},
popoverConfig = popoverConfigDefault,
}: Props) {
const { isOpen: expanded, toggle: setExpanded } = useDisclosure();
const {
Expand Down

0 comments on commit ebed905

Please sign in to comment.