How to use @material/tab-bar - 10 common examples

To help you get started, we’ve selected a few @material/tab-bar 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 material-components / material-components-web-react / packages / tab-bar / index.js View on Github external
componentDidMount() {
    this.foundation_ = new MDCTabBarFoundation(this.adapter);
    this.foundation_.init();

    const {
      activeIndex,
      indexInView,
    } = this.props;
    if (this.tabList_[activeIndex]) {
      this.tabList_[activeIndex].activate({} /* previousIndicatorClientRect */);
    }
    this.foundation_.scrollIntoView(indexInView);
  }
github material-components / material-components-web-react / packages / tab-bar / index.tsx View on Github external
componentDidMount() {
    this.foundation = new MDCTabBarFoundation(this.adapter);
    this.foundation.init();
    const {activeIndex, indexInView} = this.props;
    if (this.tabList[activeIndex]) {
      // new DOMRect is not IE11 compatible
      const defaultDOMRect = {
        bottom: 0,
        height: 0,
        left: 0,
        right: 0,
        top: 0,
        width: 0,
        x: 0,
        y: 0,
      };
      this.tabList[activeIndex].activate(defaultDOMRect /* previousIndicatorClientRect */);
    }
github material-components / material-components-web-components / packages / tab-bar / src / mwc-tab-bar-base.ts View on Github external
notifyTabActivated: (index: number) => {
        // Synchronize the tabs `activeIndex` to the foundation.
        // This is needed when a tab is changed via a click, for example.
        this.activeIndex = index;
        this.dispatchEvent(new CustomEvent(
            MDCTabBarFoundation.strings.TAB_ACTIVATED_EVENT,
            {detail: {index}, bubbles: true, cancelable: true}));
      },
    };
github trimox / angular-mdc-web / packages / tab-bar / tab-bar.ts View on Github external
if (!this._indexIsInRange(previousActiveIndex)) {
          previousActiveIndex = this.activeTabIndex;
        }
        return this.tabs.toArray()[previousActiveIndex].computeIndicatorClientRect();
      },
      getTabDimensionsAtIndex: (index: number) => this.tabs.toArray()[index].computeDimensions(),
      getPreviousActiveTabIndex: () => this.tabs.toArray().findIndex((_) => _.active),
      getFocusedTabIndex: () =>
        this._platform.isBrowser ? this.tabs.toArray().findIndex(tab =>
          tab.elementRef.nativeElement === document.activeElement!) : -1,
      getIndexOfTabById: (id: string) => this.tabs.toArray().findIndex(tab => id === tab.id),
      getTabListLength: () => this.tabs.length,
      notifyTabActivated: (index: number) =>
        this.activated.emit({ source: this, index: index, tab: this.tabs.toArray()[index] })
    };
    return new MDCTabBarFoundation(adapter);
  }
github pgbross / vue-material-adapter / packages / mcwv-tabs / tab-bar.js View on Github external
notifyTabActivated: index => {
        emitCustomEvent(
          this.$el,
          MDCTabBarFoundation.strings.TAB_ACTIVATED_EVENT,
          { index },
          true,
        );

        this.$emit('change', index);
      },
    });
github matsp / material-components-vue / components / tabs / TabBar.vue View on Github external
mounted () {
    this.updateSlot()
    this.mdcTabBar = MDCTabBar.attachTo(this.$el)

    this.slotObserver = new MutationObserver(() => this.updateSlot())
    this.slotObserver.observe(this.$el, {
      childList: true,
      subtree: true
    })
  },
  beforeDestroy () {
github matsp / material-components-vue / components / tabs / TabBar.vue View on Github external
this.$nextTick(() => {
        this.mdcTabBar = MDCTabBar.attachTo(this.$el)
        this.mdcTabBar.focusOnActivate = this.focusOnActivate
        this.mdcTabBar.useAutomaticActivation = this.useAutomaticActivation
      })
    },
github Tencent / omi / packages / omim / src / tab / index.tsx View on Github external
domReady(() => {
			//update first
			this.update()
			//init mdc tab
			this.data.tabBar = new MDCTabBar(this.shadowRoot.querySelector('.mdc-tab-bar'));
			this.data.tabBar.listen('MDCTabBar:activated', (e) => {
				let item = this.props.children[e.detail.index]
				this.fire('change', item.attributes)
			})
		})
	}
github prateekbh / preact-material-components / ts / TabBar / index.tsx View on Github external
public componentDidMount() {
    super.componentDidMount();
    if (this.control) {
      this.MDComponent = new MDCTabBar(this.control);
    }
    this.afterComponentDidMount();
  }
github jamesmfriedman / rmwc / src / tabs / tab-bar.tsx View on Github external
getDefaultFoundation() {
    return new MDCTabBarFoundation(
      /** @type {!MDCTabBarAdapter} */ {
        scrollTo: (scrollX: number) => {
          this.tabScroller && this.tabScroller.scrollTo(scrollX);
        },

        incrementScroll: (scrollXIncrement: number) =>
          this.tabScroller &&
          this.tabScroller.incrementScroll(scrollXIncrement),
        getScrollPosition: () =>
          this.tabScroller ? this.tabScroller.getScrollPosition() : 0,
        getScrollContentWidth: () =>
          this.tabScroller ? this.tabScroller.getScrollContentWidth() : 0,
        getOffsetWidth: () => (this.root.ref ? this.root.ref.offsetWidth : 0),
        isRTL: () =>
          !!this.root.ref &&
          window