Commit 0c0cfdef authored by Nikolay Gromov's avatar Nikolay Gromov

Рефакторинг элементов форм

parent 94bf6a52
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
// свой чекбокс без картинок // свой чекбокс без картинок
@at-root input:disabled ~ & {
cursor: not-allowed;
}
&:before { &:before {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -78,6 +82,11 @@ ...@@ -78,6 +82,11 @@
@include field-focus; @include field-focus;
} }
@at-root input:disabled ~ &:before {
border-color: $gray-light;
background: $gray-lighter;
}
&:after { &:after {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -95,6 +104,10 @@ ...@@ -95,6 +104,10 @@
@at-root input:checked ~ & { @at-root input:checked ~ & {
opacity: 1; opacity: 1;
} }
@at-root input:checked:disabled ~ & {
border-color: $gray-light;
}
} }
// / свой чекбокс без картинок // / свой чекбокс без картинок
......
...@@ -8,7 +8,7 @@ const closest = require('closest'); ...@@ -8,7 +8,7 @@ const closest = require('closest');
;( function () ;( function ()
{ {
var inputs = document.querySelectorAll( '.field-file__input' ); var inputs = document.querySelectorAll( '.field-file__input:not([disabled])' );
Array.prototype.forEach.call( inputs, function( input ) Array.prototype.forEach.call( inputs, function( input )
{ {
var label = closest(input, '.field-file').querySelector( '.field-file__name-text' ), var label = closest(input, '.field-file').querySelector( '.field-file__name-text' ),
......
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
// своя радиокнопка без картинки // своя радиокнопка без картинки
@at-root input:disabled ~ & {
cursor: not-allowed;
}
&:before { &:before {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -78,6 +82,11 @@ ...@@ -78,6 +82,11 @@
@include field-focus; @include field-focus;
} }
@at-root input:disabled ~ &:before {
border-color: $gray-light;
background: $gray-lighter;
}
&:after { &:after {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -93,6 +102,10 @@ ...@@ -93,6 +102,10 @@
@at-root input:checked ~ & { @at-root input:checked ~ & {
opacity: 1; opacity: 1;
} }
@at-root input:checked:disabled ~ & {
background-color: $gray-light;
}
} }
// / своя радиокнопка без картинки // / своя радиокнопка без картинки
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
&[disabled], &[disabled],
&[readonly] { &[readonly] {
cursor: default; cursor: not-allowed;
background-color: $gray-lighter; background-color: $gray-lighter;
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
// Очередность: http://nicothin.github.io/idiomatic-pre-CSS/#priority // Очередность: http://nicothin.github.io/idiomatic-pre-CSS/#priority
.field-toggler { .field-toggler {
$block-name: &; // #{$block-name}__element
display: block; display: block;
margin-bottom: 1em; margin-bottom: 1em;
...@@ -13,7 +16,19 @@ ...@@ -13,7 +16,19 @@
&__input-wrap { &__input-wrap {
& + & { & + & {
margin-top: 1rem; margin-top: 1em;
}
&--error {
#{$block-name}__name-text,
#{$block-name}__help-text {
color: $color-danger;
}
#{$block-name}__name-text:after {
background: $color-danger;
}
} }
} }
...@@ -29,6 +44,10 @@ ...@@ -29,6 +44,10 @@
&__name-text { &__name-text {
display: inline-block; display: inline-block;
@at-root input:disabled ~ & {
cursor: not-allowed;
}
&:before { &:before {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -44,6 +63,11 @@ ...@@ -44,6 +63,11 @@
} }
} }
@at-root input:disabled ~ &:before {
border-color: $gray-light;
background: $gray-lighter;
}
&:after { &:after {
content: ''; content: '';
position: absolute; position: absolute;
...@@ -59,6 +83,10 @@ ...@@ -59,6 +83,10 @@
@at-root input:checked ~ &:after { @at-root input:checked ~ &:after {
transform: translate(17px, 0); transform: translate(17px, 0);
} }
@at-root input:disabled ~ &:after {
background-color: $gray-light;
}
} }
&__input { &__input {
......
...@@ -410,14 +410,21 @@ block content ...@@ -410,14 +410,21 @@ block content
} }
}) })
+field-text({ +field-text({
title: 'Текстовое поле', title: 'Текстовое поле ошибочное',
helpText: 'Описание ошибки', helpText: 'Описание ошибки',
mods: 'error', mods: 'error',
attrs: { attrs: {
placeholder: 'Подсказка', placeholder: 'Подсказка',
} }
}) })
+field-text() +field-text({
title: 'Текстовое поле блокированное',
helpText: 'Описание ошибки',
attrs: {
placeholder: 'Подсказка',
disabled: true,
}
})
+block-lib-code() +block-lib-code()
include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-text/field-text.pug include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-text/field-text.pug
...@@ -434,7 +441,7 @@ block content ...@@ -434,7 +441,7 @@ block content
]) ])
+field-checkbox([ +field-checkbox([
{ {
title: 'Чекбокс первый', title: 'Чекбокс ошибочный',
helpText: 'И, возможно, единственный', helpText: 'И, возможно, единственный',
mods: 'error', mods: 'error',
attrs: { attrs: {
...@@ -443,10 +450,11 @@ block content ...@@ -443,10 +450,11 @@ block content
} }
}, },
{ {
title: 'Чекбокс второй', title: 'Чекбокс блокирован',
helpText: 'А, нет. Не единственный...', helpText: 'А, нет. Не единственный...',
attrs: { attrs: {
name: 'check2', name: 'check2',
disabled: true,
} }
}, },
], 'Общее необязательное название') ], 'Общее необязательное название')
...@@ -457,7 +465,7 @@ block content ...@@ -457,7 +465,7 @@ block content
include:markdown-it(html='true') ../blocks/field-radio/readme.md include:markdown-it(html='true') ../blocks/field-radio/readme.md
+field-radio([ +field-radio([
{ {
title: 'Первый', title: 'Радиокнопка',
helpText: 'И, возможно, единственный', helpText: 'И, возможно, единственный',
attrs: { attrs: {
name: 'radio', name: 'radio',
...@@ -465,10 +473,18 @@ block content ...@@ -465,10 +473,18 @@ block content
} }
}, },
{ {
title: 'Второй', title: 'Радиокнопка ошибочная',
helpText: 'А, нет. Не единственный...', helpText: 'А, нет. Не единственный...',
mods: 'error',
attrs: {
name: 'radio',
}
},
{
title: 'Радиокнопка блокированная',
attrs: { attrs: {
name: 'radio', name: 'radio',
disabled: true,
} }
}, },
], 'Общее необязательное название') ], 'Общее необязательное название')
...@@ -488,22 +504,24 @@ block content ...@@ -488,22 +504,24 @@ block content
]) ])
+field-toggler([ +field-toggler([
{ {
title: 'Переключатель 1', title: 'Одиночный переключатель ошибочный',
helpText: 'Подсказка', helpText: 'Это чекбокс, на самом деле',
mods: 'error',
attrs: { attrs: {
name: 'check11', name: 'check101',
checked: true,
} }
}, },
])
+field-toggler([
{ {
title: 'Переключатель 2', title: 'Одиночный переключатель блокированный',
helpText: 'Подсказка', helpText: 'Это чекбокс, на самом деле',
mods: 'some',
attrs: { attrs: {
name: 'check11', name: 'check102',
disabled: true,
} }
}, },
], 'Две радиокнопки', true) ])
+block-lib-code() +block-lib-code()
include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-toggler/field-toggler.pug include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-toggler/field-toggler.pug
...@@ -529,6 +547,13 @@ block content ...@@ -529,6 +547,13 @@ block content
name: 'commentFile3', name: 'commentFile3',
}, },
}) })
+field-file({
helpText: 'Блокировано',
attrs: {
name: 'commentFile4',
disabled: true,
},
})
+block-lib-code() +block-lib-code()
include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-file/field-file.pug include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-file/field-file.pug
...@@ -549,7 +574,7 @@ block content ...@@ -549,7 +574,7 @@ block content
+block-lib-code() +block-lib-code()
include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-range/field-range.pug include:show-code(first-line='//- Pug-файл этого блока:') ../blocks/field-range/field-range.pug
+block-lib('field-select', 'Селекты', false) +block-lib('field-select', 'Кастомный селект с <a href="https://joshuajohnson.co.uk/Choices/">Choices</a>', false)
include:markdown-it(html='true') ../blocks/field-select/readme.md include:markdown-it(html='true') ../blocks/field-select/readme.md
+field-select( +field-select(
'Название селекта', 'Название селекта',
...@@ -665,7 +690,6 @@ block content ...@@ -665,7 +690,6 @@ block content
helpText: 'Подсказка', helpText: 'Подсказка',
attrs: { attrs: {
placeholder: 'Пример', placeholder: 'Пример',
disabled: true,
} }
}) })
+field-text({ +field-text({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment