How to use the @material/icon-button.MDCIconButtonToggleFoundation function in @material/icon-button

To help you get started, we’ve selected a few @material/icon-button 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 src-zone / material / bundle / src / components / icon-button / mdc.icon-button.directive.ts View on Github external
ngAfterContentInit() {
        this.initRipple();
        this.toggleFoundation = new MDCIconButtonToggleFoundation(this.toggleAdapter);
        this.toggleFoundation.init();
        // the foundation doesn't initialize the iconOn/iconOff and labelOn/labelOff until
        // toggle is called for the first time,
        // also, this will ensure 'aria-pressed' and 'aria-label' attributes are initialized:
        this.toggleFoundation.toggle(this._on);
        this._initialized = true;
    }
github jamesmfriedman / rmwc / src / icon-button / index.tsx View on Github external
getDefaultFoundation() {
    return new MDCIconButtonToggleFoundation({
      addClass: (className: string) => this.root.addClass(className),
      removeClass: (className: string) => this.root.removeClass(className),
      hasClass: (className: string) => this.root.hasClass(className),
      setAttr: (attrName: string, attrValue: string | number | null) =>
        this.root.setProp(attrName as any, attrValue),
      notifyChange: (evtData: { isOn: boolean }) =>
        this.emit('onChange', evtData)
    });
  }
github trimox / angular-mdc-web / packages / icon-button / icon-button.ts View on Github external
getDefaultFoundation() {
    const adapter: MDCIconButtonToggleAdapter = {
      addClass: (className: string) => this._getHostElement().classList.add(className),
      removeClass: (className: string) => this._getHostElement().classList.remove(className),
      hasClass: (className: string) => this._getHostElement().classList.contains(className),
      setAttr: (name: string, value: string) => this._getHostElement().setAttribute(name, value),
      notifyChange: (evtData: {isOn: boolean}) => {
        this.change.emit(new MdcIconButtonChange(this, evtData.isOn));
        this._onChange(this._foundation.isOn());
      }
    };
    return new MDCIconButtonToggleFoundation(adapter);
  }