CSS selectors all exist within the same global scope. Anyone who has worked with CSS long enough has had to come to terms with its aggressively global nature — a model clearly designed in the age of documents, now struggling to offer a sane working environment for today’s modern web applications. Every selector has the potential to have unintended side effects by targeting unwanted elements or clashing with other selectors. More surprisingly, our selectors may even lose out in the global specificity war, ultimately having little or no effect on the page at all.
Any time we make a change to a CSS file, we need to carefully consider the global environment in which our styles will sit. No other front end technology requires so much discipline just to keep the code at a minimum level of maintainability. But it doesn’t have to be this way. It’s time to leave the era of global style sheets behind.
It’s time for local CSS.
In other languages, it’s accepted that modifying the global environment is something to be done rarely, if ever.
In the JavaScript community, thanks to tools like Browserify, Webpack and JSPM, it’s now expected that our code will consist of small modules, each encapsulating their explicit dependencies, exporting a minimal API.
Yet, somehow, CSS still seems to be getting a free pass.
Many of us — myself included, until recently — have been working with CSS so long that we don’t see the lack of local scope as a problem that we can solve without significant help from browser vendors. Even then, we’d still need to wait for the majority of our users to be using a browser with proper Shadow DOM support.
We’ve worked around the issues of global scope with a series of naming conventions like OOCSS, SMACSS, BEM and SUIT, each providing a way for us to avoid naming collisions and emulate sane scoping rules.
We no longer need to add lengthy prefixes to all of our selectors to simulate scoping. More components could define their own foo and bar identifiers which — unlike the traditional global selector model—wouldn’t produce any naming collisions.
import styles from './MyComponent.css'; import React, { Component } from 'react'; export default class MyComponent extends Component { render() { return ( <div> <div className={styles.foo}>Foo</div> <div className={styles.bar}>Bar</div> </div> ); }
The benefits of global CSS — style re-use between components via utility classes, etc. — are still achievable with this model. The key difference is that, just like when we work in other technologies, we need to explicitly import the classes that we depend on. Our code can’t make many, if any, assumptions about the global environment.
Writing maintainable CSS is now encouraged, not by careful adherence to a naming convention, but by style encapsulation during development.
Once you’ve tried working with local CSS, there’s really no going back. Experiencing true local scope in our style sheets — in a way that works across all browsers— is not something to be easily ignored.
Introducing local scope has had a significant ripple effect on how we approach our CSS. Naming conventions, patterns of re-use, and the potential extraction of styles into separate packages are all directly affected by this shift, and we’re only at the beginning of this new era of local CSS.
process.env.NODE_ENV === 'development' ? '[name]__[local]___[hash:base64:5]' : '[hash:base64:5]' )
Understanding the ramifications of this shift is something that we’re still working through. With your valuable input and experimentation, I’m hoping that this is a conversation we can have together as a larger community.
Note: Automatically optimising style re-use between components would be an amazing step forward, but it definitely requires help from people a lot smarter than me.
❤️ Terri is interested in your profile! Click Here: http://bit.do/fSNfb ❤️
קמגרה למכירה במודיעין פעמים רבות אנחנו יודעים שאנחנו צריכים לעשות משהו, אבל “רק הפעם” פשוט נמנעים מלעשות את זה, פשוט כי זה דורש יותר מדי מאמץ. אותו הדבר ������� ������� ��� �������
קמגרה למכירה בהרצליה אנשים באים אליה מהצפון, מהמרכז ומהדרום. לא לחינם נחשבת הרצליה לאחת מהערים המובילות בישראל בתחום הפנאי והבילויים. הרצליה היא עיר תוססת, עם מפגשים אנושיים רבים, metamask token factory example
❤️ Aria want to meet you! Click Here: http://inx.lv/p0Df ❤️
❤️ You have unread messages from Nikki (2)! Click Here: http://bit.do/fSTHz ❤️
❤️ Ann want to meet you! Click Here: http://inx.lv/p0Df ❤️
❤️ Carmen is interested in your profile! Click Here: http://bit.do/fSUSV ❤️
❤️ Biswap & LaunchZone Winter Event | Share $5 000! Click Here: https://telegra.ph/Biswap–LaunchZone-Winter-Event–Share-5-000-12-28 ❤️
Best dating worldwide! Click Here: https://bit.ly/3n0BD6D
❤️ Christy want to meet you! Click Here: https://bit.ly/3ruce6F ❤️
N-Lone-D300 | Nandrolone Decanoate buy online
🎁 Congratulations Artificial intelligence itself writes articles and places them on the web, and itself posts in wordpress. more details on the website https://stanford.io/3G7Hfmp 🎁
I have to thank you for the efforts you have put in writing this site. Im hoping to see the same high-grade content from you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal blog now 😉 I have to thank you for the efforts you have put in writing this site. Im hoping to see the same high-grade content from you later on as well. In truth, your creative writing abilities has inspired me to get my own, personal blog now 😉 Visit %url_domain%
Качественные WordPress ссылки в комментариях от 5000 уник. доменов заказать здесь .
Quality WordPress links in the comments from 5000 uniques. domains order here.
I don’t need to tell you how important it is to optimize every step in your SEO pipeline. But unfortunately, it’s nearly impossible to cut out time or money when it comes to getting good content. At least that’s what I thought until I came across Article Forge… Built by a team of AI researchers from MIT, Carnegie Mellon, Harvard, Article Forge is an artificial intelligence (AI) powered content writer that uses deep learning models to write entire articles about any topic in less than 60 seconds. Their team trained AI models on millions of articles to teach Article Forge how to draw connections between topics so that each article it writes is relevant, interesting and useful. All their hard work means you just enter a few keywords and Article Forge will write a complete article from scratch making sure every thought flows naturally into the next, resulting in readable, high quality, and unique content. Put simply, this is a secret weapon for anyone who needs content. I get how impossible that sounds so you need to see how Article Forge writes a complete article in less than 60 seconds! order here.
I was pretty pleased to discover this great site. I need to to thank you for your time for this particularly fantastic read!! I definitely appreciated every part of it and I have you book marked to see new stuff on your blog