Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
NTH-start-project/src/blocks/field-text/field-text.pug
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (45 sloc)
1.92 KB
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
//- Все примеси в этом файле должны начинаться c имени блока (field-text) | |
mixin field-text(props) | |
//- Принимает: | |
//- props { | |
//- title: '' {string} - текст с названием (выводится над полем) | |
//- isTextarea: false {bool} - флаг input/textarea | |
//- helpText: '' {string} - пояснение под полем | |
//- mods: '' {string} - модификаторы блока | |
//- val: '' {string} - текст в поле | |
//- attrs: {object} - любые атрибуты для input/textarea | |
//- type: {string} | |
//- placeholder: {string} | |
//- Вызов: | |
+field-text({ | |
title: 'Название', | |
isTextarea: true, | |
helpText: 'Подсказка', | |
mods: '', | |
val: '', | |
attrs: { | |
name: 'comment', | |
} | |
}) | |
- | |
if(typeof(props) === 'undefined') { | |
var props = {}; | |
} | |
var allMods = ''; | |
if(typeof(props.mods) !== 'undefined' && props.mods) { | |
var modsList = props.mods.split(','); | |
for (var i = 0; i < modsList.length; i++) { | |
allMods = allMods + ' field-text--' + modsList[i].trim(); | |
} | |
} | |
label.field-text(class=allMods)&attributes(attributes) | |
if(typeof(props.title) !== 'undefined' && props.title) | |
span.field-text__name!= props.title | |
span.field-text__input-wrap | |
if(typeof(props.isTextarea) !== 'undefined' && props.isTextarea) | |
textarea.field-text__input&attributes(props.attrs)= props.val | |
else | |
input.field-text__input(type=(typeof(props.attrs) !== 'undefined' && props.attrs.type) ? props.attrs.type : 'text', value=props.val)&attributes(props.attrs) | |
if(typeof(props.helpText) !== 'undefined' && props.helpText) | |
span.field-text__help-text!= props.helpText | |
block |