All Projects → jinjor → elm-contextmenu

jinjor / elm-contextmenu

Licence: BSD-3-Clause License
Flexible context menu for Elm

Programming Languages

elm
856 projects

Projects that are alternatives of or similar to elm-contextmenu

ctxmenu
Tiny and customizable context menu generator
Stars: ✭ 20 (+25%)
Mutual labels:  contextmenu, context-menu
rctx-contextmenu
✨ Context menu for React
Stars: ✭ 23 (+43.75%)
Mutual labels:  contextmenu, context-menu
ng2-right-click-menu
Right click context menu for Angular 2+
Stars: ✭ 51 (+218.75%)
Mutual labels:  contextmenu, context-menu
Ngcontextmenu
Handcraft your very own context menus for a richer UX!
Stars: ✭ 81 (+406.25%)
Mutual labels:  contextmenu, context-menu
ShellAnything
ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.
Stars: ✭ 103 (+543.75%)
Mutual labels:  contextmenu, context-menu
ContextMenuSwift
A better version of iOS 13 Context Menu
Stars: ✭ 162 (+912.5%)
Mutual labels:  contextmenu, context-menu
Open in Windows Terminal
No description or website provided.
Stars: ✭ 24 (+50%)
Mutual labels:  contextmenu, context-menu
Context Menu.ios
You can easily add awesome animated context menu to your app.
Stars: ✭ 1,854 (+11487.5%)
Mutual labels:  contextmenu, context-menu
VirusTotalScanner
Scan suspicious applications with over 60 different anti-viruses with a mere two clicks and five seconds!
Stars: ✭ 18 (+12.5%)
Mutual labels:  contextmenu, context-menu
JonContextMenu
A beautiful and minimalist arc menu like the Pinterest one, written in Swift
Stars: ✭ 60 (+275%)
Mutual labels:  contextmenu, context-menu
vue3-context-menu
A very simple context menu component for Vue3 一个简洁美观简单的Vue3右键菜单组件
Stars: ✭ 74 (+362.5%)
Mutual labels:  contextmenu, context-menu
dislash.py
A Python wrapper for discord slash-commands and buttons, designed to extend discord.py.
Stars: ✭ 172 (+975%)
Mutual labels:  context-menu
xMenuTools
Extended context menu tools for Windows
Stars: ✭ 56 (+250%)
Mutual labels:  context-menu
angular2-contextmenu
-Deprecated in favor of ngx-contextmenu- A context menu built with Angular 2 inspired by ui.bootstrap.contextMenu.
Stars: ✭ 68 (+325%)
Mutual labels:  contextmenu
editable-treemenu
a treemenu component which can edit(add/delete/rename) by contextMenu based on vue.js 2.0
Stars: ✭ 24 (+50%)
Mutual labels:  contextmenu
ShellCommand
Customize your context menu. 告别注册表,自定义右键菜单。
Stars: ✭ 64 (+300%)
Mutual labels:  contextmenu
ember-right-click-menu
An easy and flexible addon to add context menus anywhere in your application
Stars: ✭ 14 (-12.5%)
Mutual labels:  context-menu
twtree
a highly customizable tree component for vue 2
Stars: ✭ 27 (+68.75%)
Mutual labels:  contextmenu
Modern-UI-Components-for-VBA
A helper dll for VBA users to design modern UI components. No install required!
Stars: ✭ 139 (+768.75%)
Mutual labels:  contextmenu
vaadin-context-menu
The responsive Web Component for showing context dependent items for any element on the page. Part of the Vaadin components.
Stars: ✭ 26 (+62.5%)
Mutual labels:  context-menu

elm-contextmenu

Flexible context menu for Elm (Demo)

Warning

On the migration from Elm 0.18 to 0.19, the legacy Color type has changed to just a type alias of String like #aaa, rgb(100,100,200). Also, some icon libraries that uses Color type (i.e. FontAwesome, MaterialIcons) cannot be used anymore. So now you need to make a function typed as String -> Int -> Html msg. It should work but I haven't tested yet.

I also think the implementation can be improved using new Browser API, but I cannot spend my time to try it. The styling method can be improved too. I would really appreciate if someone do that. Don't hesitate to fork this package or make your own from scratch! (This article may help.)

How to use

This component works with The Elm Architecture.

1. Model

type alias Model =
  { contextMenu : ContextMenu Context
  , config : ContextMenu.Config
  , message : String
  }

2. Msg

type Msg
  = ContextMenuMsg (ContextMenu.Msg Context)
  | Item Int

3. Initialize

init : Flags -> (Model, Cmd Msg)
init flags =
  let
    (contextMenu, msg) = ContextMenu.init
  in
    ( { contextMenu = contextMenu
      }
    , Cmd.map ContextMenuMsg msg
    )

4. Update

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
  case msg of
    ContextMenuMsg msg ->
      let
        (contextMenu, cmd) =
          ContextMenu.update msg model.contextMenu
      in
        ( { model | contextMenu = contextMenu }
        , Cmd.map ContextMenuMsg cmd
        )

5. Subscribe

subscriptions : Model -> Sub Msg
subscriptions model =
  Sub.map ContextMenuMsg (ContextMenu.subscriptions model.contextMenu)

6. View

view : Model -> Html Msg
view model =
  div
    [ ContextMenu.open ContextMenuMsg "context1" ]
    [ ContextMenu.view
        ContextMenu.defaultConfig
        ContextMenuMsg
        toItemGroups
        toItemGroups model.contextMenu
    ]

toItemGroups : String -> List (List Item)
toItemGroups context =
  if context == "context1" then
    [ [ (ContextMenu.item "Hey", Item 1)
      , (ContextMenu.item "Yo!", Item 2)
      ]
    ]
  else
    []

License

BSD-3-Clause

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].