Project
Define patterns which are unique to the project which consists of several components and other elements.
Elements that make up contents for your project come under this layer, such as an article list, user profile, or image gallery.
Original FLOCLSS is defined the above, but it's hard to categorize in case of Web site project, there are many unique styles for each page, so we define Project as Define patterns which are unique layout for each page.
You must use .p- prefix for Project.
File naming rules
Project is created for each page, so name the files after the URL.
- Files: the slashes (/) of the URL become folders. A page with child pages uses
_index.scssin its folder, and a page without child pages sits directly underobject/project/. - Classes: the slashes (/) of the URL are replaced with hyphens (-).
The top page is "_index.scss".
- http://example.com/
- object/project/_index.scss
.p-index
- http://example.com/about/ (no child pages)
- object/project/_about.scss
.p-about
- http://example.com/product/ (has child pages)
- object/project/product/_index.scss
.p-product
- http://example.com/product/foo/
- object/project/product/_foo.scss
.p-product-foo
Posts that share one template, such as news posts (http://example.com/news/xxx/), use _detail.scss in the folder of their archive.
- http://example.com/news/
- object/project/news/_index.scss
.p-news
- http://example.com/news/xxx/
- object/project/news/_detail.scss
.p-news-detail
Add each new file to style.scss.
@import "object/project/index";
@import "object/project/about";
@import "object/project/product/index";
@import "object/project/product/foo";
Example
<div class="p-index">
<section class="p-index__section">
<h2 class="p-index__section__head">SECTION TITLE</h2>
<ul class="p-index__section__nav">
<li class="p-index__section__nav__item">
<a href="#" class="c-button p-index__section__nav__anchor">BUTTON</a>
</li>
</ul>
</section>
</div>
.p-index {
&__section {
// something style
&__head {
// something style
}
&__nav {
// something style
&__item {
// something style
}
&__anchor {
// something style
}
}
}
}
This Example Project has has Component (.c-button), but you must NOT overwrite styles of those inside of Project. Please make Child Project (.p-index__section__nav__anchor), then you can define the style of that element.
Reference : Don't include other component