@charset "utf-8";
// 定义input的基础构造
@mixin _input {
&,
&::-webkit-inner-spin-button {
@include appearance;
}
width: map-get($input, width);
height: map-get($input, height);
padding: map-get($input, padding);
border: 1px solid map-get($input, border-color);
@include border-radius(map-get($input, radius));
background-color: map-get($input, bgcolor);
vertical-align: top;
color: map-get($input, color);
&::-webkit-input-placeholder {
color: map-get($input, placeholder-color);
}
}
/**
* @module element
* @method yo-input
* @version 1.0.0
* @description 构造输入框的自定义使用方法,可同时作用于 input 与 textarea
* @demo http://doyoe.github.io/Yo/demo/element/yo-input.html
* @param {String} $name 定义扩展名称 <1.0.0>
* @param {Length} $width 宽度 <1.0.0>
* @param {Length} $height 高度 <1.0.0>
* @param {Length} $padding 内补白 <1.0.0>
* @param {Length} $radius 圆角半径长度 <1.0.0>
* @param {Color} $bordercolor 边框色 <1.0.0, 2.0.0>
* @param {Color} $border-color 边框色 <2.0.0>
* @param {Color} $bgcolor 背景色 <1.0.0>
* @param {Color} $color 文本色 <1.0.0>
* @param {Color} $placeholder-color placeholder文本色 <1.0.0>
*/
@mixin yo-input(
$name: default,
$width: default,
$height: default,
$padding: default,
$radius: default,
$border-color: default,
$bgcolor: default,
$color: default,
$placeholder-color: default) {
// 区别是否新增实例还是修改本身
$name: if($name == default, "", "-#{$name}");
// 如果值为default,则取config的定义
@if $width == default {
$width: map-get($input, width);
}
@if $height == default {
$height: map-get($input, height);
}
@if $padding == default {
$padding: map-get($input, padding);
}
@if $radius == default {
$radius: map-get($input, radius);
}
@if $border-color == default {
$border-color: map-get($input, border-color);
}
@if $bgcolor == default {
$bgcolor: map-get($input, bgcolor);
}
@if $color == default {
$color: map-get($input, color);
}
@if $placeholder-color == default {
$placeholder-color: map-get($input, placeholder-color);
}
.yo-input#{$name} {
@if $width != map-get($input, width) {
width: $width;
}
@if $height != map-get($input, height) {
height: $height;
}
@if $padding != map-get($input, padding) {
padding: $padding;
}
@if $radius != map-get($input, radius) {
border-radius: $radius;
}
@if $border-color != map-get($input, border-color) {
border-color: $border-color;
}
@if $bgcolor != map-get($input, bgcolor) {
background-color: $bgcolor;
}
@if $color != map-get($input, color) {
color: $color;
}
&::-webkit-input-placeholder {
@if $placeholder-color != map-get($input, placeholder-color) {
color: $placeholder-color;
}
}
// 增量扩展
@content;
}
}
// 调用本文件时载入按钮基础构造
.yo-input {
@include _input;
}