How to use the @material/snackbar.MDCSnackbarFoundation function in @material/snackbar

To help you get started, we’ve selected a few @material/snackbar 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 / snackbar / snackbar.tsx View on Github external
getDefaultFoundation() {
    /* eslint brace-style: "off" */
    return new MDCSnackbarFoundation({
      addClass: (className: string) => this.root.addClass(className),
      removeClass: (className: string) => this.root.removeClass(className),
      announce: () => this.labelEl && this.announce(this.labelEl),
      notifyOpening: () => this.emit('onOpen', {}),
      notifyOpened: () => this.emit('onOpened', {}),
      notifyClosing: (reason: string) =>
        this.emit('onClose', reason ? { reason } : {}),
      notifyClosed: (reason: string) =>
        this.emit('onClosed', reason ? { reason } : {})
    });
  }
github src-zone / material / bundle / src / components / snackbar / mdc.snackbar.directive.ts View on Github external
registerActionClickHandler: (handler: EventListener) => {
            if (this.action)
                this.registry.listen(this.renderer, 'click', handler, this.action._elm);
        },
        deregisterActionClickHandler: (handler: EventListener) => {
            this.registry.unlisten('click', handler);
        },
        registerTransitionEndHandler: (handler: EventListener) => {
            this.registry.listen(this.renderer, getCorrectEventName(window, 'transitionend'), handler, this.root);
        },
        deregisterTransitionEndHandler: (handler: EventListener) => {
            this.registry.unlisten(getCorrectEventName(window, 'transitionend'), handler);
        }
    };
    private foundation: { init: Function, destroy: Function, show: (message: SnackbarMessage) => void }
            = new MDCSnackbarFoundation(this.mdcAdapter);

    constructor(private renderer: Renderer2, private root: ElementRef, private registry: MdcEventRegistry) {
    }

    ngAfterContentInit() {
        this.foundation.init();
    }

    ngOnDestroy() {
        this.foundation.destroy();
    }

    show(message: SnackbarMessage) {
        this.foundation.show(message);
    }
}
github material-components / material-components-web / framework-examples / vue / src / v-mdc-snackbar / Snackbar.vue View on Github external
mounted () {
    let vm = this;
    this.foundation = new MDCSnackbarFoundation({
      addClass (className) {
        vm.$set(vm.classes, className, true);
      },
      removeClass (className) {
        vm.$delete(vm.classes, className);
      },
      setAriaHidden () {
        vm.hidden = true;
      },
      unsetAriaHidden () {
        vm.hidden = false;
      },
      setActionAriaHidden () {
        vm.actionHidden = true;
      },
      unsetActionAriaHidden () {
github trimox / angular-mdc-web / packages / snackbar / snackbar.component.ts View on Github external
getDefaultFoundation() {
    const adapter: MDCSnackbarAdapter = {
      addClass: (className: string) => this._getHostElement().classList.add(className),
      removeClass: (className: string) => this._getHostElement().classList.remove(className),
      announce: () => this.label.nativeElement ? this._liveAnnouncer.announce(this.config.data.message,
        this.config.politeness, this.config.timeoutMs || MDCSnackbarFoundation.numbers.ARIA_LIVE_DELAY_MS) : {},
      notifyClosing: () => {},
      notifyOpened: () => {},
      notifyOpening: () => {},
      notifyClosed: (reason: MdcSnackbarDismissReason | string) => this.snackbarRef.dismiss(reason)
    };
    return new MDCSnackbarFoundation(adapter);
  }