Yo 源文件
Yo 是一款基于 Mobile First 理念而设计的 CSS Framework,当然,它也适应于PC端的高级浏览器;其具备轻量,易用,快速且高度强大的自定义能力
Yo 是一款基于 Mobile First 理念而设计的 CSS Framework,当然,它也适应于PC端的高级浏览器;其具备轻量,易用,快速且高度强大的自定义能力
@charset "utf-8"; // 定义浮层popup的基础构造 @mixin _popup { @include flexbox; @include flex-direction(column); position: absolute; z-index: map-get($z-index, popup); @if map-get($popup, shadow-opacity) != null { box-shadow: 0 0 5px rgba(map-get($popup, border-color), map-get($popup, shadow-opacity)); } @include border( $border-color: map-get($popup, border-color), $radius: map-get($popup, radius) ); min-width: 2.8rem; min-height: 1rem; width: map-get($popup, width); height: map-get($popup, height); background-color: #fff; // 改用标签的方式,因为JS需要控制位置 > .arrow::after { position: absolute; z-index: 1000; content: "◆"; color: #fff; font-size: map-get($popup, arrow-size) * 2; line-height: 1; } // 控制箭头方向 .arrow-top, .arrow-down { &::after { @include transform(translate(-50%)); left: 50%; } } .arrow-top::after { top: -#{map-get($popup, arrow-size) - .01rem}; // 箭头边框色 text-shadow: 0 -1px map-get($popup, border-color); } .arrow-down::after { bottom: -#{map-get($popup, arrow-size) - .01rem}; // 箭头边框色 text-shadow: 0 1px map-get($popup, border-color); } .arrow-right, .arrow-left { &::after { @include transform(translate(0, -50%)); top: 50%; } } .arrow-right::after { right: -#{map-get($popup, arrow-size) - .01rem}; // 箭头边框色 text-shadow: 1px 0 map-get($popup, border-color); } .arrow-left::after { left: -#{map-get($popup, arrow-size) - .01rem}; // 箭头边框色 text-shadow: -1px 0 map-get($popup, border-color); } // 有hd或ft时,箭头的颜色应该和hd或ft相同 .arrow-extra.arrow::after { color: map-get($popup, hd-bgcolor); } > .hd, > .bd { position: relative; z-index: 2; } > .hd { height: map-get($popup, hd-height); @include border( $border-width: 0 0 1px, $border-color: map-get($popup, border-color) ); border-radius: map-get($popup, radius) map-get($popup, radius) 0 0; background-color: map-get($popup, hd-bgcolor); line-height: map-get($popup, hd-height); text-align: center; .title { overflow: hidden; height: 100%; margin: 0 60px; color: map-get($popup, title-color); font-size: map-get($popup, title-font-size); } .regret, .affirm { position: absolute; top: 0; } .regret {left: 10px;} .affirm {right: 10px;} } > .bd { @include flex(1, column); @include overflow; padding: map-get($popup, bd-padding); } > .ft { padding: .1rem 0; @include border( $border-width: 1px 0 0, $border-color: map-get($popup, border-color) ); border-radius: 0 0 map-get($popup, radius) map-get($popup, radius); text-align: center; } } /** * @module widget * @method yo-popup * @version 1.0.0 * @description 构造yo-popup的自定义使用方法 * @demo http://doyoe.github.io/Yo/demo/widget/yo-popup.html * @param {String} $name 定义扩展名称 {add:1.0.0} * @param {Length} $width 宽度 {add:1.0.0} * @param {Length} $height 高度 {add:1.0.0} * @param {Length} $radius 圆角半径长度 {add:1.0.0} * @param {Number} $shadow-opacity 阴影透明度 {add:1.0.0} * @param {Color} $bordercolor 边框色 {add:1.0.0}{del:2.0.0} * @param {Color} $border-color 边框色 {add:2.0.0} * @param {Length} $hd-height 头部高度 {add:1.0.0} * @param {Color} $hd-bgcolor 头部背景色 {add:1.0.0} * @param {Color} $title-color 标题文本色 {add:1.0.0} * @param {Length} $title-font-size 标题字号 {add:1.0.0} * @param {Length} $bd-padding 主体内补白 {add:1.0.0} * @param {Length} $arrow-size 箭头高度 {add:1.0.0} */ @mixin yo-popup( $name: default, $width: default, $height: default, $radius: default, $shadow-opacity: default, $border-color: default, $hd-height: default, $hd-bgcolor: default, $title-color: default, $title-font-size: default, $bd-padding: default, $arrow-size: default) { // 区别是否新增实例还是修改本身 $name: if($name == default, "", "-#{$name}"); // 如果值为default,则取config的定义 @if $width == default { $width: map-get($popup, width); } @if $height == default { $height: map-get($popup, height); } @if $radius == default { $radius: map-get($popup, radius); } @if $border-color == default { $border-color: map-get($popup, border-color); } @if $shadow-opacity == default { $shadow-opacity: map-get($popup, shadow-opacity); } @if $hd-height == default { $hd-height: map-get($popup, hd-height); } @if $hd-bgcolor == default { $hd-bgcolor: map-get($popup, hd-bgcolor); } @if $title-color == default { $title-color: map-get($popup, title-color); } @if $title-font-size == default { $title-font-size: map-get($popup, title-font-size); } @if $bd-padding == default { $bd-padding: map-get($popup, bd-padding); } @if $arrow-size == default { $arrow-size: map-get($popup, arrow-size); } .yo-popup#{$name} { > .arrow::after{ @if $arrow-size != map-get($popup, arrow-size) { font-size: $arrow-size * 2; } } .arrow-top::after{ @if $arrow-size != map-get($popup, arrow-size) { top: -$arrow-size + .01rem; } @if $border-color != map-get($popup, border-color) { text-shadow: 0 -1px $border-color; } } .arrow-down::after { @if $arrow-size != map-get($popup, arrow-size) { bottom: -$arrow-size + .01rem; } @if $border-color != map-get($popup, border-color) { text-shadow: 0 1px $border-color; } } .arrow-right::after { @if $arrow-size != map-get($popup, arrow-size) { right: -$arrow-size + .01rem; } @if $border-color != map-get($popup, border-color) { text-shadow: 1px 0 $border-color; } } .arrow-left::after { @if $arrow-size != map-get($popup, arrow-size) { left: -$arrow-size + .01rem; } @if $border-color != map-get($popup, border-color) { text-shadow: -1px 0 $border-color; } } .arrow-extra.arrow::after { @if $hd-bgcolor != map-get($popup, hd-bgcolor) { color: $hd-bgcolor; } } @if $radius != map-get($popup, radius) { border-radius: $radius; } &::after { // 如果$border-color不等于config设定,则重绘边框颜色 @if $border-color != map-get($popup, border-color) { border-color: $border-color; } // 如果$radius不等于config设定,则重绘边框圆角 @if $radius != map-get($popup, radius) { @include responsive(retina1x) { border-radius: $radius; } @include responsive(retina2x) { border-radius: $radius * 2; } @include responsive(retina3x) { border-radius: $radius * 3; } } } // 如果$border-color或者$shadow-opacity不等于config设定,都重绘边框颜色 @if $border-color != map-get($popup, border-color) or $shadow-opacity != map-get($popup, shadow-opacity) { box-shadow: 0 0 5px rgba($border-color, $shadow-opacity); } @if $width != map-get($popup, width) { width: $width; } @if $height != map-get($popup, height) { height: $height; } > .hd { @if $radius != map-get($popup, radius) { border-radius: $radius $radius 0 0; } @if $hd-height != map-get($popup, hd-height) { height: $hd-height; line-height: $hd-height; } &::after { // 如果$border-color不等于config设定,则重绘边框颜色 @if $border-color != map-get($popup, border-color) { border-color: $border-color; } } @if $hd-bgcolor != map-get($popup, hd-bgcolor) { background-color: $hd-bgcolor; } .title { @if $title-color != map-get($popup, title-color) { color: $title-color; } @if $title-font-size != map-get($popup, title-font-size) { font-size: $title-font-size; } } } > .bd { @if $bd-padding != map-get($popup, bd-padding) { padding: $bd-padding; } } > .ft { &::after { // 如果$border-color不等于config设定,则重绘边框颜色 @if $border-color != map-get($popup, border-color) { border-color: $border-color; } } @if $radius != map-get($popup, radius) { border-radius: 0 0 $radius $radius; } } // 增量扩展 @content; } } // 调用本文件时载入popup基础构造 .yo-popup { @include _popup; }