0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 00:19:07 -05:00

🎉 Add context-menu component.

Implemented on top of the dropdown component.
This commit is contained in:
Andrey Antukh 2020-03-17 18:12:09 +01:00
parent 376679571c
commit d5f2a1a634

View file

@ -0,0 +1,23 @@
(ns uxbox.main.ui.components.context-menu
(:require
[rumext.alpha :as mf]
[goog.object :as gobj]
[uxbox.main.ui.components.dropdown :refer [dropdown-container]]
[uxbox.util.uuid :as uuid]))
(mf/defrc context-menu
[props]
(assert (fn? (gobj/get props "on-close")) "missing `on-close` prop")
(assert (boolean? (gobj/get props "show")) "missing `show` prop")
(assert (vector? (gobj/get props "options")) "missing `options` prop")
(let [open? (gobj/get props "show")
options (gobj/get props "options")]
(when open?
[:> dropdown-container props
[:div.context-menu {:class (when open? "is-open")}
[:ul.context-menu-items
(for [[action-name action-handler] options]
[:li.context-menu-item {:key action-name}
[:a.context-menu-action {:on-click action-handler}
action-name]])]]])))