UI tweaking and bugfixes

This commit is contained in:
Paul Chiusano 2015-11-26 16:35:42 -05:00
parent 52b16475ab
commit e89804a554
5 changed files with 72 additions and 15 deletions

View File

@ -93,7 +93,7 @@ termEditor term0 = do
(\_ -> f <$> sample (current terms) <*> sample (current paths))
openEvent
Signals.evaluate id infos
explorerTopLeft <- holdDyn (X 0, Y 0) $ (\(X x, Y y, _, Height h) -> (X x, Y $ y + h)) <$> highlightRegion
explorerTopLeft <- holdDyn (X 0, Y 0) $ (\(X x, Y y, _, Height h) -> (X x, Y $ y + h + 20)) <$> highlightRegion
explorerResults <- Signals.offset "explorer-offset" explorerTopLeft . Signals.modal isExplorerOpen (never,never) $
TermExplorer.make node keydown info state paths terms
state' <- Signals.switch' (fst <$> explorerResults)

View File

@ -38,16 +38,19 @@ explorer keydown processQuery topContent s' = do
let extractReq a = case a of Request r _ -> Just r; _ -> Nothing
let validAttrs = "class" =: "explorer valid"
let invalidAttrs = "class" =: "explorer invalid"
let singleAttrs = "class" =: "explorer one-result"
rec
attrs <- holdDyn ("class" =: "explorer") (fmap (\l -> if null l then invalidAttrs else validAttrs) valids)
let pickAttr l = case l of [] -> invalidAttrs; [_] -> singleAttrs; _ -> validAttrs
attrs <- holdDyn ("class" =: "explorer") (fmap pickAttr valids)
(valids, updatedS, closings) <- elDynAttr "div" attrs $ mdo
searchbox <- textInput def
searchbox <- elClass "div" "explorer-textbox" $ textInput def
grabFocus <- Signals.now (Element.elementFocus (_textInput_element searchbox))
_ <- Signals.evaluate id grabFocus
UI.keepKeyEventIf (\i -> i /= 38 && i /= 40) searchbox -- disable up/down inside searchbox
elClass "div" "top-separator" $ pure ()
-- todo, might want to show a spinner or some indicator while we're waiting for results
z <- elClass "div" "top-content" $ widgetHold (pure Nothing) (fmap (fmap Just) topContent)
z <- elClass "div" "top-content" $
widgetHold (elClass "div" "explorer-placeholder" $ pure Nothing) (fmap (fmap Just) topContent)
elClass "div" "top-separator" $ pure ()
actions <- do
t <- Signals.prependDyn "" (_textInput_value searchbox)
processQuery s' z t (current selection)

View File

@ -113,12 +113,12 @@ make node keydown localInfo s paths terms =
push p $ attachDyn txt (updated filtered `Signals.coincides` updated txt)
formatLocalInfo (i@Node.LocalInfo{..}) = i <$ do
name <- Views.lookupSymbol . metadata <$> sample (current s)
let txt doc = text . Text.unpack . Text.concat . Doc.tokens "\n" . Doc.flow $ doc
let width = Dimensions.Width 400
elClass "div" "explorer-local-info" $ do
elClass "div" "localType" $ txt (Views.type' name localType)
elClass "div" "localAdmissibleType" $ txt (Views.type' name localAdmissibleType)
_ <- elClass "div" "localType" $ DocView.view width (Views.type' name localType)
_ <- elClass "div" "localAdmissibleType" $ DocView.view width (Views.type' name localAdmissibleType)
_ <- elClass "div" "localVariables" $
traverse (elClass "div" "localVariable" . txt . Views.term name) localVariables
traverse (elClass "div" "localVariable" . DocView.view width . Views.term name) localVariables
pure ()
in
Explorer.explorer keydown processQuery (fmap formatLocalInfo localInfo) s

View File

@ -25,6 +25,7 @@ body { line-height: 1.3; }
.docwidget {
cursor: default;
z-index: 0;
color: rgb(80,80,80);
font-family: 'fira-code-regular', monospace;
font-size: 12pt;
font-variant-ligatures: common-ligatures;
@ -48,18 +49,70 @@ body { line-height: 1.3; }
animation-timing-function: ease-in-out;
}
.explorer {
background-color: rgba(255,255,255,0.95);
width: 300px;
border-radius: 6px;
border-width: 3px;
border-style: solid;
border-color: rgba(0,0,0,.4);
}
.invalid {
animation-name: invalid-explorer;
animation-delay: 0.15s;
animation-duration: 0.45s;
animation-timing-function: ease-in-out;
}
@keyframes invalid-explorer {
from { border-color: rgba(0,0,0,.4); }
to { border-color: rgba(255,0,0,.7); }
}
.one-result {
border-color: rgba(0,100,75,0.7);
}
.top-separator {
background-color: red;
width: 5px;
height: 5px;
}
.explorer-textbox input {
font-family: 'fira-code-regular', monospace;
font-size: 14pt;
background-color: rgba(0,0,0,0);
width: 95%;
outline: none;
padding-bottom: 5px;
margin: 5px;
border-width: 0px;
border-bottom-width: 1px;
}
.explorer-local-info {
margin-left: 5px;
margin-right: 5px;
margin-bottom: 0px;
}
.explorer-placeholder {
}
.localAdmissibleType {
font-weight: bold;
}
.result {
margin: 5px;
padding: 5px;
}
.invalid-results-item {
padding: 5px;
}
.highlight {
background-color: rgb(100,100,100);
background-color: rgb(235,235,235);
}
div:focus {

View File

@ -192,7 +192,8 @@ unArrows :: Type v -> Maybe [Type v]
unArrows t =
case go t of [] -> Nothing; l -> Just l
where
go (T.Arrow' i o) = i : go o
go (T.Arrow' i o@(T.Arrow' _ _)) = i : go o
go (T.Arrow' i o) = i : [o]
go _ = []
unArrows' :: Type v -> Maybe [(Type v,Path)]