bobflux-monitor
Version:
Component for time travelling in bobflux/fun-model application state history.
64 lines (55 loc) • 1.76 kB
text/typescript
import * as b from 'bobril';
import button from './button';
const rowStyle = b.styleDef({
width: 194,
backgroundColor: '#ccc',
borderBottomStyle: 'solid',
borderBottomWidth: 2
});
const active = b.styleDef({
backgroundColor: '#999',
borderColor: '#6699FF',
borderStyle: 'solid',
borderWidth: 3
});
const inActive = b.styleDef({
borderColor: '#ccc',
borderWidth: 2,
borderBottomColor: '#000',
padding: 3
});
const actionButtonsContainer = b.styleDef({});
export interface IRowData {
header: string;
info: string;
frames: number;
isActive: boolean;
onGo: () => void;
onCopy: () => void;
}
interface ICtx extends b.IBobrilCtx {
data: IRowData;
}
export const row = b.createVirtualComponent<IRowData>({
id: 'bobflux-monitor-row',
render(ctx: ICtx, me: b.IBobrilNode) {
me.tag = 'li';
me.children =
b.styledDiv(
b.styledDiv(
[
{ tag: 'div', children: 'Order: ' + ctx.data.header },
{ tag: 'div', children: 'Time: ' + ctx.data.info },
{ tag: 'div', children: 'Frames: ' + ctx.data.frames },
b.styledDiv(
[
button({ title: 'GO', onClick: ctx.data.onGo, float: 'left', width: '50%' }),
button({ title: 'COPY', onClick: ctx.data.onCopy })
],
actionButtonsContainer)
],
ctx.data.isActive ? active : inActive),
rowStyle);
}
});
export default row;