How to use the lit-html/directives/if-defined.js.ifDefined function in lit-html

To help you get started, we’ve selected a few lit-html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CleverCloud / clever-components / components / overview / cc-header-app.js View on Github external
const isDeploying = ['restarting', 'restarting-with-downtime', 'starting'].includes(status);
    const isRunning = ['restart-failed', 'restarting', 'running'].includes(status);
    const shouldDisableAllButtons = (this._lastUserAction != null || this.disableButtons);
    const shouldDisableStopButton = ['start-failed', 'stopped', 'unknown'].includes(status);
    const canStart = ['start-failed', 'stopped'].includes(status);
    const canRestart = skeletonStatus || ['restart-failed', 'running', 'unknown'].includes(status);
    const shouldDisplayStatusMessage = (this._lastUserAction !== 'start' && this._lastUserAction !== 'stop');
    const shouldDisplayLogsLink = ['restart-failed', 'restarting', 'restarting-with-downtime', 'starting', 'start-failed'].includes(status);
    const disableButtonsTitle = this.disableButtons ? i18n('cc-header-app.disable-buttons') : undefined;

    return html`
      <div class="main">
        <div title="${ifDefined(variantName)}" class="flavor-logo ${classMap({ skeleton })}">
          
          <img alt="" src="${ifDefined(variantLogo)}" class="flavor-logo_img">
        </div>
        
        <div class="details">
          <div class="name"><span class="${classMap({">${name}</span></div>
          <div class="commits">
            ${this._renderCommit(commit, 'git', skeleton)}
            ${isRunning ? this._renderCommit(this.runningCommit, 'running', skeleton) : ''}
            ${isDeploying ? this._renderCommit(this.startingCommit, 'starting', skeleton) : ''}
          </div>
        </div>
        
        <div class="buttons">
        
          ${canStart ? html`
             this._onStart('normal')}&gt;
              ${i18n('cc-header-app.action.start')}</div></div>
github CleverCloud / clever-components / components / overview / cc-header-app.js View on Github external
const skeletonStatus = (this.status == null);
    const status = skeletonStatus ? CcHeaderApp.skeletonStatus : this.status;

    const isDeploying = ['restarting', 'restarting-with-downtime', 'starting'].includes(status);
    const isRunning = ['restart-failed', 'restarting', 'running'].includes(status);
    const shouldDisableAllButtons = (this._lastUserAction != null || this.disableButtons);
    const shouldDisableStopButton = ['start-failed', 'stopped', 'unknown'].includes(status);
    const canStart = ['start-failed', 'stopped'].includes(status);
    const canRestart = skeletonStatus || ['restart-failed', 'running', 'unknown'].includes(status);
    const shouldDisplayStatusMessage = (this._lastUserAction !== 'start' &amp;&amp; this._lastUserAction !== 'stop');
    const shouldDisplayLogsLink = ['restart-failed', 'restarting', 'restarting-with-downtime', 'starting', 'start-failed'].includes(status);
    const disableButtonsTitle = this.disableButtons ? i18n('cc-header-app.disable-buttons') : undefined;

    return html`
      <div class="main">
        <div title="${ifDefined(variantName)}" class="flavor-logo ${classMap({ skeleton })}">
          
          <img alt="" src="${ifDefined(variantLogo)}" class="flavor-logo_img">
        </div>
        
        <div class="details">
          <div class="name"><span class="${classMap({">${name}</span></div>
          <div class="commits">
            ${this._renderCommit(commit, 'git', skeleton)}
            ${isRunning ? this._renderCommit(this.runningCommit, 'running', skeleton) : ''}
            ${isDeploying ? this._renderCommit(this.startingCommit, 'starting', skeleton) : ''}
          </div>
        </div>
        
        <div class="buttons">
        
          ${canStart ? html`</div></div>
github material-components / material-components-web-components / packages / textfield / src / mwc-textfield-base.ts View on Github external
protected renderInput() {
    const maxOrUndef = this.maxLength === -1 ? undefined : this.maxLength;
    return html`
      <input step="${ifDefined(this.step === null ? undefined : this.step)}" max="${ifDefined(this.max === '' ? undefined : this.max as number)}" min="${ifDefined(this.min === '' ? undefined : this.min as number)}" pattern="${ifDefined(this.pattern ? this.pattern : undefined)}" maxlength="${ifDefined(maxOrUndef)}" placeholder="${this.placeholder}" type="${this.type}" class="mdc-text-field__input" id="text-field">`;
  }
github GoogleChrome / chromium-dashboard / static / elements / chromedash-metadata.js View on Github external
render() {
    return html`
      <ul class="${ifDefined(this._className)}" id="versionlist">
        ${this._versions.map((version) =&gt; html`
          <li data-version="${version}">${version}</li>
          `)}
      </ul>
      <div class="error">Error fetching version information.</div>
    `;
  }
}
github CleverCloud / clever-components / components / overview / cc-tile-scalability.js View on Github external
const skeleton = (this.scalability == null);
    const { minFlavor, maxFlavor, minInstances, maxInstances } = skeleton ? CcTileScalability._skeletonScalability : this.scalability;

    return html`
      <div class="tile_title">${i18n('cc-tile-scalability.title')}</div>
      
      ${!this.error ? html`
        <div class="tile_body">
          <div class="label">${i18n('cc-tile-scalability.size')}</div>
          <div class="info">
            <div title="${ifDefined(this._getFlavorDetails(minFlavor))}" class="size-label ${classMap({ skeleton })}">${this._formatFlavorName(minFlavor.name)}</div>
            <div class="separator"></div>
            <div title="${ifDefined(this._getFlavorDetails(maxFlavor))}" class="size-label ${classMap({ skeleton })}">${this._formatFlavorName(maxFlavor.name)}</div>
          </div>
          <div class="label">${i18n('cc-tile-scalability.number')}</div>
          <div class="info">
            <div class="count-bubble ${classMap({ skeleton })}">${minInstances}</div>
            <div class="separator"></div>
            <div class="count-bubble ${classMap({ skeleton })}">${maxInstances}</div>
          </div>
        </div>
      ` : ''}

      ${this.error ? html`
        <div class="tile_message"><img alt="" src="${warningSvg}" class="icon-img">${i18n('cc-tile-scalability.error')}</div>
      ` : ''}
    `;
  }
github material-components / material-components-web-components / packages / textfield / src / mwc-textfield-base.ts View on Github external
protected renderInput() {
    const maxOrUndef = this.maxLength === -1 ? undefined : this.maxLength;
    return html`
      <input step="${ifDefined(this.step === null ? undefined : this.step)}" max="${ifDefined(this.max === '' ? undefined : this.max as number)}" min="${ifDefined(this.min === '' ? undefined : this.min as number)}" pattern="${ifDefined(this.pattern ? this.pattern : undefined)}" maxlength="${ifDefined(maxOrUndef)}" placeholder="${this.placeholder}" type="${this.type}" class="mdc-text-field__input" id="text-field">`;
  }
github material-components / material-components-web-components / packages / textfield / src / mwc-textfield-base.ts View on Github external
protected renderInput() {
    const maxOrUndef = this.maxLength === -1 ? undefined : this.maxLength;
    return html`
      <input step="${ifDefined(this.step === null ? undefined : this.step)}" max="${ifDefined(this.max === '' ? undefined : this.max as number)}" min="${ifDefined(this.min === '' ? undefined : this.min as number)}" pattern="${ifDefined(this.pattern ? this.pattern : undefined)}" maxlength="${ifDefined(maxOrUndef)}" placeholder="${this.placeholder}" type="${this.type}" class="mdc-text-field__input" id="text-field">`;
  }
github GoogleChrome / chromium-dashboard / static / elements / chromedash-metrics.js View on Github external
render() {
    return html`
      <b>Showing <span>${this.viewList.length}</span> properties</b>
      <ol id="stack-rank-list">
        <li class="header">
          <span data-order="property_name">
            Property name 
          </span>
          <span class="percent_label" data-order="percentage">
           Percentage 
          </span>
        </li>
        ${this.viewList.map((item) =&gt; html`
          <li tabindex="0" title="${item.property_name}. Click to deep link to this property." id="${item.property_name}">
            <a href="#${item.property_name}">${item.property_name}</a>
            
          </li>
          `)}
      </ol>
    `;
github GoogleChrome / chromium-dashboard / static / elements / chromedash-feature.js View on Github external
` : nothing}
            ${window.PushNotifier &amp;&amp; window.PushNotifier.SUPPORTS_NOTIFICATIONS ? html`
              <span title="Receive a push notification when there are updates" class="tooltip">
                <a data-tooltip="" href="#">
                  
                </a>
              </span>
              ` : nothing}
            <span title="File a bug against this feature" class="tooltip">
              <a data-tooltip="" href="${ifDefined(this._newBugUrl)}">
                
              </a>
            </span>
            <span title="View on a standalone page" class="tooltip">
              <a href="/feature/${this.feature.id}">
                
              </a>
            </span>
          
        
      
      <section class="desc">
        <summary>
          <p><span>${this.feature.summary}</span></p>
          <p><span>${this.feature.motivation}</span></p>
        </summary></section>