diff --git a/Readme.md b/Readme.md index 8d23780..947d906 100644 --- a/Readme.md +++ b/Readme.md @@ -1,21 +1,21 @@ -# Стиль кода Академии HTML -Стиль кода можно [посмотреть тут](https://codeguide.academy/). +# Стиль кода .html academy + +Это исходники, публичная версия на сайте [codeguide.academy](https://codeguide.academy/). ## Благодарности * [Code Guide](http://codeguide.co) by @mdo * [CSS Guidelines](http://cssguidelin.es) by Harry Roberts * [Idiomatic CSS](https://github.com/necolas/idiomatic-css) by Nicolas Gallagher -* [Primer Guidelines](https://styleguide.github.com/primer/principles/) by GitHub +* [Primer Guidelines](https://primer.style/css/) by GitHub ## Лицензия -Лицензия MIT, смотрите файл `License.md`. - -## Конфигурации линтеров - -ESLint — https://github.com/htmlacademy/eslint-config-htmlacademy +[MIT](./License.md). -Stylelint — https://github.com/htmlacademy/stylelint-config-htmlacademy +## Правила линтеров -linthtml — https://github.com/htmlacademy/linthtml-config-htmlacademy +* [EditorConfig](.editorconfig) +* [ESLint](https://github.com/htmlacademy/eslint-config-htmlacademy) +* [Stylelint](https://github.com/htmlacademy/stylelint-config-htmlacademy) +* [HTMLHint](https://github.com/htmlacademy/htmlhint-config-htmlacademy) diff --git a/css/normalize.css b/css/normalize.css deleted file mode 100644 index 192eb9c..0000000 --- a/css/normalize.css +++ /dev/null @@ -1,349 +0,0 @@ -/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ - -/* Document - ========================================================================== */ - -/** - * 1. Correct the line height in all browsers. - * 2. Prevent adjustments of font size after orientation changes in iOS. - */ - -html { - line-height: 1.15; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ -} - -/* Sections - ========================================================================== */ - -/** - * Remove the margin in all browsers. - */ - -body { - margin: 0; -} - -/** - * Render the `main` element consistently in IE. - */ - -main { - display: block; -} - -/** - * Correct the font size and margin on `h1` elements within `section` and - * `article` contexts in Chrome, Firefox, and Safari. - */ - -h1 { - font-size: 2em; - margin: 0.67em 0; -} - -/* Grouping content - ========================================================================== */ - -/** - * 1. Add the correct box sizing in Firefox. - * 2. Show the overflow in Edge and IE. - */ - -hr { - box-sizing: content-box; /* 1 */ - height: 0; /* 1 */ - overflow: visible; /* 2 */ -} - -/** - * 1. Correct the inheritance and scaling of font size in all browsers. - * 2. Correct the odd `em` font sizing in all browsers. - */ - -pre { - font-family: monospace, monospace; /* 1 */ - font-size: 1em; /* 2 */ -} - -/* Text-level semantics - ========================================================================== */ - -/** - * Remove the gray background on active links in IE 10. - */ - -a { - background-color: transparent; -} - -/** - * 1. Remove the bottom border in Chrome 57- - * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. - */ - -abbr[title] { - border-bottom: none; /* 1 */ - text-decoration: underline; /* 2 */ - text-decoration: underline dotted; /* 2 */ -} - -/** - * Add the correct font weight in Chrome, Edge, and Safari. - */ - -b, -strong { - font-weight: bolder; -} - -/** - * 1. Correct the inheritance and scaling of font size in all browsers. - * 2. Correct the odd `em` font sizing in all browsers. - */ - -code, -kbd, -samp { - font-family: monospace, monospace; /* 1 */ - font-size: 1em; /* 2 */ -} - -/** - * Add the correct font size in all browsers. - */ - -small { - font-size: 80%; -} - -/** - * Prevent `sub` and `sup` elements from affecting the line height in - * all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sub { - bottom: -0.25em; -} - -sup { - top: -0.5em; -} - -/* Embedded content - ========================================================================== */ - -/** - * Remove the border on images inside links in IE 10. - */ - -img { - border-style: none; -} - -/* Forms - ========================================================================== */ - -/** - * 1. Change the font styles in all browsers. - * 2. Remove the margin in Firefox and Safari. - */ - -button, -input, -optgroup, -select, -textarea { - font-family: inherit; /* 1 */ - font-size: 100%; /* 1 */ - line-height: 1.15; /* 1 */ - margin: 0; /* 2 */ -} - -/** - * Show the overflow in IE. - * 1. Show the overflow in Edge. - */ - -button, -input { /* 1 */ - overflow: visible; -} - -/** - * Remove the inheritance of text transform in Edge, Firefox, and IE. - * 1. Remove the inheritance of text transform in Firefox. - */ - -button, -select { /* 1 */ - text-transform: none; -} - -/** - * Correct the inability to style clickable types in iOS and Safari. - */ - -button, -[type="button"], -[type="reset"], -[type="submit"] { - -webkit-appearance: button; -} - -/** - * Remove the inner border and padding in Firefox. - */ - -button::-moz-focus-inner, -[type="button"]::-moz-focus-inner, -[type="reset"]::-moz-focus-inner, -[type="submit"]::-moz-focus-inner { - border-style: none; - padding: 0; -} - -/** - * Restore the focus styles unset by the previous rule. - */ - -button:-moz-focusring, -[type="button"]:-moz-focusring, -[type="reset"]:-moz-focusring, -[type="submit"]:-moz-focusring { - outline: 1px dotted ButtonText; -} - -/** - * Correct the padding in Firefox. - */ - -fieldset { - padding: 0.35em 0.75em 0.625em; -} - -/** - * 1. Correct the text wrapping in Edge and IE. - * 2. Correct the color inheritance from `fieldset` elements in IE. - * 3. Remove the padding so developers are not caught out when they zero out - * `fieldset` elements in all browsers. - */ - -legend { - box-sizing: border-box; /* 1 */ - color: inherit; /* 2 */ - display: table; /* 1 */ - max-width: 100%; /* 1 */ - padding: 0; /* 3 */ - white-space: normal; /* 1 */ -} - -/** - * Add the correct vertical alignment in Chrome, Firefox, and Opera. - */ - -progress { - vertical-align: baseline; -} - -/** - * Remove the default vertical scrollbar in IE 10+. - */ - -textarea { - overflow: auto; -} - -/** - * 1. Add the correct box sizing in IE 10. - * 2. Remove the padding in IE 10. - */ - -[type="checkbox"], -[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/** - * Correct the cursor style of increment and decrement buttons in Chrome. - */ - -[type="number"]::-webkit-inner-spin-button, -[type="number"]::-webkit-outer-spin-button { - height: auto; -} - -/** - * 1. Correct the odd appearance in Chrome and Safari. - * 2. Correct the outline style in Safari. - */ - -[type="search"] { - -webkit-appearance: textfield; /* 1 */ - outline-offset: -2px; /* 2 */ -} - -/** - * Remove the inner padding in Chrome and Safari on macOS. - */ - -[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/** - * 1. Correct the inability to style clickable types in iOS and Safari. - * 2. Change font properties to `inherit` in Safari. - */ - -::-webkit-file-upload-button { - -webkit-appearance: button; /* 1 */ - font: inherit; /* 2 */ -} - -/* Interactive - ========================================================================== */ - -/* - * Add the correct display in Edge, IE 10+, and Firefox. - */ - -details { - display: block; -} - -/* - * Add the correct display in all browsers. - */ - -summary { - display: list-item; -} - -/* Misc - ========================================================================== */ - -/** - * Add the correct display in IE 10+. - */ - -template { - display: none; -} - -/** - * Add the correct display in IE 10. - */ - -[hidden] { - display: none; -} diff --git a/css/style.css b/css/style.css index acb48a7..a125c80 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,5 @@ +/* Common */ + *, *::before, *::after { @@ -5,17 +7,20 @@ } html { - font-size: 16px; scroll-behavior: smooth; + height: 100%; } body { margin: 0; - - font: 17px/1.6 "Helvetica", "Arial", sans-serif; + min-height: 100%; + font-size: 16px; + line-height: 1.6; + font-family: "Helvetica", "Arial", sans-serif; color: #5a5a5a; - background-color: #ffffff; + display: flex; + flex-direction: column; } a:link, @@ -34,7 +39,6 @@ h1, h2, h3 { margin: 0; - font-weight: normal; color: #424242; letter-spacing: -0.025em; @@ -60,6 +64,25 @@ h3 { scroll-margin-top: 20px; } +ul li { + margin-bottom: 0.25rem; +} + +.visually-hidden { + position: absolute; + + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + border: 0; + clip: rect(0, 0, 0, 0); + clip-path: inset(100%); +} + +/* Code */ + code, pre { font-family: "Consolas", "Liberation Mono", "Menlo", "Courier", monospace; @@ -67,10 +90,8 @@ pre { code { padding: 2px 4px; - font-size: 95%; color: #d44950; - background-color: #f7f7f9; border-radius: 0.2rem; } @@ -78,29 +99,22 @@ code { pre { display: block; margin: 0 0 1rem; - line-height: 1.4; white-space: pre-wrap; } pre code { padding: 0; - color: inherit; - background-color: transparent; border: 0; } -ul li { - margin-bottom: 0.25rem; -} +/* Header */ header { padding: 1rem 1rem 6rem; - text-align: center; - background-color: #312785; background-image: repeating-linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.06) 1px, transparent 0, transparent 41px), repeating-linear-gradient(-150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.06) 1px, transparent 0, transparent 41px); background-size: 82px 47px; @@ -108,13 +122,11 @@ header { header h1 { margin: 0 0 0.25rem; - color: #ffffff; } header p { margin-top: 0; - font-size: 1.1rem; } @@ -123,33 +135,33 @@ header a:visited { color: #ffffff; } -.visually-hidden { - position: absolute; - - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; +.logo { + width: 300px; + height: 300px; +} - border: 0; +.logo-list-js { + margin: 11px 23px 0; +} - clip: rect(0, 0, 0, 0); - clip-path: inset(100%); +@media (min-width: 38em) { + header { + padding-bottom: 4rem; + } } +/* Logo list */ + .logo-list { - max-width: 550px; margin: 50px auto; } .logo-list ul { display: flex; flex-wrap: wrap; - justify-content: space-around; + justify-content: center; margin: 0; padding: 0; - list-style: none; } @@ -158,20 +170,18 @@ header a:visited { margin-left: 10px; } -.logo { - width: 300px; - height: 300px; -} +/* Gudie content */ .guide-content { display: flex; flex-wrap: wrap; } +/* Sidebar */ + .sidebar { display: flex; flex-direction: column; - width: 100%; } @@ -201,6 +211,84 @@ header a:visited { padding-left: 1rem; } +@media (min-width: 48em) { + .sidebar { + flex-direction: row; + flex-wrap: wrap; + padding: 2rem 0; + } + + .sidebar-col { + width: 50%; + padding: 1rem 3rem; + } + + .sidebar-col + .sidebar-col { + border-top: 0; + } +} + +@media (min-width: 75em) { + .sidebar { + position: sticky; + top: 0; + bottom: 0; + flex-direction: column; + flex-wrap: nowrap; + align-self: flex-start; + width: 230px; + height: 100vh; + padding: 0 1rem; + overflow-y: auto; + line-height: 1.25; + border-right: 1px solid #e5e5e5; + } + + .sidebar-col { + flex-shrink: 0; + width: 100%; + padding: 0; + } + + .sidebar-col-first { + padding-top: 1.75rem; + } + + .sidebar-col-last { + padding-bottom: 1.75rem; + } + + .sidebar-col + .sidebar-col { + margin-top: 1.75em; + } + + .sidebar-col > a { + display: block; + + font-size: 0.8rem; + font-weight: bold; + } + + .sidebar-menu { + padding: 0; + margin: 0.5em 0 0; + list-style: none; + font-size: 0.7rem; + } + + .sidebar-menu li { + margin: 0; + line-height: 1.45; + } + + .sidebar-menu a { + display: block; + padding: 0.25em 0; + } +} + +/* Chapter */ + .chapters { width: 100%; } @@ -222,7 +310,6 @@ header a:visited { .chapter-part { display: flex; flex-direction: column; - border-bottom: 1px solid #e5e5e5; } @@ -246,9 +333,51 @@ header a:visited { background-color: #fafafa; } +@media (min-width: 38em) { + .chapter h2 { + padding: 2rem 2rem 2.5rem; + } + + .chapter-part-col { + padding: 2rem; + } +} + + +@media (min-width: 48em) { + .chapter h2 { + padding: 2rem 3rem 2.5rem; + } + + .chapter-part { + flex-direction: row; + } + + .chapter-part-col { + width: 50%; + padding: 3rem 1.5rem; + } + + .chapter-part-col--full-width { + width: 100%; + } + + .chapter-part-col + .chapter-part-col { + border-top: 0; + } +} + +@media (min-width: 75em) { + .chapters { + width: calc(100% - 230px); + } +} + +/* Footer */ + footer { padding: 2rem; - + margin-top: auto; background-color: #2d2d44; } @@ -279,7 +408,6 @@ footer { .icon { min-width: 2rem; min-height: 2rem; - background-repeat: no-repeat; background-position: center; background-size: calc(100% - 5px); @@ -291,156 +419,29 @@ footer { } .icon-vk { - background-image: url("http://github.com/img/icon-vkontakte.svg"); + background-image: url("http://github.com/img/icon-vkontakte.svg"); } .icon-fb { - background-image: url("http://github.com/img/icon-facebook.svg"); + background-image: url("http://github.com/img/icon-facebook.svg"); } .icon-tw { - background-image: url("http://github.com/img/icon-twitter.svg"); + background-image: url("http://github.com/img/icon-twitter.svg"); } .icon-ig { - background-image: url("http://github.com/img/icon-instagram.svg"); + background-image: url("http://github.com/img/icon-instagram.svg"); } .github-link { display: inline-block; width: 91px; height: 16px; - - background-image: url("http://github.com/img/github.svg"); + background-image: url("http://github.com/img/github.svg"); } -@media (min-width: 38em) { - header { - padding-bottom: 4rem; - } - - html { - font-size: 20px; - } - - .chapter h2 { - padding: 2rem 2rem 2.5rem; - } - - .chapter-part-col { - padding: 2rem; - } -} - -@media (min-width: 48em) { - .sidebar { - flex-direction: row; - flex-wrap: wrap; - - padding: 2rem 0; - } - - .sidebar-col { - width: 50%; - padding: 1rem 3rem; - } - - .sidebar-col + .sidebar-col { - border-top: 0; - } - - .chapter h2 { - padding: 2rem 3rem 2.5rem; - } - - .chapter-part { - flex-direction: row; - } - - .chapter-part-col { - width: 50%; - padding: 3rem 1.5rem; - } - - .chapter-part-col--full-width { - width: 100%; - } - - .chapter-part-col + .chapter-part-col { - border-top: 0; - } -} - -@media (min-width: 75em) { - .chapters { - width: calc(100% - 230px); - } - - .sidebar { - position: sticky; - top: 0; - bottom: 0; - - flex-direction: column; - flex-wrap: nowrap; - align-self: flex-start; - - width: 230px; - height: 100vh; - padding: 0 1rem; - - overflow-y: auto; - line-height: 1.25; - border-right: 1px solid #e5e5e5; - } - - .sidebar-col { - flex-shrink: 0; - - width: 100%; - padding: 0; - } - - .sidebar-col-first { - padding-top: 1.75rem; - } - - .sidebar-col-last { - padding-bottom: 1.75rem; - } - - .sidebar-col + .sidebar-col { - margin-top: 1.75em; - } - - .sidebar-col > a { - display: block; - - font-size: 0.8rem; - font-weight: bold; - } - - .sidebar-menu { - padding: 0; - margin: 0.5em 0 0; - - list-style: none; - - font-size: 0.7rem; - } - - .sidebar-menu li { - margin: 0; - - line-height: 1.45; - } - - .sidebar-menu a { - display: block; - - padding: 0.25em 0; - } -} +/* Prism */ /* override default prism theme */ code[class*="language-"], diff --git a/html-css.html b/html-css.html index c468d5f..8e52a6a 100644 --- a/html-css.html +++ b/html-css.html @@ -2,17 +2,16 @@ - Стиль кода Академии HTML + Стиль кода HTML Academy - + - @@ -28,7 +27,7 @@ -

Стиль кода Академии HTML

+

Стиль кода HTML Academy

github.com/htmlacademy/codeguide

@@ -99,7 +98,7 @@

Автоматизация проверки кода

При написании кода вам сложно будет запомнить все правила кодгайда. Эту работу стоит отдать роботам.

По ссылкам находятся конфигурации Академии для этих инструментов. Конфигурации частично покрывают то, что описано в этом стиле кода, и в них нет ничего, что не описано ниже.

@@ -213,7 +212,7 @@

Базовые части разметки

  • Корневой элемент <html> с языком документа lang
  • Метаинформация <head>
  • Заголовок документа <title>
  • -
  • Кодировка документа <meta charset="utf-8">. Кодировка символов на странице явно указана, чтобы обеспечить корректное отображение текста. Кодировка utf-8 предпочтительна.
  • +
  • Кодировка документа <meta charset="utf-8">. Кодировка символов на странице явно указана, чтобы обеспечить корректное отображение текста.
  • Тело документа <body>
  • @@ -235,6 +234,14 @@

    Базовые части разметки

    <title>Заголовок</title> Страница </html> + +<!-- Плохо --> +<!DOCTYPE html> +<html lang="ru"> + <head> + <meta charset="windows-1251"> + </head> +</html> @@ -451,7 +458,7 @@

    Размеры замещаемых элементов
  • У изображений, видео и iframe указаны размеры.
  • -
  • о возможности изображениям указываются действительные размеры, так как это улучшает производительность отрисовки страницы: браузер не будет перерисовывать страницу в процессе загрузки и отображения изображения.
  • +
  • По возможности изображениям указываются действительные размеры, так как это улучшает производительность отрисовки страницы: браузер не будет перерисовывать страницу в процессе загрузки и отображения изображения.
  • В атрибутах нет единиц измерения.
  • @@ -582,7 +589,7 @@

    Подключение скриптов

    Валидность

    - Документ проходит проверку на валидность. Для проверки используется современный валидатор. + Документ проходит проверку на валидность. Для проверки используется современный валидатор.

    @@ -669,7 +676,7 @@

    Структура объявления

    .block{margin-bottom: 0; margin-top: 0; font-size: 14px;line-height: 20; - color :red} + color :#ff0000} .element { background-color: #000000; } @@ -787,12 +794,12 @@

    Кавычки

    /* Хорошо */
     .field[type="text"] {
    -  background-color: url("http://github.com/images/cat.jpg");
    +  background-image: url("http://github.com/images/cat.jpg");
     }
     
     /* Плохо */
     .field[type=text] {
    -  background-color: url(http://github.com/images/cat.jpg);
    +  background-image: url(http://github.com/images/cat.jpg);
     }
     
     
    @@ -816,11 +823,6 @@

    Ведущий ноль и пробелы после background-color: rgba(0, 0, 0, 0.5); } -.element { - background-color: rgb(0, 0, 0); - color: rgba(0, 0, 0, 0.5); -} - /* Плохо */ .block { opacity: .5; @@ -828,7 +830,6 @@

    Ведущий ноль и пробелы после } .element { - background-color: rgb(0,0,0); color: rgba(0 ,0 ,0 ,0.5); } @@ -870,22 +871,35 @@

    Повторяющиеся свойства

    Единицы измерения

    -

    Единицы измерения не указаны там, где в них нет необходимости.

    +
    /* Хорошо */
    +:root {
    +  --size: 0px;
    +}
    +
     .element {
       border: 0;
       box-shadow: 0 1px 2px #cccccc, inset 0 1px 0 #ffffff;
       margin-top: 0;
    +  width: calc(100% - var(--size));
     }
     
     /* Плохо */
    +:root {
    +  --size: 0;
    +}
    +
     .element {
       border: 0px;
       box-shadow: 0px 1px 2px #cccccc, inset 0px 1px 0 #ffffff;
       margin-top: 0px;
    +  width: calc(100% - var(--size));
     }
     
     
    @@ -1065,21 +1079,21 @@

    Порядок свойств

    HTML Academy diff --git a/img/icon-css.svg b/img/icon-css.svg new file mode 100644 index 0000000..3d8959a --- /dev/null +++ b/img/icon-css.svg @@ -0,0 +1 @@ +file_type_css \ No newline at end of file diff --git a/img/icon-html.svg b/img/icon-html.svg new file mode 100644 index 0000000..a0152d8 --- /dev/null +++ b/img/icon-html.svg @@ -0,0 +1 @@ +file_type_html \ No newline at end of file diff --git a/img/icon-javascript.svg b/img/icon-javascript.svg new file mode 100644 index 0000000..92316ce --- /dev/null +++ b/img/icon-javascript.svg @@ -0,0 +1 @@ + diff --git a/img/logo-html.svg b/img/logo-html.svg deleted file mode 100644 index 101e1ff..0000000 --- a/img/logo-html.svg +++ /dev/null @@ -1 +0,0 @@ -HTML5 Logo diff --git a/img/logo-js.svg b/img/logo-js.svg index d609063..3895f98 100644 --- a/img/logo-js.svg +++ b/img/logo-js.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/index.html b/index.html index efd2507..e8fc7e6 100644 --- a/index.html +++ b/index.html @@ -2,17 +2,16 @@ - Стиль кода Академии HTML + Стиль кода HTML Academy - + - @@ -29,7 +28,7 @@ -

    Стиль кода Академии HTML

    +

    Стиль кода HTML Academy

    github.com/htmlacademy/codeguide

    @@ -41,12 +40,16 @@

    Разделы стиля кода

    @@ -60,21 +63,21 @@

    Разделы стиля кода

    HTML Academy diff --git a/javascript.html b/javascript.html index e3917bc..62bf3b1 100644 --- a/javascript.html +++ b/javascript.html @@ -2,17 +2,16 @@ - Стиль кода Академии HTML + Стиль кода HTML Academy - + - @@ -36,7 +35,7 @@ -

    Стиль кода Академии HTML

    +

    Стиль кода HTML Academy

    github.com/htmlacademy/codeguide

    @@ -97,7 +96,7 @@

    Синтаксис

    Отступы, пробелы и переносы

    -
    Для правильного форматирования используйте файл .editorconfig в вашем редакторе.
    +
    Для правильного форматирования используйте файл .editorconfig в вашем редакторе.

    Для отступов используются два пробела. Знак табуляции не используется

    @@ -248,7 +247,7 @@

    Именование

    Запрещено использовать имена переменных, которые используются во внешних областях видимости

    -

    Запрещено называть переменные и свойства ключевыми словами JS

    +

    Запрещено называть переменные и свойства ключевыми словами JS

    Запрещено использовать переменные, не объявленные ранее. При использовании переменной, объявленной в другом модуле в глобальной области видимости, нужно обращаться к ней как к свойству объекта window

    @@ -288,7 +287,7 @@

    Условные операторы

    В условиях не используется небезопасное отрицание, например использование ! в in или instanceof без скобок

    -

    Запрещено сравнение с NaN. Для проверки, является ли результат операции числовым, нужно использовать Number.isNaN

    +

    Запрещено сравнение с NaN. Для проверки, является ли результат операции числовым, нужно использовать Number.isNaN

    Запрещено использовать case без break или return в блоках switch

    @@ -556,21 +555,21 @@

    Регулярные выражения

    HTML Academy