Get Your CSS Organized with These 5 Tips! (with Astro Example)

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 17

  • @visua1hue-dev
    @visua1hue-dev 12 дней назад +1

    More to Astro please ;P - great video

    • @dmtrmrv
      @dmtrmrv  12 дней назад +1

      Thank you! Glad you enjoyed it!

  • @HarryPujols
    @HarryPujols 12 дней назад +3

    Using css @import is fine now? I always avoided it because it was supposedly slow.

    • @dmtrmrv
      @dmtrmrv  12 дней назад

      Great question! it depends on the context. Vanilla CSS @imports are considered an antipattern because they create another request to the server. In the case of Astro, they aren't treated that way. Astro is smart enough to bundle multiple CSS files together. It is like this for many other frameworks.

    • @mrparadox165
      @mrparadox165 7 дней назад

      ​@@dmtrmrvSo which is the best way to organize CSS style in vanilla CSS? Do you suggest to use one CSS file full of comments, divided in token, global etc, use html tag to add different css stylesheets or use @import rule even if it is antipattern?
      Thanks for your amazing content!

    • @dmtrmrv
      @dmtrmrv  6 дней назад +1

      @mrparadox165 It depends on the project, tbh. Even if you’re sticking with vanilla CSS, Vite is super easy to set up. You can write vanilla CSS, split it into multiple files, and have it all compiled into one file at the end similar to some of my demos: github.com/dmtrmrv/demo-content-width

    • @mrparadox165
      @mrparadox165 6 дней назад

      @@dmtrmrv Many thanks!

  • @rodrigonovais9624
    @rodrigonovais9624 13 дней назад

    7:30 why not use layers?

    • @dmtrmrv
      @dmtrmrv  13 дней назад +1

      Really good question! Mostly because of my work habits. Some of our projects get a lot of traffic, and even though @layers is baseline now, there's still a chunk of users on browsers that don't support it. If we have 1M page views and 0.5% are on IE11 (God forbid), that's 5k people seeing a broken site. And polyfills are a bit ugly. I'm cautious about using new foundational features. That said, for my personal site, it's a great alternative to the approach mentioned in that video.

    • @dmtrmrv
      @dmtrmrv  13 дней назад +1

      I talk more about my approach to new CSS features in this video btw: ruclips.net/video/WIvQLSPcvtA/видео.html

    • @HarryPujols
      @HarryPujols 12 дней назад

      @@dmtrmrv I think the current implementation of css layers are unusable because how they treat the !important qualifier. Even if I never use it, I still have to use vendor files for plugins, and a lot of them use !important

    • @HarryPujols
      @HarryPujols 12 дней назад

      Another weird thing about @layers is that it wasn’t working in Opera desktop Mac at the time of this writing even though it’s supposed to have full support.

    • @dmtrmrv
      @dmtrmrv  12 дней назад

      @@HarryPujols @rodrigonovais9624 another great point on why @layers isn't always a good idea!

  • @moneyfr
    @moneyfr 13 дней назад

    you should use vanilla extract css

    • @dmtrmrv
      @dmtrmrv  13 дней назад

      Thanks for the suggestion