Commit f32774ac authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[NgramsTree] some styling fixes to context menu

parent d6aa4382
.context-menu { .context-menu {
display: block; position : absolute;
position: fixed; left : 96px;
z-index: 9999; top:-64px;
background: #fff; background-color: white;
border: 1px solid #000; z-index: 1000;
border-radius: 3px;
padding: 0;
} }
.context-menu-items { .context-menu a.list-group-item {
display: block; cursor: pointer;
position: relative;
margin: 0;
padding: 0;
}
.context-menu-item {
display: block;
margin: 10px;
text-align: center;
margin: 0;
padding: 0;
cursor: pointer;
}
.context-menu-item a {
display: block;
padding: 10px 20px;
text-align: center;
font-size: 16px;
height: 100%;
} }
.search-bar-container { .search-bar-container {
margin-top: 11px; margin-top: 11px;
text-align: center; text-align: center;
......
...@@ -50,5 +50,5 @@ addToList {menuType, setList} t = Just $ CM.contextMenuItem [ link ] ...@@ -50,5 +50,5 @@ addToList {menuType, setList} t = Just $ CM.contextMenuItem [ link ]
link = HTML.a { onClick: click, className: className } [ HTML.text (label menuType) ] link = HTML.a { onClick: click, className: className } [ HTML.text (label menuType) ]
label NewNgram = "Add to " <> termListName t label NewNgram = "Add to " <> termListName t
label SetTermListItem = "Change to" <> termListName t label SetTermListItem = "Change to" <> termListName t
className = termClass t className = "list-group-item " <> (termClass t)
click = mkEffectFn1 $ \_ -> setList t click = mkEffectFn1 $ \_ -> setList t
...@@ -19,7 +19,7 @@ import DOM.Simple.Document as Document ...@@ -19,7 +19,7 @@ import DOM.Simple.Document as Document
import DOM.Simple.Types ( DOMRect ) import DOM.Simple.Types ( DOMRect )
import Effect (Effect) import Effect (Effect)
import Effect.Uncurried ( mkEffectFn1 ) import Effect.Uncurried ( mkEffectFn1 )
import FFI.Simple ( (...), (..), delay ) import FFI.Simple ( (...), (..), (.=), delay )
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as HTML import Reactix.DOM.HTML as HTML
import Reactix.SyntheticEvent as E import Reactix.SyntheticEvent as E
...@@ -47,10 +47,17 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt ...@@ -47,10 +47,17 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
(toMaybe $ R.readRef root) (toMaybe $ R.readRef root)
pure $ \_ -> pure unit pure $ \_ -> pure unit
R.useLayoutEffect2 root rect (contextMenuEffect menu.setMenu root) R.useLayoutEffect2 root rect (contextMenuEffect menu.setMenu root)
let cs = [ HTML.ul { className: "context-menu-items" } children ] let cs = [
HTML.div { className: "popover-content" }
[ HTML.div { className: "panel panel-default" }
[ HTML.ul { className: "list-group" }
children
]
]
]
pure $ R.createPortal [ elems root menu rect $ cs ] host pure $ R.createPortal [ elems root menu rect $ cs ] host
elems ref menu (Just rect) = HTML.nav { ref , className: "context-menu", style: position menu rect} elems ref menu (Just rect) = HTML.div (({ ref , className: "context-menu", style: position menu rect} .= "data-toggle" $ "popover") .= "data-placement" $ "right")
elems ref _ _ = HTML.nav { ref, className: "context-menu" } elems ref _ _ = HTML.div (({ ref, className: "context-menu" } .= "data-toggle" $ "popover") .= "data-placement" $ "right")
contextMenuEffect contextMenuEffect
:: forall t :: forall t
...@@ -68,7 +75,7 @@ contextMenuEffect setMenu rootRef _ = ...@@ -68,7 +75,7 @@ contextMenuEffect setMenu rootRef _ =
DOM.removeEventListener document "click" onClick DOM.removeEventListener document "click" onClick
DOM.removeEventListener document "scroll" onScroll DOM.removeEventListener document "scroll" onScroll
Nothing -> pure $ \_ -> pure unit Nothing -> pure $ \_ -> pure unit
documentClickHandler :: forall t. (Maybe t -> Effect Unit) -> DOM.Element -> Callback DE.MouseEvent documentClickHandler :: forall t. (Maybe t -> Effect Unit) -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler hide menu = documentClickHandler hide menu =
R2.named "hideMenuOnClickOutside" $ callback $ \e -> R2.named "hideMenuOnClickOutside" $ callback $ \e ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment