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

DIY Components: Why and how?

DIY Components: Why and how?

[ABSTRACT] You've been given a design which is going to require a complex dropdown menu. You would've liked to save time and use a tag but it's missing some features. Do you use a component library or do you courageously build your own component from scratch? We'll look into why the DIY route is so challenging, learn to think like a component developer and understand the implications of going DIY vs component library vs built-in HTML.

Julien Benchetrit

April 03, 2019
Tweet

Other Decks in Programming

Transcript

  1. DIY Components Who am I? • I'm Julien. I've been

    building web apps and websites since 2009.
  2. DIY Components Who am I? • I'm Julien. I've been

    building web apps and websites since 2009. • I work at Healthy.io, a digital healthcare company.
  3. DIY Components Who am I? • I'm Julien. I've been

    building web apps and websites since 2009. • I work at Healthy.io, a digital healthcare company. • I contribute to react-boilerplate.
  4. DIY Components Who am I? • I'm Julien. I've been

    building web apps and websites since 2009. • I work at Healthy.io, a digital healthcare company. • I contribute to react-boilerplate. • I'm (sort of) on Twitter. @julienbenc
  5. DIY Components What are we talking about? • Web components...

    • But not "Web Components"! • Small, interactive and reusable widgets. • You mean inputs? Kind of, yes. • They're a basic building block in most of our work.
  6. DIY Components What about them? • Knowing how to build

    components is a skill in itself. • Alas, it's often a very complex endeavor. Why? • How do we get better at it?
  7. DIY Components Why not component libraries? • Not always maintained

    • Much harder to debug • Sometimes bloated
  8. DIY Components How do we do it? • Write the

    API • Build the UX • Make it accessible • Make it performant • Maintain it
  9. DIY Components Won't somebody please think of the users? 1.

    Affects more people than you might think 2. Not just about vision and screen readers. Accessibility
  10. DIY Components DIY Components DIY Components 1. Is it the

    responsible choice? 2. Make it feature-complete 3. And, above all, accessible Won't somebody please think of the users?
  11. DIY Components Disclaimer •We're looking at controlled components. •Code samples

    use React. Won't somebody please think of the developers? "#
  12. button checkbox color date datetime-local email file hidden image month

    number password radio range reset search submit tel text daterange time url week
  13. button checkbox color date datetime-local email file hidden image month

    number password radio range reset search submit tel text daterange time url week
  14. DIY Components How do we make a custom input compatible

    with other Web APIs? In the case of forms... • Place an <input type="hidden"> inside your custom element and sync the values. • Custom Elements and the "is" attribute. Won't somebody please think of the developers? "#
  15. DIY Components Hold on.... Custom Elements and the "is" attribute?

    Won't somebody please think of the developers? "#
  16. DIY Components Flexibility •Use strings like in a regular <select>

    •Pass a custom component or markup Won't somebody please think of the developers? "#
  17. DIY Components DIY Components DIY Components 1. Make it single-purpose

    2. Reuse APIs and patterns 3. Add interoperability 4. Refactor if necessary Won't somebody please think of the developers? "#
  18. DIY Components RECAP • Building custom components isn't always the

    best path. • When it is, make sure that what you build is feature-complete. • It's our responsibility to our users. • Developing components is very challenging. • There's always downsides compared to native elements. • Make the right tradeoffs. • New standards will help. Eventually.