Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Angular Template Angular Template
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • IzeniIzeni
  • Angular TemplateAngular Template
  • Wiki
  • sass with bem

sass with bem · Changes

Page history
jlewis created page: sass with bem authored May 08, 2017 by Joe Lewis's avatar Joe Lewis
Hide whitespace changes
Inline Side-by-side
sass-with-bem.md 0 → 100644
View page @ e9336032
# Shadow Dom Emulation
### Allows for scope isolation of css classes. There are other benifits but in this case if two components that are on the page at the same time both have a class called container but are defined differently there wont be a collision. THIS DOES NOT MEAN DONT BEM YOU STYLES.
```javascript
import { Component, OnInit, OnDestroy, ViewContainerRef, ViewEncapsulation } from '@angular/core';
import { MdDialog, MdDialogRef, MdDialogConfig } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { AuthService, ToastService, ConfirmComponent, Data } from '../shared';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
encapsulation: ViewEncapsulation.Emulated
})
```
## Izeni sass, y'all
Unfortunately, there is currently no support for sourceMaps or style injection, which will eventually greatly benefit our UI development process when they become available.
#### [here are our Izeni HTML/CSS conventions](https://dev.izeni.net/nbills/izeni-css-conventions), which should be adopted by all, in addition to best practices found in [style guides](toolbox)
### defaults, typography, globals
* These files are imported **ONCE**, on a global level, via angular-cli.json
### breakpoints, functions, mixins, variables
* These files are imported into globals.scss or component scss files as needed.
* For this reason, no actual rules (i.e. `.selector {}`) should be added to these four files, or those rules would be unnecessarily repeated anywhere they are imported.
### component styles
* If a style is used cross-component (i.e. buttons, headings, etc), it should probably be defined in globabls.scss.
* Otherwise, the style is only applicable to a specific component and those styles should go in the component's scss file, e.g. `home.component.scss`.
* [Angular 2 component styles](https://angular.io/docs/ts/latest/guide/component-styles.html)
- we'll stick to default ViewEncapsulation (see link above) for now
- tl:dr; Angular takes the css generated by sass-loader after parsing the scss file, adds it's own attribute string to each rule (unique to each component), and then makes sure that anything that matches those rules' selectors gets that same attribute, thus namespacing css for us (somewhat emulating this aspect of the impending DOM encapsulation technologies)
- even though this is neat, we should still use BEM for a variety of reasons, including: scss file maintainability, html readability, etc.
\ No newline at end of file
Clone repository
  • angular
  • cookbook forms
  • cookbook routing
  • data store
  • gotchas
  • Home
  • modals
  • sass with bem
  • toolbox
  • typescript
  • webpack