-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow adding custom data to menu bar item types (#300)
- Loading branch information
1 parent
7398a5b
commit 9b03316
Showing
3 changed files
with
42 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { MenuBar, type MenuBarItem } from '../../packages/react-components/src/MenuBar.js'; | ||
|
||
const assertType = function <TExpected>(value: TExpected) { | ||
return value; | ||
}; | ||
|
||
type CustomMenuBarItem = MenuBarItem<{ value: string }>; | ||
|
||
const items: CustomMenuBarItem[] = [{ text: 'View', value: 'view' }]; | ||
|
||
<MenuBar | ||
items={items} | ||
onItemSelected={(e) => { | ||
// Event item type should be inferred from items | ||
assertType<CustomMenuBarItem>(e.detail.value); | ||
}} | ||
/>; |
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