Skip to content

Instantly share code, notes, and snippets.

@sotayamashita
Last active May 8, 2016 07:39
Show Gist options
  • Save sotayamashita/f6c77c5f28ebe07bc2a04ec671c58f3b to your computer and use it in GitHub Desktop.
Save sotayamashita/f6c77c5f28ebe07bc2a04ec671c58f3b to your computer and use it in GitHub Desktop.
Question about ECSS

Question

I understand why ECSS make CSS be isolated but I have a question. Here is two modal components and I cannnot same components. There are buttons which rules are same in each component. According to ECSS I should write same code but I think it is redundant. what would you do in this situation ? Thaks in advance. πŸ˜„

Structure

components           # Presentational Components
.
β”œβ”€β”€ foo-modal
β”‚   β”œβ”€β”€ foo.css
β”‚   └── foo.html
└── hoge-modal
    β”œβ”€β”€ hoge.css
    └── hoge.html

2 directories, 4 files
.foo-Modal_button {
border-radius: 3px;
color: blue;
}
.foo-Modal_button--success {
background: green;
color: white;
}
<div class="foo-Modal" role="dialog" aria-hashup="true">
Lorem ipsum dolor sit amet, consectetur adipisicing elit
<button type="button" class="foo-Modal_button foo-Modal_button-success">OK</button>
</div>
.hoge-Modal_button {
border-radius: 3px;
color: blue;
}
.hoge-Modal_button--success {
background: green;
color: white;
}
.hoge-Modal_button--danger {
background: red;
color: white;
}
<div class="hoge-Modal" role="dialog" aria-hashup="true">
Lorem ipsum dolor sit amet, consectetur adipisicing elit
<button type="button" class="hoge-Modal_button hoge-Modal_button-success">Stay on Page</button>
<button type="button" class="hoge-Modal_button-success hoge-Modal_button-danger">Leave Page</button>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment