Skip to content

Commit aad6039

Browse files
authored
Merge pull request #5 from asyndesis/feat/upgrade-deps-styles
className and better style support
2 parents 3b62882 + b7d7d51 commit aad6039

File tree

9 files changed

+10757
-5303
lines changed

9 files changed

+10757
-5303
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ dist-ssr
2424
*.njsproj
2525
*.sln
2626
*.sw?
27+
28+
.npmrc

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@ Then use it in your app:
2121

2222
```jsx
2323
import React from "react";
24-
/* Library comes with some super basic MenuButtons: */
24+
/* Library comes with some super basic MenuButtons. You can import default styles and use them as a starting point.
25+
The example below shows how to use the `classNames` prop to style the menu, popover, and arrow elements with something like Tailwind.*/
2526
import { HighlightMenu, MenuButton } from "react-highlight-menu";
2627

2728
export default function App() {
2829
return (
29-
<div className="app">
30+
<div className="tailwind-menu-example">
3031
<HighlightMenu
31-
target=".app"
32-
allowedPlacements={["top", "bottom"]}
32+
classNames={{
33+
menu: "flex gap-1 p-1",
34+
popover: "bg-white shadow-lg rounded-md border border-gray-200",
35+
arrow: "fill-white",
36+
}}
37+
target=".tailwind-menu-example"
38+
withoutStyles={true}
3339
menu={({ selectedText = "", setClipboard, setMenuOpen }) => (
3440
<>
3541
<MenuButton
42+
className="p-2 rounded-md hover:bg-gray-100 text-gray-700"
3643
title="Copy to clipboard"
3744
icon="clipboard"
3845
onClick={() =>
@@ -41,8 +48,8 @@ export default function App() {
4148
})
4249
}
4350
/>
44-
4551
<MenuButton
52+
className="p-2 rounded-md hover:bg-gray-100 text-gray-700"
4653
title="Search Google"
4754
onClick={() => {
4855
window.open(
@@ -54,12 +61,14 @@ export default function App() {
5461
icon="magnifying-glass"
5562
/>
5663
<MenuButton
64+
className="p-2 rounded-md hover:bg-gray-100 text-gray-700"
5765
title="Close menu"
5866
onClick={() => setMenuOpen(false)}
5967
icon="x-mark"
6068
/>
6169
</>
6270
)}
71+
allowedPlacements={["top", "bottom"]}
6372
/>
6473
</div>
6574
);
@@ -74,3 +83,23 @@ export default function App() {
7483
- **allowedPlacements** - array of allowed placements `-'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end'`
7584
- **offset** - distance in pixels from highlighted words. `10`
7685
- **zIndex** - zIndex of the popover `999999999`
86+
87+
## Customization
88+
89+
- **withoutStyles** - if true, the menu will be only styled with props that help it to function. And we the following classnames can be targeted for styling:
90+
- `.rhm-popover` - for the popover element
91+
- `.rhm-menu` - for the menu element
92+
- `.rhm-button` - for the button element
93+
- `.rhm-arrow` - for the arrow element
94+
- `.rhm-anchor` - for the anchor element
95+
- **classNames** - an object where classnames can be passed to the menu, popover, and arrow elements.
96+
- `menu` - for the menu element
97+
- `popover` - for the popover element
98+
- `arrow` - for the arrow element
99+
100+
## Development
101+
102+
```bash
103+
npm install
104+
npm run dev
105+
```

0 commit comments

Comments
 (0)