Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable inapplicable context menu options
- Loading branch information
1 parent
c9bae5b
commit 68b7cfb
Showing
4 changed files
with
55 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.item { | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
-ms-user-select: none; | ||
-o-user-select: none; | ||
user-select: none; | ||
|
||
cursor: pointer; | ||
margin: 0; | ||
padding: 8px 14px; | ||
} | ||
|
||
.item:hover { | ||
background: #ffefd7; | ||
} | ||
|
||
.disabled { | ||
cursor: default; | ||
color: gray; | ||
} | ||
|
||
.item.disabled:hover { | ||
background: transparent; | ||
} |
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,17 @@ | ||
/** @jsx h */ | ||
import {h} from 'preact'; | ||
import cls from 'classnames'; | ||
import s from './ContextMenuItem.css'; | ||
|
||
function noop() { | ||
return false; | ||
} | ||
|
||
export default function ContextMenuItem({children, disabled, onClick}) { | ||
const className = cls({ | ||
[s.item]: true, | ||
[s.disabled]: disabled | ||
}); | ||
const handler = disabled ? noop : onClick; | ||
return (<li className={className} onClick={handler}>{children}</li>); | ||
} |