Created
August 8, 2016 06:40
-
-
Save gambala/4d1022d42512f588d19c007da2d060e6 to your computer and use it in GitHub Desktop.
OOP-like CSS naming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// css/search-form.scss | |
.search-form { | |
> .field { | |
} | |
} | |
// css/search-form/iconic-button.scss | |
.search-form > .iconic-button { | |
> .icon { | |
} | |
} | |
// css/search-form/-prefixed.scss | |
.search-form.-prefixed { | |
> .prefix { | |
} | |
> .field { | |
} | |
} | |
// css/search-form/-prefixed/iconic-button.scss | |
.search-form.-prefixed > .iconic-button { | |
> .icon { | |
} | |
} | |
// css/search-form/-sm.scss | |
.search-form.-sm { | |
> .field { | |
} | |
} | |
// css/search-form/-sm/iconic-button.scss | |
.search-form.-prefixed > .iconic-button { | |
> .icon { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.search-form | |
.field | |
.iconic-button.-primary | |
.icon | |
.search-form.-prefixed | |
.prefix | |
.field | |
.iconic-button.-primary | |
.icon | |
.search-form.-sm | |
.field | |
.iconic-button.-primary | |
.icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Навеяно подходом RSCSS (сайт, презентация)
Плюсы
>
селектор;Нюансы
Конфликты со стилями подключаемых библиотек
Когда возникает: Подключаемая js-библиотека использует классы такие же, как классы элементов.
Что происходит: Стили js-библиотеки применяются ко всем элементам с такими же классами.
Как решить: В проекте явно обнулить стили элементов, и уточнить во вложенных стилях js-библиотеки.