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:
parent
376679571c
commit
d5f2a1a634
1 changed files with 23 additions and 0 deletions
23
frontend/src/uxbox/main/ui/components/context_menu.cljs
Normal file
23
frontend/src/uxbox/main/ui/components/context_menu.cljs
Normal 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]])]]])))
|
Loading…
Add table
Reference in a new issue