Adding center and box, more color options to UI stuff, working on command palette styling
parent
da97f53729
commit
6edf592637
@ -1,61 +1,95 @@
|
|||||||
osState = {
|
osState = {
|
||||||
|
palette = {
|
||||||
query = "",
|
query = "",
|
||||||
focusedPaletteIndex = 0
|
focusedIndex = 0,
|
||||||
|
windowHeight = 400,
|
||||||
|
windowWidth = 600,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
init = {
|
init = {};
|
||||||
test = ""
|
|
||||||
};
|
|
||||||
|
|
||||||
update = state event \ event
|
update = state event \ event
|
||||||
| _ \ state;
|
| _ \ state;
|
||||||
|
|
||||||
listRow = child selected \
|
listRow = config \
|
||||||
Clickable {
|
color = (config.selected | True \ "rgba(255,255,255,0.2)" | False \ "transparent");
|
||||||
event = osState.query := "",
|
|
||||||
|
Clickable {
|
||||||
|
event = config.onClick,
|
||||||
child = Stack {
|
child = Stack {
|
||||||
children = [
|
children = [
|
||||||
Rect { w = 300, h = 40, strokeWidth = 2, strokeColor = "black", color = "pink" }
|
Rect { w = config.w, h = config.h, color = color },
|
||||||
]
|
centerV config.h (
|
||||||
|
Positioned {
|
||||||
|
x = 10,
|
||||||
|
y = 0,
|
||||||
|
child = Text { content = config.child, color = "white" }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
# listRow = child selected \
|
palette = state viewport \
|
||||||
# pre = (selected | True \ "*" | _ \ "");
|
results = take 10 (storeSearch osState.palette.query);
|
||||||
# Text { content = pre & " " & child };
|
|
||||||
|
|
||||||
view = state viewport \
|
state = osState.palette;
|
||||||
_ = debug "focusedPalletIndex" osState.focusedPaletteIndex;
|
|
||||||
|
padding = 0;
|
||||||
Positioned {
|
|
||||||
x = 30,
|
textInputHeight = 40;
|
||||||
y = 30,
|
contentWidth = state.windowWidth - (padding * 2);
|
||||||
child = Column {
|
contentHeight = state.windowHeight - (padding * 2);
|
||||||
gap = 10,
|
listHeight = contentHeight - 40;
|
||||||
children = [
|
|
||||||
textInput {
|
Positioned {
|
||||||
key = "query",
|
x = (viewport.width - state.windowWidth) / 2,
|
||||||
initialValue = osState.query,
|
y = (viewport.height - state.windowHeight) / 2,
|
||||||
initialFocus = True,
|
|
||||||
w = 300,
|
child = Stack {
|
||||||
h = 40,
|
children = [
|
||||||
onChange = text \ osState.query := text,
|
Rect { w = state.windowWidth, h = state.windowHeight, color = "#063351", radius = 0, strokeWidth = 1, strokeColor = "#1A5F80" },
|
||||||
onKeyDown = key \ key
|
Padding {
|
||||||
| ArrowUp \ osState.focusedPaletteIndex := max 0 (osState.focusedPaletteIndex - 1)
|
amount = padding,
|
||||||
| ArrowDown \ osState.focusedPaletteIndex := (osState.focusedPaletteIndex + 1)
|
child = Column {
|
||||||
| _ \ NoOp
|
gap = 0,
|
||||||
},
|
children = [
|
||||||
Clip {
|
textInput {
|
||||||
w = 300,
|
key = "query",
|
||||||
h = 300,
|
initialValue = osState.palette.query,
|
||||||
child = Column {
|
initialFocus = True,
|
||||||
gap = 10,
|
color = "white",
|
||||||
# children = mapWithIndex (t i \ Text { content = str i & " " & t }) (storeSearch osState.query)
|
backgroundColor = "rgba(0,0,0,0.2)",
|
||||||
children = mapWithIndex (t i \ listRow t (osState.focusedPaletteIndex == i)) (storeSearch osState.query)
|
w = contentWidth,
|
||||||
|
h = textInputHeight,
|
||||||
|
onChange = text \ Batch [osState.palette.query := text, osState.palette.focusedIndex := 0],
|
||||||
|
onKeyDown = key \ key
|
||||||
|
| ArrowUp \ osState.palette.focusedIndex := max 0 (osState.palette.focusedIndex - 1)
|
||||||
|
| ArrowDown \ osState.palette.focusedIndex := (osState.palette.focusedIndex + 1)
|
||||||
|
| _ \ NoOp
|
||||||
|
},
|
||||||
|
Clip {
|
||||||
|
w = contentWidth,
|
||||||
|
h = listHeight,
|
||||||
|
child = Column {
|
||||||
|
gap = 1,
|
||||||
|
children = mapWithIndex (t i \ listRow { child = t, w = contentWidth, h = textInputHeight, selected = (osState.palette.focusedIndex == i), onClick = NoOp }) results
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
view = state viewport \
|
||||||
|
Stack {
|
||||||
|
children = [
|
||||||
|
Rect { w = viewport.width, h = viewport.height, color = "#012" },
|
||||||
|
palette state viewport
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
os = { init = init, update = update, view = view }
|
os = { init = init, update = update, view = view }
|
||||||
|
|||||||
Loading…
Reference in New Issue