diff --git a/README.md b/README.md index 6f8acac7..975d05b4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# Code Guide +# frontendanon code guide + +Fork "Русская версия руководства по написанию кода от @mdo http://sadcitizen.me/code-guide/" Code Guide is a project for documenting standards for developing flexible, durable, and sustainable HTML and CSS. It comes from years of experience writing code on projects of all sizes. It's not the end-all be-all, but it's a start. -**[Start reading ☞](http://mdo.github.io/code-guide)** +**[Start reading ☞](https://gitanon.github.io/code-guide/)** --- @@ -13,18 +15,3 @@ Released under MIT by, and copyright 2014, @mdo. ### Thanks Heavily inspired by [Idiomatic CSS](https://github.com/necolas/idiomatic-css) and the [GitHub Styleguide](http://github.com/styleguide). - -### Translations - -Translations are maintained by their creators and may not always be up to date with the original here. - -- [Portuguese](http://diegoeis.github.io/code-guide/) - Translated by [Diego Eis](http://tableless.com.br/) -- [Spanish](http://adrianayala.mx/code-guide/es/) - Translated by [Adrian Ayala](http://adrianayala.mx/) -- [Indonesian](http://diagramatics.github.io/code-guide-id) - Translated by [Steven Sinatra](http://diagramatics.me) -- [Chinese](http://zoomzhao.github.io/code-guide/) - Translated by [Zoom Zhao](https://github.com/ZoomZhao) -- [Italian](http://alessandro1997.github.io/code-guide/) - Translated by [Alessandro Desantis](https://github.com/alessandro1997) -- [Russian](http://sadcitizen.github.io/code-guide/) - Translated by [Eugene Abrosimov](https://github.com/sadcitizen) - -Have a translation you'd like to link to? Open a pull request to add it. - -<3 diff --git a/_config.yml b/_config.yml index 7b45087e..1fe3ae7d 100644 --- a/_config.yml +++ b/_config.yml @@ -1,7 +1,7 @@ -name: Руководство по написанию кода от @mdo -description: Стандарты для разработки гибкого, надежного и поддерживаемого кода на HTML и CSS. +name: Руководство по написанию кода frontendanon +description: Стандарты для разработки гибкого, надежного и поддерживаемого кода на Pug(Jade) и Stylus. url: http://mdo.github.com/code-guide markdown: rdiscount permalink: pretty -pygments: true +rouge: true diff --git a/_includes/css/class-names.css b/_includes/css/class-names.css index c450cbb1..f5595cbc 100644 --- a/_includes/css/class-names.css +++ b/_includes/css/class-names.css @@ -1,9 +1,17 @@ /* Плохой пример */ -.t { ... } -.red { ... } -.header { ... } +.t + ... +.red + ... +.header + ... /* Хороший пример */ -.tweet { ... } -.important { ... } -.tweet-header { ... } +.tweet + ... + +.important + ... + +.tweet-header + ... diff --git a/_includes/css/comments.css b/_includes/css/comments.css index 49ad3b5c..902f404d 100644 --- a/_includes/css/comments.css +++ b/_includes/css/comments.css @@ -1,11 +1,9 @@ /* Плохой пример */ /* Modal header */ -.modal-header { +.modal-header ... -} /* Хороший пример */ /* Обертывающий элемент для .modal-title и .modal-close */ -.modal-header { +.modal-header ... -} diff --git a/_includes/css/declaration-order.css b/_includes/css/declaration-order.css index 0b3eff21..a6f7725a 100644 --- a/_includes/css/declaration-order.css +++ b/_includes/css/declaration-order.css @@ -1,29 +1,19 @@ -.declaration-order { - /* Позиционирование */ - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 100; - - /* Блочная модель */ - display: block; - float: right; - width: 100px; - height: 100px; - - /* Типографика */ - font: normal 13px "Helvetica Neue", sans-serif; - line-height: 1.5; - color: #333; - text-align: center; - - /* Отображение */ - background-color: #f5f5f5; - border: 1px solid #e5e5e5; - border-radius: 3px; - - /* Прочее */ - opacity: 1; -} +.declaration-order + background-color #f5f5f5 + border 1px solid #e5e5e5 + border-radius 3px + bottom 0 + color #333 + display block + font normal 13px "Helvetica Neue", sans-serif + height 100px + left 0 + float right + line-height 1.5 + opacity 1 + position absolute + right 0 + text-align center + top 0 + width 100px + z-index 100 diff --git a/_includes/css/media-queries.css b/_includes/css/media-queries.css index 7440c7a3..22f03a95 100644 --- a/_includes/css/media-queries.css +++ b/_includes/css/media-queries.css @@ -1,9 +1,18 @@ -.element { ... } -.element-avatar { ... } -.element-selected { ... } - -@media (min-width: 480px) { - .element { ...} - .element-avatar { ... } - .element-selected { ... } -} +.element + ... + +.element-avatar + ... + +.element-selected + ... + +@media (min-width: tablet) + .element + ... + + .element-avatar + ... + + .element-selected + ... diff --git a/_includes/css/nesting.scss b/_includes/css/nesting.scss index 5f4194c2..a83875d2 100644 --- a/_includes/css/nesting.scss +++ b/_includes/css/nesting.scss @@ -1,9 +1,13 @@ // Без вложенности -.table > thead > tr > th { … } -.table > thead > tr > td { … } +.table > thead > tr > th + ... +.table > thead > tr > td + ... // С вложенностью -.table > thead > tr { - > th { … } - > td { … } -} +.table > thead > tr + > th + ... + > td + ... + diff --git a/_includes/css/organization-comments.css b/_includes/css/organization-comments.css index 6320eb1a..2fce4d7d 100644 --- a/_includes/css/organization-comments.css +++ b/_includes/css/organization-comments.css @@ -2,7 +2,8 @@ * Заголовок раздела для компонента */ -.element { ... } +.element + ... /* @@ -11,7 +12,9 @@ * Иногда возникает необходимость включения дополнительного контекста для всего компонента. Сделайте это в этом месте, если это достаточно важно. */ -.element { ... } +.element + ... /* Контекстный под-компонент или модификатор */ -.element-heading { ... } +.element_heading + ... diff --git a/_includes/css/prefixed-properties.css b/_includes/css/prefixed-properties.css index 789d4858..ba91c45e 100644 --- a/_includes/css/prefixed-properties.css +++ b/_includes/css/prefixed-properties.css @@ -1,5 +1,3 @@ /* Свойства с префиксами */ -.selector { - -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15); - box-shadow: 0 1px 2px rgba(0,0,0,.15); -} +.selector + box-shadow: 0 1px 2px rgba(0,0,0,.15) diff --git a/_includes/css/selectors.css b/_includes/css/selectors.css index 1f8e4477..5342ca91 100644 --- a/_includes/css/selectors.css +++ b/_includes/css/selectors.css @@ -1,9 +1,18 @@ /* Плохой пример */ -span { ... } -.page-container #stream .stream-item .tweet .tweet-header .username { ... } -.avatar { ... } +span + ... +.page-container #stream .stream-item .tweet .tweet-header .username + ... +.avatar + ... /* Хороший пример */ -.avatar { ... } -.tweet-header .username { ... } -.tweet .avatar { ... } +.avatar + ... + +.tweet-header .username + ... + +.tweet .avatar + ... + diff --git a/_includes/css/set.css b/_includes/css/set.css new file mode 100644 index 00000000..01cd556f --- /dev/null +++ b/_includes/css/set.css @@ -0,0 +1,38 @@ +.element + ... + +.element-avatar + ... + +.element-selected + ... + +@media (min-width: tablet) + .element + ... + + .element-avatar + ... + + .element-selected + ... + +@media (min-width: screen) + .element + ... + + .element-avatar + ... + + .element-selected + ... + +@media (min-width: screen_large) + .element + ... + + .element-avatar + ... + + .element-selected + ... diff --git a/_includes/css/shorthand.css b/_includes/css/shorthand.css index 34cae1c2..100bc81a 100644 --- a/_includes/css/shorthand.css +++ b/_includes/css/shorthand.css @@ -1,16 +1,14 @@ /* Плохой пример */ -.element { - margin: 0 0 10px; - background: red; - background: url("http://github.com/image.jpg"); - border-radius: 3px 3px 0 0; -} +.element + margin 0 0 10px + background red + background url("http://github.com/image.jpg") + border-radius 3px 3px 0 0 /* Хороший пример */ -.element { - margin-bottom: 10px; - background-color: red; - background-image: url("http://github.com/image.jpg"); - border-top-left-radius: 3px; - border-top-right-radius: 3px; -} +.element + margin-bottom 10px + background-color red + background-image url("http://github.com/image.jpg") + border-top-left-radius 3px + border-top-right-radius 3px diff --git a/_includes/css/single-declarations.css b/_includes/css/single-declarations.css index 7c44275a..2488a46b 100644 --- a/_includes/css/single-declarations.css +++ b/_includes/css/single-declarations.css @@ -1,15 +1,21 @@ -/* Одиночные объявления в одну строчку */ -.span1 { width: 60px; } -.span2 { width: 140px; } -.span3 { width: 220px; } +/* Одиночные объявления */ +.span1 + width 60px +.span2 + width 140px +.span3 + width 220px /* Несколько объявлений, по одному на каждую строчку */ -.sprite { - display: inline-block; - width: 16px; - height: 15px; - background-image: url(http://github.com/img/sprite.png); -} -.icon { background-position: 0 0; } -.icon-home { background-position: 0 -20px; } -.icon-account { background-position: 0 -40px; } +.sprite + display inline-block + width 16px + height 15px + background-image url(http://github.com/img/sprite.png) + +.icon + background-position 0 0 +.icon-home + background-position 0 -20px +.icon-account + background-position 0 -40px diff --git a/_includes/css/syntax.css b/_includes/css/syntax.css index a7023dff..a435b94d 100644 --- a/_includes/css/syntax.css +++ b/_includes/css/syntax.css @@ -1,4 +1,4 @@ -/* Плохой CSS */ +/* Плохой Stylus */ .selector, .selector-secondary, .selector[type=text] { padding:15px; margin:0px 0px 15px; @@ -6,12 +6,11 @@ box-shadow:0 1px 2px #CCC,inset 0 1px 0 #FFFFFF } -/* Хороший CSS */ +/* Хороший Stylus */ .selector, .selector-secondary, -.selector[type="text"] { - padding: 15px; - margin: 0 0 15px; - background-color: rgba(0,0,0,.5); - box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff; -} +.selector[type="text"] + padding 15px + margin 0 0 15px + background-color rgba(0,0,0,0.5) + box-shadow 0 1px 2px #ccc, inset 0 1px 0 #fff diff --git a/_includes/html/attribute-order.html b/_includes/html/attribute-order.html index f4971679..43909702 100644 --- a/_includes/html/attribute-order.html +++ b/_includes/html/attribute-order.html @@ -1,7 +1,5 @@ - - Какая-то ссылка - +a(class="..." id="..." data-modal="toggle" href="#") Какая-то ссылка - +input(class="form-control" type="text") -... +img(src="http://github.com/..." alt="...") diff --git a/_includes/html/boolean-attributes.html b/_includes/html/boolean-attributes.html index c1ba6320..343b9fc8 100644 --- a/_includes/html/boolean-attributes.html +++ b/_includes/html/boolean-attributes.html @@ -1,7 +1,6 @@ - +input(type="text" disabled) - +input(type="checkbox" value="1" checked) - +select + option(value="1" selected) 1 diff --git a/_includes/html/doctype.html b/_includes/html/doctype.html index da20eb1b..cdd6afea 100644 --- a/_includes/html/doctype.html +++ b/_includes/html/doctype.html @@ -1,5 +1,3 @@ - - - - +html + head diff --git a/_includes/html/encoding.html b/_includes/html/encoding.html index 9cb22cb4..920909a6 100644 --- a/_includes/html/encoding.html +++ b/_includes/html/encoding.html @@ -1,3 +1,2 @@ - - - +head + meta(charset="UTF-8") \ No newline at end of file diff --git a/_includes/html/ie-compatibility-mode.html b/_includes/html/ie-compatibility-mode.html index cc2d32ed..2d225ca7 100644 --- a/_includes/html/ie-compatibility-mode.html +++ b/_includes/html/ie-compatibility-mode.html @@ -1 +1 @@ - +meta(http-equiv="X-UA-Compatible" content="IE=Edge") diff --git a/_includes/html/lang.html b/_includes/html/lang.html index d00dbf02..0a3eb869 100644 --- a/_includes/html/lang.html +++ b/_includes/html/lang.html @@ -1,3 +1 @@ - - - \ No newline at end of file +html(lang="en-us") diff --git a/_includes/html/reducing-markup.html b/_includes/html/reducing-markup.html index 5fe7e2dc..ee07e299 100644 --- a/_includes/html/reducing-markup.html +++ b/_includes/html/reducing-markup.html @@ -1,7 +1,6 @@ - - - +span(class="avatar") + img(src="http://github.com/...") - +img(class="avatar" src="http://github.com/...") diff --git a/_includes/html/style-script.html b/_includes/html/style-script.html index d41179cb..1d8ce087 100644 --- a/_includes/html/style-script.html +++ b/_includes/html/style-script.html @@ -1,10 +1,9 @@ - +link(rel="stylesheet", href="http://github.com/css/main.css") - - +script(src="http://github.com/js/main.js") diff --git a/_includes/html/syntax.html b/_includes/html/syntax.html index 4df0fc97..896c4452 100644 --- a/_includes/html/syntax.html +++ b/_includes/html/syntax.html @@ -1,10 +1,13 @@ - - - Заголовок страницы - - - Company -

Привет, мир!

- - +html(lang="en-us") + head + meta(charset="UTF-8") + meta(http-equiv="X-UA-Compatible" content="IE=Edge") + meta(name="viewport" content="width=device-width,initial-scale=1") + title Title page + link(rel="stylesheet", href="http://github.com/css/main.css") + body.page + include blocks/header/header.pug + ... + include blocks/text/text.pug + script(src="http://github.com/js/main.js") diff --git a/code-guide.css b/code-guide.css index e1281bdd..3cc653ee 100644 --- a/code-guide.css +++ b/code-guide.css @@ -52,11 +52,11 @@ html { body { margin: 0; font: 1rem/1.5 "PT Sans", sans-serif; - color: #5a5a5a; + color: #34495e; } a { - color: #08c; + color: #3498db; text-decoration: none; } a:hover { @@ -67,7 +67,7 @@ h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: normal; line-height: 1; - color: #2a2a2a; + color: #2c3e50; letter-spacing: -.05em; } h1 { font-size: 3rem; } @@ -188,12 +188,12 @@ pre code { .masthead { padding: 3rem 1rem; - color: rgba(255,255,255,.5); + color: rgba(44,62,80,.5); text-align: center; - background-color: #2a3440; + background-color: #ecf0f1; } .masthead h1 { - color: #fff; + color: #2c3e50; margin-bottom: .25rem; } .masthead .icon { @@ -205,12 +205,12 @@ pre code { font-size: 2rem; } .masthead-links a { - color: rgba(255,255,255,.5); + color: rgba(44,62,80,.5); text-decoration: none; transition: all .15s linear; } .masthead-links a:hover { - color: #fff; + color: #2c3e50; } @media (min-width: 38rem) { @@ -227,7 +227,7 @@ pre code { .heading { padding: 2rem 1rem 1.5rem; - background-color: #dfe1e8; + background-color: #bdc3c7; } @media (min-width: 38rem) { @@ -237,7 +237,7 @@ pre code { } .section { - border-bottom: 1px solid #dfe1e8; + border-bottom: 1px solid #95a5a6; } diff --git a/index.html b/index.html index 50cb48a4..9f181480 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,7 @@

HTML

CSS

@@ -204,7 +216,22 @@

Разметка, генерируемая с помощью JavaScript

-

CSS

+

Stylus

+
+ +
+
+

Подход к разработке стилей

+
    Mobile first использующий следующие разрешения: +
  • mobile (экраны шириной от 0 до 640px), стили пишутся без использования медия выражений
  • +
  • tablet = 40em (экраны шириной от 640px и больше), стили пишутся в медиа выражении @media (min-width: tablet)
  • +
  • screen = 64em (экраны шириной от 1024px и больше), стили пишутся в медиа выражении @media (min-width: screen)
  • +
  • screen_large = 90em (экраны шириной от 1440px и больше), стили пишутся в медиа выражении @media (min-width: screen_large)
  • +
+
+
+ {% highlight css %}{% include css/set.css %}{% endhighlight %} +
@@ -213,14 +240,12 @@

Синтаксис