How to use @material/icon-button - 10 common examples

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 jsoetens / udacity-nanodegree-mws / mws-project-3 / app / js / resto-info.js View on Github external
const elementGoogleMaps = document.getElementById('google-maps');
const elementGoogleStaticMaps = document.getElementById('google-static-maps');
const elementReviewsContainer = document.getElementById('reviews-container');
const elementReviewsList = document.getElementById('reviews-list');

/**
 * Material Design
 */
// Enhance icon button to have a ripple effect by instantiating MDCRipple 
// on the root element.
const iconButtonRipple = 
  new MDCRipple(document.querySelector('.mdc-icon-button'));
iconButtonRipple.unbounded = true;

const toggleFavoriteButton = 
  new MDCIconButtonToggle(elementAddToFavorites);

elementAddToFavorites.addEventListener('MDCIconButtonToggle:change', function(evt) {
  // let newStatus = evt.detail.isOn ? 'yes' : 'no';
  if (evt.detail.isOn) {
    is_favorite = true;
    postIsFavoriteNetworkFirst(self.restaurant_id, is_favorite)
  } else {
    is_favorite = false;
    postIsFavoriteNetworkFirst(self.restaurant_id, is_favorite);
  }
});

/**
 * Post the is_favorite status by restaurant_id, save data locally to IndexedDB,
 * send to API server, update UI.
 * POST: http://localhost:1337/restaurants//?is_favorite=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);
  }
github pgbross / vue-material-adapter / packages / mcwv-icon-button / mdc-icon-button.js View on Github external
mounted() {
    const { CHANGE_EVENT } = MDCIconButtonToggleFoundation.strings;
    const adapter = {
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      hasClass: className => Boolean(this.classes[className]),
      setAttr: (attrName, attrValue) =>
        this.$el.setAttribute(attrName, attrValue),
      notifyChange: evtData => {
        this.$emit(CHANGE_EVENT, evtData);
        this.$emit('change', evtData.isOn);
      },
    };

    this.foundation = new MDCIconButtonToggleFoundation(adapter);
    this.foundation.init();

    this.ripple = new RippleBase(this, {
      isUnbounded: () => true,
    });
    this.ripple.init();
    this.foundation.toggle(this.isOn);
  },
github pgbross / vue-material-adapter / packages / mcwv-icon-button / icon-button.js View on Github external
mounted() {
    const { CHANGE_EVENT } = MDCIconButtonToggleFoundation.strings;
    const adapter = {
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      hasClass: className => Boolean(this.classes[className]),
      setAttr: (attrName, attrValue) =>
        this.$el.setAttribute(attrName, attrValue),
      notifyChange: evtData => {
        this.$emit(CHANGE_EVENT, evtData);
        this.$emit('change', evtData.isOn);
      },
    };

    this.foundation = new MDCIconButtonToggleFoundation(adapter);
    this.foundation.init();

    this.ripple = new RippleBase(this, {
      isUnbounded: () => true,
    });
    this.ripple.init();
    this.foundation.toggle(this.isOn);
  },
github pgbross / vue-material-adapter / packages / mcwv-icon-button / mdc-icon-button.js View on Github external
mounted() {
    const { CHANGE_EVENT } = MDCIconButtonToggleFoundation.strings;
    const adapter = {
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      hasClass: className => Boolean(this.classes[className]),
      setAttr: (attrName, attrValue) =>
        this.$el.setAttribute(attrName, attrValue),
      notifyChange: evtData => {
        this.$emit(CHANGE_EVENT, evtData);
        this.$emit('change', evtData.isOn);
      },
    };

    this.foundation = new MDCIconButtonToggleFoundation(adapter);
    this.foundation.init();

    this.ripple = new RippleBase(this, {
github pgbross / vue-material-adapter / packages / mcwv-icon-button / icon-button.js View on Github external
mounted() {
    const { CHANGE_EVENT } = MDCIconButtonToggleFoundation.strings;
    const adapter = {
      addClass: className => this.$set(this.classes, className, true),
      removeClass: className => this.$delete(this.classes, className),
      hasClass: className => Boolean(this.classes[className]),
      setAttr: (attrName, attrValue) =>
        this.$el.setAttribute(attrName, attrValue),
      notifyChange: evtData => {
        this.$emit(CHANGE_EVENT, evtData);
        this.$emit('change', evtData.isOn);
      },
    };

    this.foundation = new MDCIconButtonToggleFoundation(adapter);
    this.foundation.init();

    this.ripple = new RippleBase(this, {
github material-components / material-components-web-react / packages / icon-button / index.tsx View on Github external
componentDidMount() {
    this.foundation = new MDCIconButtonToggleFoundation(this.adapter);
    this.foundation.init();
  }
github material-components / material-components-web-catalog / src / ShapeCatalog.js View on Github external
                  ref={(surfaceEl) => this.iconToggle = surfaceEl && new MDCIconButtonToggle(surfaceEl)}>
                  <i>favorite</i>