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

Angular Material ou Bootstrap ? Pourquoi choisir ! @ GDG Toulouse

Angular Material ou Bootstrap ? Pourquoi choisir ! @ GDG Toulouse

Angular Material ET Bootstrap pour votre prochaine application Angular ? Ça n'a aucun sens, n'est-ce pas ? La première fois que j'ai proposé à mes collègues de mixer les deux, ils se sont tous moqués de moi. Mais aujourd'hui, ils sont devenus fans de cette approche, car ça marche du feu de Dieu !

Dans cette session, nous allons voir comment on peut tirer parti du meilleur des deux mondes pour créer des applications Angular qui soient jolies, maintenables, et responsives, et ce, avec très peu de CSS.

Amadou Sall

October 17, 2019
Tweet

More Decks by Amadou Sall

Other Decks in Programming

Transcript

  1. AHASALL / JDJEBARI Frontend Software Engineer Jérôme Djebari GDG Toulouse

    / October 2019 @ahasall Frontend Software Engineer Amadou Sall www.amadousall.com @JDjebari Angular Material or Bootstrap? Stop Asking the Question!
  2. AHASALL / JDJEBARI 3 Core Principles of Responsive Design 15

    Media Queries Fluid Layouts Mobile First
  3. AHASALL / JDJEBARI What is a CSS Reset? All browsers

    have presentation defaults, but no browser has the same defaults. —Eric Meyer 18
  4. AHASALL / JDJEBARI Columns <div class="container"> <div class="row"> <div class="col">Row

    1/Col 1!</div> <div class="col">Row 1/Col 2!</div> !</div> !</div> 26
  5. AHASALL / JDJEBARI Columns <div class="container"> <div class="row"> <div class="col-4">Row

    1/Col 1!</div> <div class="col-8">Row 1/Col 2!</div> !</div> !</div> 27
  6. AHASALL / JDJEBARI Columns <div class="container"> <div class="row"> <div class="col-md-6

    col-lg-4">Row 1/Col 1!</div> <div class="col-md-6 col-lg-4">Row 1/Col 2!</div> !!... !</div> !</div> 28
  7. AHASALL / JDJEBARI Utility Class .class { property: value !important;

    } a single, immutable property-value pairing 31
  8. AHASALL / JDJEBARI Utility Class .d-block { display: block !important;

    } a single, immutable property-value pairing 33
  9. AHASALL / JDJEBARI Utility Class .d-!flex { display: !flex !important;

    } a single, immutable property-value pairing 34
  10. AHASALL / JDJEBARI <div class="d-none d-md-!flex"> Hidden on small devices

    Visible on bigger devices !</div> Bootstrap utilities are responsive 36
  11. AHASALL / JDJEBARI ✅ CSS Reset ✅ CSS Layout ✅

    CSS Utilities ❌ Components Recap
  12. AHASALL / JDJEBARI What is Angular Material? Angular components Implements

    Material Design Built by the Angular Team Released at the same time as Angular 44
  13. AHASALL / JDJEBARI The Different Parts of Angular Material 45

    Component Development Kit Material Design Components
  14. AHASALL / JDJEBARI CDK Layout constructor(private observer: BreakpointObserver) { this.breakpoint$

    = this.observer.observe([ '(min-width: 0px)', '(min-width: 576px)', '(min-width: 768px)', '(min-width: 992px)', '(min-width: 1200px)', ]); } 49
  15. AHASALL / JDJEBARI The CDK can be used to build

    your own component library 50
  16. AHASALL / JDJEBARI Form controls Navigation "Layout" components Buttons &

    indicators Popups & Modals Data table 51 Components
  17. AHASALL / JDJEBARI (2) my-alert.component.scss .my-alert { padding: 1.5rem; margin:

    1.5rem; border-width: 1px; border-style: solid; font-weight: bold; } 61
  18. AHASALL / JDJEBARI (3) my-alert.component.theme.scss @mixin alert-theme($theme) { $primary: map-get($theme,

    primary); $accent: map-get($theme, accent); .my-alert { background-color: mat-color($accent, 50); color: mat-color($accent, 900); border-color: mat-color($primary, 100); } } 62
  19. AHASALL / JDJEBARI ❌ CSS Reset ❌ CSS Layout ❌

    CSS Utilities ✅ Components Recap
  20. AHASALL / JDJEBARI Which one to choose? Angular Material ❌

    CSS Reset ❌ CSS Layout ❌ CSS Utilities ✅ Components Bootstrap ✅ CSS Reset ✅ CSS Layout ✅ CSS Utilities ❌ Components 71
  21. AHASALL / JDJEBARI The Setup - Bootstrap @import "my-variables"; @import

    "~bootstrap/scss/functions"; @import "~bootstrap/scss/variables"; @import "~bootstrap/scss/mixins"; @import "~bootstrap/scss/reboot"; @import "~bootstrap/scss/grid"; @import "~bootstrap/scss/utilities"; @import "my-reset"; 73
  22. AHASALL / JDJEBARI The Setup - Angular Material @import "!~@angular/material/theming";

    @include mat-core($my-typography); $my-theme: mat-light-theme($primary, $accent, $warn) @include angular-material-theme($my-theme); 74
  23. AHASALL / JDJEBARI my-alert.component.html <div class="border m-3 p-3 font-weight-bold my-border-primary-100

    my-text-secondary-900 my-bg-secondary-50 > Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi dolore ea, earum esse !</div> 85
  24. AHASALL / JDJEBARI Generating Custom Utilities @mixin generate-utilities($theme) { $primary:

    map-get($theme, primary); $accent: map-get($theme, accent); .my-text-secondary-900 { color: mat-color($secondary, 900); } .my-bg-primary-100 { background-color: mat-color($primary, 100); } !!... } 86
  25. AHASALL / JDJEBARI ✅ Bootstrap Reboot ✅ Bootstrap Grid ✅

    Bootstrap Utilities ✅ Component Dev Kit ✅ Material Components ✅ New Theming approach Recap
  26. AHASALL / JDJEBARI @JDjebari Frontend Software Engineer Jérôme Djebari GDG

    Toulouse Thank You! @ahasall Frontend Software Engineer Amadou Sall www.amadousall.com