Yo : ./style/lib/fragment/yo-tab.scss
源代码
源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | @charset "utf-8" ; // 定义tab的基础构造 @mixin _tab { @include flexbox; overflow : hidden ; width : map-get($tab, width); height : map-get($tab, height); @include border( $ border-width : map-get($tab, border-width), $ border-color : map-get($tab, border-color), $radius: map-get($tab, radius) ); background-color : map-get($tab, bgcolor); font-size : map-get($tab, font-size); text-align : center ; line-height : map-get($tab, height); > .item { display : block ; @include flex; position : relative ; &:not(:first-child)::after { position : absolute ; top : 50% ; left : 0 ; border-left : 1px solid map-get($tab, item-border-color); content : "\0020" ; // 适配dpr进行缩放 @include responsive(retina 1 x) { width : 10px ; height : map-get($tab, item-border-height); @include transform(translatey( -50% )); } @include responsive(retina 2 x) { width : 20px ; height : map-get($tab, item-border-height) * 2 ; @include transform(scale(. 5 ) translatey( -50% )); } @include responsive(retina 3 x) { width : 30px ; height : map-get($tab, item-border-height) * 3 ; @include transform(scale(. 33333 ) translatey( -50% )); } @include transform-origin( 0 0 ); } color : map-get($tab, color); &:first-child { border-top-left-radius: map-get($tab, radius); border-bottom-left-radius: map-get($tab, radius); } &:last-child { border-top-right-radius: map-get($tab, radius); border-bottom-right-radius: map-get($tab, radius); } &.item-on { background-color : map-get($tab, on-bgcolor); color : map-get($tab, on-color); } &-y-ico { padding-top : . 04 rem; line-height : . 2 rem; .yo-ico { display : block ; font-size : map-get($tab, y-ico-size); } } &-x-ico { .yo-ico { font-size : map-get($tab, x-ico-size); } } &-only-ico { .yo-ico { font-size : map-get($tab, only-ico-size); } } } } /** * @module fragment * @method yo-tab * @version 3.0.0 * @description 构造列表的自定义使用方法 * @param {String} $name 定义扩展名称 <3.0.0> * @param {Length} $width 宽度 <3.0.0> * @param {Length} $height 高度 <3.0.0> * @param {Length} $radius 圆角半径长度 <3.0.0> * @param {Length} $border-width 边框厚度 <3.0.0> * @param {Color} $border-color 边框色 <3.0.0> * @param {Color} $bgcolor 背景色 <3.0.0> * @param {Color} $color 文本色 <3.0.0> * @param {Color} $on-bgcolor 激活时背景色 <3.0.0> * @param {Color} $on-color 激活时文本色 <3.0.0> * @param {Length} $font-size 文本字号 <3.0.0> * @param {Length} $x-ico-size 子项内容为水平ico时,ico的大小 <3.0.0> * @param {Length} $y-ico-size 子项内容为垂直ico时,ico的大小 <3.0.0> * @param {Length} $only-ico-size 子项内容仅有ico时,ico的大小 <3.0.0> * @param {Length} $item-border-height 子项的间隔线高度 <3.0.0> * @param {Color} $item-border-color 子项的间隔线颜色 <3.0.0> */ @mixin yo-tab( $name: default , $ width : default , $ height : default , $radius: default , $ border-width : default , $ border-color : default , $bgcolor: default , $ color : default , $on- border-color : default , $on-bgcolor: default , $on- color : default , $ font-size : default , $x-ico- size : default , $y-ico- size : default , $only-ico- size : default , $item-border- height : default , $item- border-color : default ) { // 区别是否新增实例还是修改本身 $name: if($name == default , "" , "-#{$name}" ); // 如果值为 default ,则取config的定义 @if $width == default { $ width : map-get($tab, width); } @if $height == default { $ height : map-get($tab, height); } @if $radius == default { $radius: map-get($tab, radius); } @if $border-width == default { $ border-width : map-get($tab, border-width); } @if $border-color == default { $ border-color : map-get($tab, border-color); } @if $bgcolor == default { $bgcolor: map-get($tab, bgcolor); } @if $color == default { $ color : map-get($tab, color); } @if $on-border-color == default { $on- border-color : map-get($tab, on-border-color); } @if $on-bgcolor == default { $on-bgcolor: map-get($tab, on-bgcolor); } @if $on-color == default { $on- color : map-get($tab, on-color); } @if $font-size == default { $ font-size : map-get($tab, font-size); } @if $x-ico-size == default { $x-ico- size : map-get($tab, x-ico-size); } @if $y-ico-size == default { $y-ico- size : map-get($tab, y-ico-size); } @if $only-ico-size == default { $only-ico- size : map-get($tab, only-ico-size); } @if $item-border-height == default { $item-border- height : map-get($tab, item-border-height); } @if $item-border-color == default { $item- border-color : map-get($tab, item-border-color); } .yo-tab#{$name} { @if $width != map-get($tab, width) { width : $width; } @if $height != map-get($tab, height) { height : $height; line-height : $height; } @if $radius != map-get($tab, radius) { border-radius: $radius; } &::after { // 如果$border-width不等于config设定,则重绘边框相关 @if $border-width != map-get($tab, border-width) { border-width : $border-width; } // 如果$border-color不等于config设定,则重绘边框颜色 @if $border-color != map-get($tab, border-color) { border-color : $border-color; } // 如果$radius不等于config设定,则重绘边框圆角 @if $radius != map-get($tab, radius) { @include responsive(retina 1 x) { border-radius: $radius; } @include responsive(retina 2 x) { border-radius: $radius * 2 ; } @include responsive(retina 3 x) { border-radius: $radius * 3 ; } } } @if $bgcolor != map-get($tab, bgcolor) { background-color : $bgcolor; } @if $font-size != map-get($tab, font-size) { font-size : $font-size; } > .item { &:not(:first-child)::after { @if $item-border-height != map-get($tab, item-border-height) { @include responsive(retina 1 x) { height : $item-border-height; } @include responsive(retina 2 x) { height : $item-border-height * 2 ; } @include responsive(retina 3 x) { height : $item-border-height * 3 ; } } @if $item-border-color != map-get($tab, item-border-color) { border-color : $item-border-color; } } @if $color != map-get($tab, color) { color : $color; } @if $radius != map-get($tab, radius) { &:first-child { border-top-left-radius: $radius; border-bottom-left-radius: $radius; } &:last-child { border-top-right-radius: $radius; border-bottom-right-radius: $radius; } } &.item-on { @if $on-bgcolor != map-get($tab, on-bgcolor) { background-color : $on-bgcolor; } @if $on-color != map-get($tab, on-color) { color : $on-color; } } &-top-ico { .yo-ico { @if $y-ico-size != map-get($tab, y-ico-size) { font-size : $y-ico-size; } } } &-left-ico { .yo-ico { @if $x-ico-size != map-get($tab, x-ico-size) { font-size : $x-ico-size; } } } &-only-ico { .yo-ico { @if $only-ico-size != map-get($tab, only-ico-size) { font-size : $only-ico-size; } } } } // 增量扩展 @content; } } // 调用本文件时载入tab基础构造 .yo-tab { @include _tab; } |