Skip to content

Instantly share code, notes, and snippets.

@sekky0905
Last active September 21, 2017 04:56
Show Gist options
  • Save sekky0905/af26d51448886c2dd5736a1a17696643 to your computer and use it in GitHub Desktop.
Save sekky0905/af26d51448886c2dd5736a1a17696643 to your computer and use it in GitHub Desktop.
CSSの設計方法をまとめてみた~SUIT CCS編~(Angularによるサンプル付き) ref: http://qiita.com/Sekky0905/items/605d23d8287fd4c160b4
<p class="u-floatLeft">hoge</p>
.ComponentName{...}
.ComponentName--modifierName{...}
.Compomnent{}
.Compomnent.is-stateOfComponent{}
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss', './utilities.scss']
})
export class AppComponent {
contentsTitle = 'SUIT CSS!';
contentsHeading = 'design principles';
designPrinciples = ['Modularity', 'Cohesion', 'Composition and configuration', 'Loose coupling', 'Soft encapsulation', 'Documentation'];
clazz = 'AppComponent is-coloredBlack';
/**
* 文字を赤くする
*/
changeColorToRed() {
this.clazz = 'AppComponent is-coloredRed';
}
}
<!--Component Name-->
<article class="AppComponent">
<!--ComponentName-descendentName-->
<header class="AppComponent-header">
<h1>{{contentsTitle}}</h1>
</header>
<!--ComponentName-descendentName-->
<div class="AppComponent-content">
<!--ComponentName.is-stateOfComponent-->
<h1 [class]="clazz" (click)="changeColorToRed()">{{contentsHeading}}</h1>
<!--utilities-->
<ul class=" u-listStyleNone">
<li *ngFor="let p of designPrinciples">
{{p}}
</li>
</ul>
</div>
</article>
/*AppComponentに対するstyle*/
.AppComponent {
width: 100%;
.AppComponent-header {
color: #0000ed;
}
.AppComponent-content {
color: #3A3A3A;
}
.is-coloredBlack {
color: black;
}
.is-coloredRed {
color: red;
}
}
@charset "UTF-8";
/*AppComponentに対するstyle*/
.AppComponent {
width: 100%;
}
.AppComponent .AppComponent-header {
color: #0000ed;
}
.AppComponent .AppComponent-content {
color: #3A3A3A;
}
.AppComponent .is-coloredBlack {
color: black;
}
.AppComponent.is-coloredRed {
color: red;
}
/*listの点を消す*/
.u-listStyleNone {
list-style: none;
}
@charset "UTF-8";
/*listの点を消す*/
.u-listStyleNone {
list-style: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment