Skip to content

Instantly share code, notes, and snippets.

@jwosty
Created January 30, 2020 22:02
Show Gist options
  • Save jwosty/0cb9042dd727dfb589e58c01386099b2 to your computer and use it in GitHub Desktop.
Save jwosty/0cb9042dd727dfb589e58c01386099b2 to your computer and use it in GitHub Desktop.
open System
open Fable
open Fable.Core
open Fable.React
open Fable.Import
type OnMenuSelectArgs = { key: string; item: Component<obj,obj>; domEvent: Browser.Types.Event; selectedKeys: string[] }
type OnMenuClickArgs = { key: string; item: Component<obj,obj>; domEvent: Browser.Types.Event; keyPath: string[] }
type MenuProps =
| ClassName of string
| Mode of string
| ActiveKey of obj
| DefaultActiveFirst of bool
| Multiple of bool
| Selectable of bool
| SelectedKeys of string[]
| DefaultSelectedKeys of string[]
| OpenKeys of string[]
| DefaultOpenKeys of string[]
| OnSelect of (OnMenuSelectArgs -> unit)
| OnClick of (OnMenuClickArgs -> unit)
type MenuItemProps =
| ClassName of string
| Disabled of bool
| Key of obj
| OnMouseEnter of (obj -> unit)
| OnMouseLeave of (obj -> unit)
type SubMenuProps =
| PopupClassName of string
| Title of string
| OverflowedIndicator of string
| Key of obj
| Disabled of bool
| OnMouseEnter of (obj -> unit)
| PopupOffset of float[]
type MenuItemGroupProps =
| Title of string
| Children of ReactElement[]
let inline menu (props: MenuProps seq) children = ofImport "default" "rc-menu" (JsInterop.keyValueList CaseRules.LowerFirst props) children
let inline menuItem (props: MenuItemProps seq) children = ofImport "Item" "rc-menu" (JsInterop.keyValueList CaseRules.LowerFirst props) children
let inline subMenu (props: SubMenuProps seq) children = ofImport "SubMenu" "rc-menu" (JsInterop.keyValueList CaseRules.LowerFirst props) children
let inline divider () = ofImport "Divider" "rc-menu" () []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment