first commit
This commit is contained in:
1
unpackage/dist/build/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/types.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/types.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../common/props.js"),o={...e.baseProps,modelValue:{type:[Boolean,String,Number],required:!0,default:!1},disabled:e.makeBooleanProp(!1),activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},activeColor:String,inactiveColor:String,size:{type:e.numericProp},beforeChange:Function};exports.switchProps=o;
|
||||
1
unpackage/dist/build/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),a=require("../common/util.js"),o=require("./types.js"),l=e.defineComponent({name:"wd-switch",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"},props:o.switchProps,emits:["change","update:modelValue"],setup(o,{emit:l}){const t=o,i=l,u=e.computed((()=>`wd-switch ${t.customClass} ${t.disabled?"is-disabled":""} ${t.modelValue===t.activeValue?"is-checked":""}`)),c=e.computed((()=>{const e={background:t.modelValue===t.activeValue?t.activeColor:t.inactiveColor,"border-color":t.modelValue===t.activeValue?t.activeColor:t.inactiveColor};return t.size&&(e["font-size"]=a.addUnit(t.size)),`${a.objToStyle(e)}${t.customStyle}`})),n=e.computed((()=>t.modelValue===t.activeValue&&t.activeColor||t.modelValue!==t.activeValue&&t.inactiveColor?"box-shadow: none;":""));function s(){if(t.disabled)return;const e=t.modelValue===t.activeValue?t.inactiveValue:t.activeValue;t.beforeChange&&a.isFunction(t.beforeChange)?t.beforeChange({value:e,resolve:a=>{a&&(i("update:modelValue",e),i("change",{value:e}))}}):(i("update:modelValue",e),i("change",{value:e}))}return e.onBeforeMount((()=>{-1===[t.activeValue,t.inactiveValue].indexOf(t.modelValue)&&(i("update:modelValue",t.inactiveValue),i("change",{value:t.inactiveValue}))})),(a,o)=>({a:e.s(n.value),b:e.n(u.value),c:e.s(c.value),d:e.o(s)})}}),t=e._export_sfc(l,[["__scopeId","data-v-55242008"]]);wx.createComponent(t);
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="{{['data-v-55242008', b]}}" style="{{c}}" bindtap="{{d}}"><view class="wd-switch__circle data-v-55242008" style="{{a}}"></view></view>
|
||||
@@ -0,0 +1 @@
|
||||
.wd-switch.data-v-55242008{display:inline-block;position:relative;width:var(--wot-switch-width, calc(1.8em + 4px) );height:var(--wot-switch-height, calc(1em + 4px) );border-radius:var(--wot-switch-circle-size, 1em);background:var(--wot-switch-inactive-color, #eaeaea);font-size:var(--wot-switch-size, 28px);transition:all .3s}.wd-switch__checkbox.data-v-55242008{position:absolute;width:0;height:0;opacity:0;margin:0}.wd-switch__circle.data-v-55242008{box-sizing:border-box;position:absolute;display:inline-block;width:var(--wot-switch-circle-size, 1em);height:var(--wot-switch-circle-size, 1em);top:2px;left:2px;background:#fff;border-radius:50%;transition:left .3s ease-out;box-shadow:0 2px 4px 0 var(--wot-switch-inactive-shadow-color, rgba(155, 155, 155, .5))}.wd-switch__circle.data-v-55242008:after{position:absolute;content:"";width:calc(200% - 2px);height:calc(200% - 2px);top:50%;left:50%;transform:translate(-50%,-50%) scale(.5);border:1px solid var(--wot-switch-border-color, #e5e5e5);border-radius:50%}.wd-switch.is-checked.data-v-55242008{background:var(--wot-switch-active-color, var(--wot-color-theme, #4d80f0));border-color:var(--wot-switch-active-color, var(--wot-color-theme, #4d80f0))}.wd-switch.is-checked .wd-switch__circle.data-v-55242008{left:calc(var(--wot-switch-width, calc(1.8em + 4px) ) - var(--wot-switch-circle-size, 1em) - 2px);box-shadow:0 2px 4px 0 var(--wot-switch-active-shadow-color, rgba(0, 83, 162, .5))}.wd-switch.is-disabled.data-v-55242008{opacity:.5}
|
||||
Reference in New Issue
Block a user