How to use @material/tab - 10 common examples

To help you get started, we’ve selected a few @material/tab 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 jamesmfriedman / rmwc / src / tabs / tab.tsx View on Github external
getDefaultFoundation() {
      return new MDCTabFoundation(
        /** @type {!MDCTabAdapter} */ {
          setAttr: (attr: string, value: any) =>
            this.root.setProp(attr as any, value),
          addClass: (className: string) => this.root.addClass(className),
          removeClass: (className: string) => this.root.removeClass(className),
          hasClass: (className: string) => this.root.hasClass(className),
          activateIndicator: (previousIndicatorClientRect: ClientRect) =>
            this.tabIndicator &&
            this.tabIndicator.activate(previousIndicatorClientRect),
          deactivateIndicator: () =>
            this.tabIndicator && this.tabIndicator.deactivate(),
          notifyInteracted: () => {
            const evt = this.emit(
              'onInteraction',
              { tabId: this.id },
              true /* bubble */
github matsp / material-components-vue / components / tabs / Tab.vue View on Github external
this.$nextTick(() => {
        this.updateSlot()
        this.mdcTab = MDCTab.attachTo(this.$el)
        if (this.index !== -1) { // within 
          this.replaceTabInstance(this.mdcTab, this.index)
        }
      })
    },
github matsp / material-components-vue / components / tabs / Tab.vue View on Github external
childList: true,
      subtree: true
    })

    this.classObserver = new MutationObserver(() => this.updateActive())
    this.classObserver.observe(this.$el, {
      attributes: true
    })
    if (this.getTabInstance instanceof Function) { // within 
      this.$nextTick(() => {
        [this.mdcTab, this.index] = this.getTabInstance(this.$el)
        this.assignProperties()
        this.updateSlot()
      })
    } else { // standalone tab
      this.mdcTab = MDCTab.attachTo(this.$el)
    }
  },
  beforeDestroy () {
github pgbross / vue-material-adapter / packages / mcwv-tabs / tab.js View on Github external
notifyInteracted: () =>
        emitCustomEvent(
          this.$el,
          MDCTabFoundation.strings.INTERACTED_EVENT,
          { tabId: this.id },
          true /* bubble */,
        ),
      getOffsetLeft: () => this.$el.offsetLeft,
github pgbross / vue-material-adapter / packages / mcwv-tabs / tab.js View on Github external
mounted() {
    this.id = this.vma_uid_;
    this.foundation = new MDCTabFoundation({
      setAttr: (attr, value) => this.$el.setAttribute(attr, value),
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      hasClass: className => this.$el.classList.contains(className),
      activateIndicator: previousIndicatorClientRect => {
        this.$refs.tabIndicator.activate(previousIndicatorClientRect);
      },
      deactivateIndicator: () => {
        this.$refs.tabIndicator.deactivate();
      },
      notifyInteracted: () =>
        emitCustomEvent(
          this.$el,
          MDCTabFoundation.strings.INTERACTED_EVENT,
          { tabId: this.id },
          true /* bubble */,
github trimox / angular-mdc-web / packages / tab / tab.ts View on Github external
const adapter: MDCTabAdapter = {
      setAttr: (attr: string, value: string) => this._getHostElement().setAttribute(attr, value),
      addClass: (className: string) => this._getHostElement().classList.add(className),
      removeClass: (className: string) => this._getHostElement().classList.remove(className),
      hasClass: (className: string) => this._getHostElement().classList.contains(className),
      activateIndicator: (previousIndicatorClientRect: ClientRect) =>
        this.tabIndicator.activate(previousIndicatorClientRect),
      deactivateIndicator: () => this.tabIndicator.deactivate(),
      notifyInteracted: () => this.interacted.emit({detail: {tabId: this.id, tab: this}}),
      getOffsetLeft: () => this._getHostElement().offsetLeft,
      getOffsetWidth: () => this._getHostElement().offsetWidth,
      getContentOffsetLeft: () => this.content.nativeElement.offsetLeft,
      getContentOffsetWidth: () => this.content.nativeElement.offsetWidth,
      focus: () => this._getHostElement().focus()
    };
    return new MDCTabFoundation(adapter);
  }
github material-components / material-components-web-react / packages / tab / index.tsx View on Github external
componentDidMount() {
    const {active, focusOnActivate} = this.props;
    this.foundation = new MDCTabFoundation(this.adapter);
    this.foundation.init();
    this.foundation.setFocusOnActivate(focusOnActivate!);
    if (active) {
      this.foundation.activate();
    }
  }
github material-components / material-components-web-components / packages / tab / src / mwc-tab-base.ts View on Github external
notifyInteracted: () => this.dispatchEvent(
          new CustomEvent(MDCTabFoundation.strings.INTERACTED_EVENT, {
            detail: {tabId: this.id},
            bubbles: true,
            composed: true,
            cancelable: true,
          })),
      getOffsetLeft: () => this.offsetLeft,
github material-components / material-components-web / packages / mdc-tab-bar / component.ts View on Github external
      tabFactory: MDCTabFactory = (el) => new MDCTab(el),
      tabScrollerFactory: MDCTabScrollerFactory = (el) => new MDCTabScroller(el),
github material-components / material-components-web / packages / mdc-tab-bar / component.ts View on Github external
destroy() {
    super.destroy();
    this.unlisten(MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
    this.unlisten('keydown', this.handleKeyDown_);
    this.tabList_.forEach((tab) => tab.destroy());

    if (this.tabScroller_) {
      this.tabScroller_.destroy();
    }
  }