Things are coming along with SilverStripe 4 alpha and to help keep things clean from the get-go we would like to progress some of our standards and conventions around structure of code, the use of CSS/SCSS and its naming conventions.
As you all know we are basing our styles off Bootstrap 4 which uses some
pretty good conventions but we’re taking the opportunity to build upon those conventions by using
BEM, which is more strict in its use but will help to make the styles more manageable as it grows. We are also liking the simplicity of the
AirBnb guides and are thinking to possibly use this as a first reference.
We’ve done a bit of a test run with some of the work used in Alpha to see if BEM would conflict with Bootstrap and so far there hasn’t really been any major concerns, but of course it's still early days. In addition to this we will be using the principles behind
ITCSS to structure the inclusion of styles. You can take a look at first components to get an idea of how things are structured on
GitHub (keep in mind this is work in progress).
BEM uses double underscores and dashes: .block__elem--mod { }
Block: The sole root of the component.
Element: A component part of the Block.
Modifier: A variant or extension of the Block.
We’re not currently using any prefixing to avoid conflicts for any of our new components but will be considering it as we continue to work making React components.
As always it would be good to hear people's thoughts on any of this stuff.
There's a lot of work ahead for everyone to clean up the front-end of the CMS but its going to be satisfying for sure!