|
|
|
@ -33,7 +33,6 @@ export const _rt = {
|
|
|
|
storeSearch: (query: string) => {
|
|
|
|
storeSearch: (query: string) => {
|
|
|
|
const results: string[] = [];
|
|
|
|
const results: string[] = [];
|
|
|
|
const searchTerm = query.toLowerCase();
|
|
|
|
const searchTerm = query.toLowerCase();
|
|
|
|
console.log("in storeSearch. query: ", searchTerm);
|
|
|
|
|
|
|
|
for (const name of Object.keys(store)) {
|
|
|
|
for (const name of Object.keys(store)) {
|
|
|
|
if (searchTerm === '' || name.toLowerCase().includes(searchTerm)) {
|
|
|
|
if (searchTerm === '' || name.toLowerCase().includes(searchTerm)) {
|
|
|
|
results.push(name);
|
|
|
|
results.push(name);
|
|
|
|
@ -53,4 +52,62 @@ export const _rt = {
|
|
|
|
obj[path[path.length - 1]] = maybeValue;
|
|
|
|
obj[path[path.length - 1]] = maybeValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
measure: (ui: any): { width: number, height: number } => {
|
|
|
|
|
|
|
|
switch (ui._tag) {
|
|
|
|
|
|
|
|
case 'Rect': return { width: ui.w, height: ui.h };
|
|
|
|
|
|
|
|
case 'Text': return { width: ui.content.length * 10, height: 20 }; // TODO
|
|
|
|
|
|
|
|
case 'Clip': return { width: ui.w, height: ui.h };
|
|
|
|
|
|
|
|
case 'Row': {
|
|
|
|
|
|
|
|
let totalWidth = 0;
|
|
|
|
|
|
|
|
let maxHeight = 0;
|
|
|
|
|
|
|
|
for (const child of ui.children) {
|
|
|
|
|
|
|
|
const size = _rt.measure(child);
|
|
|
|
|
|
|
|
totalWidth += size.width;
|
|
|
|
|
|
|
|
maxHeight = Math.max(maxHeight, size.height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
totalWidth += ui.gap * (ui.children.length - 1);
|
|
|
|
|
|
|
|
return { width: totalWidth, height: maxHeight };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'Column': {
|
|
|
|
|
|
|
|
let totalHeight = 0;
|
|
|
|
|
|
|
|
let maxWidth = 0;
|
|
|
|
|
|
|
|
for (const child of ui.children) {
|
|
|
|
|
|
|
|
const size = _rt.measure(child);
|
|
|
|
|
|
|
|
totalHeight += size.height;
|
|
|
|
|
|
|
|
maxWidth = Math.max(maxWidth, size.width);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
totalHeight += ui.gap * (ui.children.length - 1);
|
|
|
|
|
|
|
|
return { width: maxWidth, height: totalHeight };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'Padding': {
|
|
|
|
|
|
|
|
const childSize = _rt.measure(ui.child);
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
width: childSize.width + ui.amount * 2,
|
|
|
|
|
|
|
|
height: childSize.height + ui.amount * 2,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'Stack': {
|
|
|
|
|
|
|
|
let maxWidth = 0;
|
|
|
|
|
|
|
|
let maxHeight = 0;
|
|
|
|
|
|
|
|
for (const child of ui.children) {
|
|
|
|
|
|
|
|
const size = _rt.measure(child);
|
|
|
|
|
|
|
|
maxWidth = Math.max(maxWidth, size.width);
|
|
|
|
|
|
|
|
maxHeight = Math.max(maxHeight, size.height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { width: maxWidth, height: maxHeight };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'Clickable':
|
|
|
|
|
|
|
|
case 'Opacity':
|
|
|
|
|
|
|
|
case 'Positioned':
|
|
|
|
|
|
|
|
return _rt.measure(ui.child);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return { width: 0, height: 0 };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|