當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript maquette.h函數代碼示例

本文整理匯總了TypeScript中maquette/maquette.h函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript h函數的具體用法?TypeScript h怎麽用?TypeScript h使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了h函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getTabChildVNode

				function getTabChildVNode(tab: TabbedChild): (VNode | string)[] {
					const tabListeners = getTabListeners(tabbed, tab);
					return [
						h('div.tab-label', { onclick: tabListeners.onclickTabListener }, [ tab.state.label ]),
						/* TODO: only show the close when the tab state is closable */
						h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ])
					];
				}
開發者ID:benpope82,項目名稱:widgets,代碼行數:8,代碼來源:createTabbedMixin.ts

示例2: getTabChildVNode

				function getTabChildVNode(tab: TabbedChild): (VNode | string)[] {
					const tabListeners = getTabListeners(tabbed, tab);
					const nodes = [ h('div.tab-label', { onclick: tabListeners.onclickTabListener }, [ tab.state.label ]) ];
					if (tab.state.closeable) {
						nodes.push(h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ]));
					}
					return nodes;
				}
開發者ID:danice,項目名稱:widgets,代碼行數:8,代碼來源:createTabbedMixin.ts

示例3: h

						h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ])
					];
				}

				/* We need to generate a set of VDom the represents the buttons */
				/* TODO: Allow the location of the tab bar to be set (top/left/bottom/right) */
				const tabs: VNode[] = [];
				const childrenNodes: VNode[] = [];
				tabbed.children.forEach((tab, key) => {
					if (tab === activeTab) {
						const activeTabVNode = tab.render();
						activeTabVNode.properties.classes['visible'] = true;
						childrenNodes.push(activeTabVNode);
						tabs.push(h(tabbed.tagNames.tab + '.active', { key: tab }, getTabChildVNode(tab)));
					}
					else {
						/* TODO: Having trouble changing the classes on the subnodes, so once visible always visible,
						 * The only choice was to just omit non visible nodes from the VDom, though I am not sure
						 * this makes a lot of sense, because with a big render, it is a lot of DOM to add and remove
						 */
						tabs.push(h(tabbed.tagNames.tab, { key: tab }, getTabChildVNode(tab)));
					}
				});

				return [ h(tabbed.tagNames.tabBar, tabs), ...childrenNodes ];
			}
		}
	}) as TabbedMixinFactory;

export default createTabbedMixin;
開發者ID:benpope82,項目名稱:widgets,代碼行數:30,代碼來源:createTabbedMixin.ts

示例4: destroy

	Attached = 1,
	Detached
};

interface ProjectorData {
	projector?: MaquetteProjector;
	root?: Element;
	state?: ProjectorState;
	attachHandle?: Handle;
	boundRender?: () => VNode;
}

const projectorDataMap = new WeakMap<Projector, ProjectorData>();

const noopHandle = { destroy() { } };
const emptyVNode = h('div');
const noopVNode = function(): VNode { return emptyVNode; };

export const createProjector: ProjectorFactory = compose<any, ProjectorOptions>({
		getNodeAttributes(overrides?: VNodeProperties): VNodeProperties {
			/* TODO: This is the same logic as createCachedRenderMixin, merge somehow */
			const projector: Projector = this;
			const props: VNodeProperties = {};
			for (let key in projector.listeners) {
				props[key] = projector.listeners[key];
			}
			const classes: { [index: string]: boolean; } = {};
			if (projector.classes) {
				projector.classes.forEach((c) => classes[c] = true);
			}
			props.classes = classes;
開發者ID:kitsonk,項目名稱:widgets,代碼行數:31,代碼來源:projector.ts

示例5: h

						h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ])
					];
				}

				/* We need to generate a set of VDom the represents the buttons */
				/* TODO: Allow the location of the tab bar to be set (top/left/bottom/right) */
				const tabs: VNode[] = [];
				const childrenNodes: VNode[] = [];
				tabbed.children.forEach((tab, key) => {
					if (tab === activeTab) {
						const activeTabVNode = tab.render();
						activeTabVNode.properties.classes['visible'] = true;
						childrenNodes.push(activeTabVNode);
						tabs.push(h(tabbed.tagNames.tab + '.active', { key: tab }, getTabChildVNode(tab)));
					}
					else {
						/* TODO: Having trouble changing the classes on the subnodes, so once visible always visible,
						 * The only choice was to just omit non visible nodes from the VDom, though I am not sure
						 * this makes a lot of sense, because with a big render, it is a lot of DOM to add and remove
						 */
						tabs.push(h(tabbed.tagNames.tab, { key: tab }, getTabChildVNode(tab)));
					}
				});

				return [ h(tabbed.tagNames.tabBar, tabs) ].concat(childrenNodes);
			}
		}
	});

export default createTabbedMixin;
開發者ID:kitsonk,項目名稱:widgets,代碼行數:30,代碼來源:createTabbedMixin.ts

示例6: render

function render(): VNode {
	return h('dojo-panel-tabbed', {
		id: 'tabbed-panel'
	}, [
		h('ul', {}, [
			h('li', { classes: { active: false }, key: panel1 }, [ h('div.tab-label', [ 'tab 1' ]), h('div.tab-close', [ 'X' ]) ]),
			h('li', { classes: { active: closed }, key: panel2 }, [ h('div.tab-label', [ 'tab 2' ]), h('div.tab-close', [ 'X' ]) ]),
			h('li', { classes: { active: false }, key: panel3 }, [ h('div.tab-label', [ 'tab 3' ]), h('div.tab-close', [ 'X' ]) ]),
			closed
				? undefined
				: h('li', { classes: { active: !closed }, key: panel4 }, [ h('div.tab-label', [ 'tab 4' ]), h('div.tab-close', [ 'X' ]) ])
		]),
		h('div.panels', [
			undefined,
			closed
				? h('dojo-panel', { classes: { visible: true }, key: panel2 }, [ h('div#bar', [ 'tab 2' ]) ])
				: undefined,
			undefined,
			closed
				? undefined
				: h('dojo-panel', { classes: { visible: true }, key: panel4 }, [ h('div#bar', [ 'tab 4' ]) ])
		])
	]);
}
開發者ID:novemberborn,項目名稱:widgets,代碼行數:24,代碼來源:scratch.ts

示例7: isRenderable

	parent?: ParentMixin<Renderable>;
}

export type Renderable = Destroyable & RenderableMixin;

export interface RenderableFactory extends ComposeFactory<Renderable, RenderableOptions> { }

export function isRenderable(value: any): value is Renderable {
	return value && typeof value.render === 'function';
}

const createRenderable: RenderableFactory = compose<RenderableMixin, RenderableOptions>({
		render() {
			const renderable: Renderable = this;
			return h(renderable.tagName);
		},

		tagName: 'div'
	}, (instance, options) => {
		if (options) {
			const { tagName, render, parent } = options;
			instance.tagName = tagName || instance.tagName;
			instance.render = render || instance.render;
			if (parent) {
				parent.append(instance);
			}
		}
	})
	.mixin(createDestroyable);
開發者ID:novemberborn,項目名稱:widgets,代碼行數:29,代碼來源:createRenderable.ts

示例8: h

		renderable.render = () => {
			return h('h1', [ 'Greetings' ]);
		};
開發者ID:novemberborn,項目名稱:widgets,代碼行數:3,代碼來源:createRenderable.ts


注:本文中的maquette/maquette.h函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。