generated from abelflopes/lerna-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e93a65
commit 3fa7807
Showing
8 changed files
with
136 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import styles from "./styles/menu-item.module.scss"; | ||
import React from "react"; | ||
import React, { useContext } from "react"; | ||
import classNames from "classnames"; | ||
import { MenuContext } from "./context"; | ||
|
||
export interface MenuItemProps extends React.HTMLAttributes<HTMLElement> { | ||
selected?: boolean; | ||
highlighted?: boolean; | ||
skin?: "default" | "primary" | "secondary" | "disabled"; | ||
icon?: NonNullable<React.ReactNode>; | ||
disabled?: boolean; | ||
} | ||
|
||
export const MenuItem = ({ | ||
skin = "default", | ||
icon, | ||
selected, | ||
highlighted, | ||
disabled, | ||
className, | ||
children, | ||
...otherProps | ||
}: Readonly<MenuItemProps>): React.ReactElement => ( | ||
<li | ||
className={classNames( | ||
styles.root, | ||
{ | ||
[`${styles.disabled}`]: disabled, | ||
[`${styles.selected}`]: selected, | ||
[`${styles.highlighted}`]: highlighted, | ||
}, | ||
className, | ||
)} | ||
{...otherProps}> | ||
{icon} | ||
{children} | ||
</li> | ||
); | ||
}: Readonly<MenuItemProps>): React.ReactElement => { | ||
const menuContext = useContext(MenuContext); | ||
|
||
return ( | ||
<li | ||
className={classNames( | ||
styles.root, | ||
skin !== "default" && styles[skin], | ||
styles[menuContext.variation], | ||
className, | ||
)} | ||
{...otherProps}> | ||
{icon} | ||
{children} | ||
</li> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
export interface MenuContextProps { | ||
variation: "vertical" | "horizontal"; | ||
} | ||
|
||
export const menuContextDefaults: MenuContextProps = { | ||
variation: "vertical", | ||
}; | ||
|
||
export const MenuContext = React.createContext<MenuContextProps>(menuContextDefaults); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters