Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
K
kpp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Veselov
kpp
Commits
0c0cfdef
Commit
0c0cfdef
authored
Jan 04, 2019
by
Nikolay Gromov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Рефакторинг элементов форм
parent
94bf6a52
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
20 deletions
+98
-20
field-checkbox.scss
src/blocks/field-checkbox/field-checkbox.scss
+13
-0
field-file.js
src/blocks/field-file/field-file.js
+1
-1
field-radio.scss
src/blocks/field-radio/field-radio.scss
+13
-0
field-text.scss
src/blocks/field-text/field-text.scss
+1
-1
field-toggler.scss
src/blocks/field-toggler/field-toggler.scss
+29
-1
blocks-demo.pug
src/pages/blocks-demo.pug
+41
-17
No files found.
src/blocks/field-checkbox/field-checkbox.scss
View file @
0c0cfdef
...
@@ -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
;
}
}
}
// / свой чекбокс без картинок
// / свой чекбокс без картинок
...
...
src/blocks/field-file/field-file.js
View file @
0c0cfdef
...
@@ -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'
),
...
...
src/blocks/field-radio/field-radio.scss
View file @
0c0cfdef
...
@@ -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
;
}
}
}
// / своя радиокнопка без картинки
// / своя радиокнопка без картинки
...
...
src/blocks/field-text/field-text.scss
View file @
0c0cfdef
...
@@ -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
;
}
}
...
...
src/blocks/field-toggler/field-toggler.scss
View file @
0c0cfdef
...
@@ -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
{
...
...
src/pages/blocks-demo.pug
View file @
0c0cfdef
...
@@ -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({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment