Dark theme switching with Angular Material (2020)

Поділитися
Вставка
  • Опубліковано 29 лют 2020
  • 📣 Check out my full Angular Material Theming Workshop 📣
    bit.ly/angular-material-themi...
    ✅ Use 10%-off coupon code: UA-cam_DISCOUNT (Only 2 coupons left)
    In this video we will learn how to implement dark theme and dark mode switching in your web application by using angular material theming capabilities. In next videos we will continue to explore more and more powerful features from Angular Material library.
    Please leave you feedback in comments so I would be able to improve content quality :)
    Time code:
    00:01:19 - Here ends my talking ;)
    Explore more on my channel:
    ✅ Check out my other videos about Angular Material Library: • Angular Material
    ✅ And there are some topics about Angular Material CDK:
    • Angular Material CDK
    ✅ Quick subscribe: / @decodedfrontend
    🔗 Links:
    Link to GitHub repo: github.com/mezhik91/angular-t...
    Angular: angular.io
    Angular Material: material.angular.io
    Contact me: dmytro.mezhenskyi@gmail.com
  • Наука та технологія

КОМЕНТАРІ • 87

  • @DecodedFrontend
    @DecodedFrontend  3 роки тому +2

    🔥🔥🔥Do you want to master *Angular Material Themes* like a PRO? Check out my new Workshop where you will find a lot of advanced tips & tricks which will help you to make your themes maintainable, lean & consistent! Limited 50%-off discount is about to expire very soon: 🔗 bit.ly/angular-material-theming-workshop 🔥🔥🔥

  • @alexanderleonardo5649
    @alexanderleonardo5649 4 роки тому +2

    as someone who recently dive and started in angular, your channel will be helpful to me . subscribed!

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому

      Thank for your warm feedback! It motivates me a lot :)

  • @velosofy
    @velosofy Рік тому

    Very good video. Helped me a lot!

  • @pazzuto
    @pazzuto 4 роки тому +6

    Hey Dmytro, looks like you really know Angular. Looking forward to watching more of your videos.

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому

      Thank you, Eddie! I appreciate your feedback ;)
      You can find even more advanced things in my other videos. Hope those will be also useful for you.

  • @gabrielferrin
    @gabrielferrin 2 роки тому +1

    Simple and effective. Thank a lot.

  • @mehrtashsouri6862
    @mehrtashsouri6862 3 роки тому +3

    Very Nice and useful. specially in part that you add class to the document body for overlays. you save me a lot of time. BIG LIKE

  • @jeffersongil3949
    @jeffersongil3949 4 роки тому +1

    Great video, just that i needed, thank U' so much!!

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому

      Welcome! I am happy to know that the tutorial helped you :) I hope my other videos you will find useful as well!

  • @Serik_vyh
    @Serik_vyh 4 роки тому +2

    Wow, exactly what I was looking for

  • @_cipriangg_
    @_cipriangg_ 2 роки тому

    Thank you for the info!

  • @alihosseinkhani2671
    @alihosseinkhani2671 2 роки тому

    Thanks . You made my day

  • @cilcoposea
    @cilcoposea 3 роки тому +1

    Great job, that was really useful

  • @gangareddy5111
    @gangareddy5111 4 роки тому +1

    Yes, it's a very useful video. Keep doing like this.

  • @keshav2kumar
    @keshav2kumar 8 місяців тому

    Very nice and useful

  • @vishwadinupriya2291
    @vishwadinupriya2291 3 роки тому +2

    Damn! You absolutely genius. please keep it up brother!

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      Thank you! I will ;)

    • @vishwadinupriya2291
      @vishwadinupriya2291 3 роки тому

      @@DecodedFrontend Hey bro please help me! there is a reactive form in my project and when i active the dark mode that form's height increase and because of that it's look weird.

  • @archismantripathi
    @archismantripathi Рік тому

    its really helpful
    thank you

  • @krishnapanigrahi6926
    @krishnapanigrahi6926 3 роки тому +1

    Awesome content. Learnt something new.

  • @thomasnicolai628
    @thomasnicolai628 3 роки тому +1

    THANK YOU!! Goldmine!

  • @rumoefz3252
    @rumoefz3252 4 роки тому +2

    Thanks for your help.

  • @MarcusPaulo
    @MarcusPaulo 4 роки тому +1

    Congratulations for your video 👏🏻👏🏻👏🏻

  • @johncerpa3782
    @johncerpa3782 3 роки тому

    Great

  • @nixonnelson8856
    @nixonnelson8856 3 роки тому +2

    Hi Dymtro , Can you pls make a video on responsive designing and the best practices , I have always worked on web but starting responsive for the first time , but its difficult to chose between angular flex-layout , angular material itself , media queries or other 3rd party . what to use where to use as in at a global level rather than importing at all components and all . It will be really helpful . thanks

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому +2

      Hi Nixon,
      Great suggestion! I will take it into consideration. Thanks for an idea.
      As quick response I can say that you usually need all of them. As example flex-layout it is great declarative way to manage different grids and layouts for different viewport sizes but it isn't applicable to ... as example fonts which may also be differ for different screen sizes and there you will need to go with media queries. Also you may need to change feature logic depending on screen size and there could be a great choice BreakpointObserver module which I covered in on of my video: ua-cam.com/video/1Z4QlRYXINc/v-deo.html
      So... this is quite hard to unify it because very often it depends on concrete project/component requirements which are different from project to project :)

  • @hamidhassani9550
    @hamidhassani9550 3 роки тому

    I don't have those Angular material schematics I mean ANgular/material dashboard, table and so on when I installed the NxConsole
    how can I add those items to my IDE?

  • @zrowork1362
    @zrowork1362 2 роки тому

    Thanks very much! 🤣

  • @elnicopons
    @elnicopons 3 роки тому +1

    Excelente video. It helps me a lot. But i have to apply the theme class to the body, not the app-root because if not, the matDialog crash.

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому +1

      Hi Nico! Thanks for your feedback.
      Exactly! I actually covered this case and explained the reason in exactly this video :) Click on this time code: 00:10:35

    • @elnicopons
      @elnicopons 3 роки тому

      @@DecodedFrontend Oh! My bad. I realize i didn't finish the video. Sorry! I also added a service that persists the value selected on localStorage. And it looks great. Thanks again! and sorry

  • @mehedihasansony
    @mehedihasansony 3 роки тому +1

    great video bro. one question though; how to set conditional color as per theme in lazy loading module's style file. don't want to put all my style in the root style file

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому +1

      Hi Mehedi! Thanks for feedback! :) If I understood you right this discussion should help: github.com/angular/angular-cli/issues/5880#issuecomment-499876894
      So you configure and generate different themes separately, so you get separate css file per theme and then programatically you load it when it is needed. I hope it will help

    • @mehedihasansony
      @mehedihasansony 3 роки тому

      @@DecodedFrontend exactly what I was looking for.. thank you a lot.

  • @tekforge
    @tekforge Рік тому +1

    Hi Dmytro, do you recommend using yarn over npm in 2022 (since npm has also improved in the last years), and which versions of them do you like?

    • @DecodedFrontend
      @DecodedFrontend  Рік тому +1

      Hi Rakia! I didn't investigate this question last time but in most cases, I don't see any dramatic difference between those 2 in 2022. I like Yarn more because I got used to it many years ago and I think it is still faster than NPM. Also, Yarn has some features like Plug’n’Play and Zero-Install which npm doesn't support.

    • @tekforge
      @tekforge Рік тому

      I like yarn as well but although I'm still using its version 1.22 and haven't tried its version 2 yet.

    • @DecodedFrontend
      @DecodedFrontend  Рік тому

      @@tekforge I tried yarn 2 just for testing purposes but mostly I use Yarn 1 too :)

  • @22pradeeppathak
    @22pradeeppathak 3 роки тому +1

    Thanks for the video. How can I add my custom theme with my custom colors??

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      Hi! Thanks for your feedback. I am sure you will find an answer in this video: ua-cam.com/video/99T-zQLcluM/v-deo.html 😉

  • @livb4139
    @livb4139 3 роки тому +1

    4:37 I did ng add @angular/material but instead of getting all that scss I only get @import "@angular/material/prebuilt-themes/deeppurple-amber.css"; help pls

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      you most probably have picked some pre-build scheme rather to chose "custom"

  • @tanujsingh8312
    @tanujsingh8312 3 роки тому +3

    how to do preserve the last theme whatever I toggle (dark/light) in my project. If I toggle in dark mode so day after whenever I will open my project I want to see this dark mode again. May you explain this in another video.

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому +3

      Hello! thanks for suggestion. It is quite small topic for a separate video but I implemented this functionality in tutorial's project for you. See this commit: github.com/mezhik91/angular-theming/commit/1b4633a619b81e3903fcce4b161384ad0f513090
      Short explanation: I use local storage in order to store active theme and then in app components inside OnInit I try to read which theme was active last time. If nothing was found in localStorage I use light theme by default.

    • @julianblanco8735
      @julianblanco8735 3 роки тому +1

      You can use LocalStorage and take the value from there

    • @correomaraco1284
      @correomaraco1284 3 роки тому

      @@DecodedFrontend thanks!

  • @kushalbaldev8490
    @kushalbaldev8490 3 роки тому +2

    How did you manage to get the scss file like this and app navigation directory by default? Currently generating new projects didnt have all these stuffs instead they point to specific style.scss file in the styles array inside angular.json

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      Which Angular CLI version do you have?

    • @kushalbaldev8490
      @kushalbaldev8490 3 роки тому

      @@DecodedFrontend 10.1.2 the latest version actually I am trying on the latest version by creating new project to look into this stuff

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      @@kushalbaldev8490 Ah, I think I know what is your problem. The scss file like I have generates not CLI but Angular Material Schematic which is being involved when you run `yarn ng add @angular/material`. Just run `yarn ng add @angular/material` in your root application folder and you will see the dialog which I had and you can pick custom theme

    • @kushalbaldev8490
      @kushalbaldev8490 3 роки тому

      @@DecodedFrontend okk thanks will get back to you after trying..!!🙂

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому

      @@kushalbaldev8490 and navigation folder is just a new component which I created separately in the video. You can use NX extention which I used or run `ng g c navigation` it root folder of your component

  • @syedhannan546
    @syedhannan546 Рік тому +1

    how can I achieve the same using styles.css instead of styles.scss?

    • @DecodedFrontend
      @DecodedFrontend  Рік тому +1

      I am afraid it won’t be possible. You have to use scss to use the mixins shown in the video.

  • @tumpudimuralisaikamalsrika2351
    @tumpudimuralisaikamalsrika2351 4 роки тому +2

    Try to zoom the editor Hard to Read things from there

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому

      Thanks for your feedback and sorry for inconvenience! I fixed this in my next videos.

  • @kennyisaboy
    @kennyisaboy 4 роки тому +1

    Hi, I am using css for my project. How to adapt to this?

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому +1

      Hi! Well, I do not see an easy way to do it. You have actually 2 options:
      1. Very unmaintainable and cumbersome. You can create separately theme.scss file where you configure theme as it was done in the video and then create some script which would build it and put output (css file) in dist folder after application was build. Then you can include this file in index.html.
      2. That's what I would recommend - migration to scss. It is actually easier then it sounds. Actually CSS is a valid scss code. You just have to change file .css extensions to .scss (also inside ts files in Component decorator) and in angular.json file change property style from "css" to "scss" and then you can config your theme as in video. I would say that it would be the best way for you.
      if you want to extent Angular Material Theme you have to always use SCSS because it was written with SCSS and it relays on different functions/mixins which in other pre-processors and plain CSS just do not work.

    • @kennyisaboy
      @kennyisaboy 4 роки тому +1

      @@DecodedFrontend wow, what a great explanation! I think I will go with switching to scss like you recommended. Thanks!

    • @carlosraul6578
      @carlosraul6578 4 роки тому

      use this:
      ua-cam.com/video/2Nmi1sXu12U/v-deo.html

  • @pedrinhofernandes
    @pedrinhofernandes 3 роки тому +3

    Hello, according to the angular material team this not the best approach, it prompts a warning on the console.
    github.com/angular/components/blob/master/guides/duplicate-theming-styles.md
    The change is very simple and it seems to work fine.
    Thanks for the video!

    • @DecodedFrontend
      @DecodedFrontend  3 роки тому +2

      Hi Pedro! You are absolutely right!👍 The way you mentioned is preferable since Angular 10 but this video was published when v10 wasn't even in beta and the latest version was 9.1 :) But it is good that you mentioned about it, so people can see a better way of how to handle this 😉 I am also planning to make remastering for this video when v11 will be out.

    • @larrysinining3845
      @larrysinining3845 3 роки тому +1

      @@DecodedFrontend waiting for version 11 of this :)

    • @larrysinining3845
      @larrysinining3845 3 роки тому

      especially the color theming :D

  • @user-vd9yw5ez3e
    @user-vd9yw5ez3e 2 роки тому +1

    Братюнь, наши в Галівудє?

  • @kushalbaldev8490
    @kushalbaldev8490 3 роки тому

    @Dev Plus Plus I have some other topics which are required in IT industries to take some concrete decisions before building applications in angular is.
    1. Why to use angular material for building apps?
    2. Difference between angular material and bootstrap.
    3. What bootstrap misses which angular material don't have and what angular material misses that bootstrap don't have?
    4. Can we use bootstrap and angular together?
    5. Nx extension that I told in earlier comments like we have schematics in angular material we can generate the same component by angular cli command for material then why to use nx extension?
    6. Some best practises for building angular apps like to unsubscribe behavior subjects after leaving particular scope etc etc.
    7. Difference between subjects and behaviour subjects.
    8. Change in locles that is app supporting two different languages and can change on a switch.
    9. How some common components like we need a window in which the contents are dynamic like there must be only common header else we might be able to set the different components run time.
    10. How to allow to access the child routes to only some person having specific roles. Like from the side nav one can only see some views having guest role and more views having admin role etc etc.somewhat like role based authentication.
    Its up to you how you organise but I have already subscribed it and waiting for these amazing stuffs...!!

  • @carlosraul6578
    @carlosraul6578 4 роки тому +1

    1080p

    • @carlosraul6578
      @carlosraul6578 4 роки тому +1

      very helpful video , thanks a lot bro

    • @DecodedFrontend
      @DecodedFrontend  4 роки тому

      Hey! Thank you for your feedback! Sorry, that was my first video and I didn’t have any 1080p web camera at that time... but in my latest videos you can enjoy fullHD 😉