Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Material Components for React

Avatar for Bonnie Zhou Bonnie Zhou
December 04, 2018

Material Components for React

Google Material Design is a design system, that anyone can use, to create beautiful usable applications. MDC React is the open source component library, officially supported by the Material Design team at Google. Come learn all about Material Design, and MDC React, and how it can help you make beautiful websites faster.

Avatar for Bonnie Zhou

Bonnie Zhou

December 04, 2018
Tweet

More Decks by Bonnie Zhou

Other Decks in Programming

Transcript

  1. Agenda 1. What is Material Design? 2. How does Material

    help developers? 3. How does Material help React developers? 4. How to use Material in a React code base
  2. Material is a design system – backed by open-source code

    – that helps teams build digital experiences
  3. Material is a design system – backed by open-source code

    – that helps teams build digital experiences
  4. MDC Web: Text Field Foundation/Adapter interface TextFieldAdapter { addClass(className: string);

    ... } class TextFieldFoundation { constructor(adapter: TextFieldAdapter) { this.adapter = adapter; } activateFocus() { this.adapter.addClass(‘text-field--focused’); } }
  5. MDC Web: Text Field Foundation/Adapter interface TextFieldAdapter { addClass(className: string);

    ... } class TextFieldFoundation { constructor(adapter: TextFieldAdapter) { this.adapter = adapter; } activateFocus() { this.adapter.addClass(‘text-field--focused’); } }
  6. MDC Web: Text Field Foundation/Adapter interface TextFieldAdapter { addClass(className: string);

    ... } class TextFieldFoundation { constructor(adapter: TextFieldAdapter) { this.adapter = adapter; } activateFocus() { this.adapter.addClass(‘text-field--focused’); } }
  7. MDC Web: Text Field Foundation/Adapter interface TextFieldAdapter { addClass(className: string);

    ... } class TextFieldFoundation { constructor(adapter: TextFieldAdapter) { this.adapter = adapter; } activateFocus() { this.adapter.addClass(‘text-field--focused’); } }
  8. MDC Web: Text Field Foundation/Adapter interface TextFieldAdapter { addClass(className: string);

    ... } class TextFieldFoundation { constructor(adapter: TextFieldAdapter) { this.adapter = adapter; } activateFocus() { this.adapter.addClass(‘text-field--focused’); } }
  9. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; componentDidMount() { this.foundation = new TextFieldFoundation({ addClass: (className) => { const classList = new Set(this.state.classList); classList.add(className); this.setState({classList}); }, }); } }
  10. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; componentDidMount() { this.foundation = new TextFieldFoundation({ addClass: (className) => { const classList = new Set(this.state.classList); classList.add(className); this.setState({classList}); }, }); } }
  11. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; componentDidMount() { this.foundation = new TextFieldFoundation({ addClass: (className) => { const classList = new Set(this.state.classList); classList.add(className); this.setState({classList}); }, }); } }
  12. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; ... render() { return ( <div className={classNames(this.state.classList)}> <input onFocus={this.foundation.activateFocus} ... /> </div> ); } }
  13. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; ... render() { return ( <div className={classNames(this.state.classList)}> <input onFocus={this.foundation.activateFocus} ... /> </div> ); } }
  14. MDC React: Text Field class TextField extends React.Component { state

    = {classList: new Set()}; ... render() { return ( <div className={classNames(this.state.classList)}> <input onFocus={this.foundation.activateFocus} ... /> </div> ); } }
  15. User focuses on text field React synthetic event fires TextFieldFoundation

    .activateFocus TextFieldAdapter .addClass React updates state and re-renders User sees text field with focused styling User React MDC Web
  16. What makes MDC React different? • Official Google support •

    Dogfooded by Google teams (through MDC Web) • Strong focus on accessibility
  17. Takeaways material.io • Material helps you build beautiful (React) apps

    faster • Material works across platforms • Material wants to work with all you React developers!! • MDC React can easily be included in your existing React code