当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript virtualdom.h类代码示例

本文整理汇总了TypeScript中@phosphor/virtualdom.h的典型用法代码示例。如果您正苦于以下问题:TypeScript h类的具体用法?TypeScript h怎么用?TypeScript h使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了h类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should update the text of a text node', () => {
   let host = document.createElement('div');
   VirtualDOM.render(h.div('foo'), host);
   let div = host.children[0];
   expect(div.textContent).to.equal('foo');
   VirtualDOM.render(h.div('bar'), host);
   expect(host.children[0]).to.equal(div);
   expect(div.textContent).to.equal('bar');
 });
开发者ID:afshin,项目名称:phosphor,代码行数:9,代码来源:index.spec.ts

示例2: it

      it('should connect a node to a command', () => {
        let called = false;
        const command = 'commandlinker:connect-node';
        const commands = new CommandRegistry();
        const linker = new CommandLinker({ commands });
        let node: HTMLElement;
        let vnode: VirtualNode;
        const disposable = commands.addCommand(command, {
          execute: () => {
            called = true;
          }
        });

        vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
        node = VirtualDOM.realize(vnode);
        document.body.appendChild(node);

        expect(called).to.equal(false);
        simulate(node, 'click');
        expect(called).to.equal(true);

        document.body.removeChild(node);
        linker.dispose();
        disposable.dispose();
      });
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:25,代码来源:commandlinker.spec.ts

示例3: render

  /**
   * Render the landing plugin to virtual DOM nodes.
   */
  protected render(): VirtualNode {
    let activitiesList: VirtualNode[] = [];
    let activites = this.model.activities;
    for (let activityName of activites) {
      let name = activityName[0];
      let command = activityName[1];
      let args = activityName[2];
      let imgName = name.replace(' ', '');
      let column = h.div({ className: LANDING_COLUMN_CLASS },
        h.span({
          className: LANDING_ICON_CLASS + ` jp-Image${imgName}` ,
          dataset: this._linker.populateVNodeDataset(command, args)
        }),
        h.span({ className: LANDING_TEXT_CLASS }, name)
      );
      activitiesList.push(column);
    }

    let logo = h.span({
      className: `${JUPYTERLAB_ICON_CLASS} ${LANDING_LOGO_CLASS}`
    });
    let subtitle = h.span(
      {className: LANDING_SUBTITLE_CLASS},
      this.model.previewMessage
    );
    let tour = h.span({
      className: TOUR_ICON_CLASS,
      dataset: this._linker.populateVNodeDataset('about-jupyterlab:open', {})
    });
    let header = h.span({
      className: LANDING_HEADER_CLASS
    }, this.model.headerText);
    let body = h.div({ className: LANDING_BODY_CLASS }, activitiesList);

    let dialog = h.div({ className: LANDING_DIALOG_CLASS },
      logo,
      subtitle,
      tour,
      header,
      body
    );
    return h.div({ className: LANDING_WRAPPER_CLASS }, dialog);
  }
开发者ID:faricacarroll,项目名称:jupyterlab,代码行数:46,代码来源:widget.ts

示例4: renderItem

 /**
  * Render the virtual element for a command palette item.
  *
  * @param data - The data to use for rendering the item.
  *
  * @returns A virtual element representing the item.
  */
 renderItem(data: CommandPalette.IItemRenderData): VirtualElement {
   let className = this.createItemClass(data);
   let dataset = this.createItemDataset(data);
   return (
     h.li({ className, dataset },
       this.renderItemIcon(data),
       this.renderItemLabel(data),
       this.renderItemShortcut(data),
       this.renderItemCaption(data)
     )
   );
 }
开发者ID:cfsmile,项目名称:jupyterlab,代码行数:19,代码来源:palette.ts

示例5: createButtonNode

 /**
  * Create a button node for the dialog.
  *
  * @param button - The button data.
  *
  * @returns A node for the button.
  */
 createButtonNode(button: IButton): HTMLElement {
   let className = this.createItemClass(button);
   // We use realize here instead of creating
   // nodes with document.createElement as a
   // shorthand, and only because this is not
   // called often.
   return VirtualDOM.realize(
     h.button({ className },
           this.renderIcon(button),
           this.renderLabel(button))
   );
 }
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:19,代码来源:dialog.ts

示例6: showDialog

          execute: () => {
            // Create the header of the about dialog
            let headerLogo = h.img({ src: kernelIconUrl});
            let title = h.span({className: 'jp-About-header'},
              headerLogo,
              h.div({className: 'jp-About-header-info'}, kernelName)
            );
            const banner = h.pre({}, kernelInfo.banner);
            let body = h.div({ className: 'jp-About-body' },
              banner
            );

            showDialog({
              title,
              body,
              buttons: [
                Dialog.createButton({
                  label: 'DISMISS',
                  className: 'jp-About-button jp-mod-reject jp-mod-styled'
                })
              ]
            });
          }
开发者ID:7125messi,项目名称:jupyterlab,代码行数:23,代码来源:index.ts

示例7: doBuild

 builder.getStatus().then(response => {
   if (response.status === 'building') {
     return doBuild();
   }
   if (response.status !== 'needed') {
     return;
   }
   let body = h.div(
     h.p(
       'JupyterLab build is suggested:',
       h.br(),
       h.pre(response.message)
     )
   );
   showDialog({
     title: 'Build Recommended',
     body,
     buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'BUILD' })]
   }).then(result => {
     if (result.button.accept) {
       return doBuild();
     }
   });
 });
开发者ID:7125messi,项目名称:jupyterlab,代码行数:24,代码来源:index.ts


注:本文中的@phosphor/virtualdom.h类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。