first commit
This commit is contained in:
51
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/types.js
vendored
Normal file
51
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/types.js
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
const uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
|
||||
const switchProps = {
|
||||
...uni_modules_wotDesignUni_components_common_props.baseProps,
|
||||
/**
|
||||
* 绑定值
|
||||
*/
|
||||
modelValue: {
|
||||
type: [Boolean, String, Number],
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
/**
|
||||
* 是否禁用
|
||||
*/
|
||||
disabled: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
|
||||
/**
|
||||
* 激活值
|
||||
*/
|
||||
activeValue: {
|
||||
type: [Boolean, String, Number],
|
||||
default: true
|
||||
},
|
||||
/**
|
||||
* 非激活值
|
||||
*/
|
||||
inactiveValue: {
|
||||
type: [Boolean, String, Number],
|
||||
default: false
|
||||
},
|
||||
/**
|
||||
* 激活颜色
|
||||
*/
|
||||
activeColor: String,
|
||||
/**
|
||||
* 非激活颜色
|
||||
*/
|
||||
inactiveColor: String,
|
||||
/**
|
||||
* 大小
|
||||
*/
|
||||
size: {
|
||||
type: uni_modules_wotDesignUni_components_common_props.numericProp
|
||||
},
|
||||
/**
|
||||
* 在改变前执行的函数
|
||||
*/
|
||||
beforeChange: Function
|
||||
};
|
||||
exports.switchProps = switchProps;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/types.js.map
|
||||
80
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.js
vendored
Normal file
80
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.js
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
|
||||
const uni_modules_wotDesignUni_components_wdSwitch_types = require("./types.js");
|
||||
const __default__ = {
|
||||
name: "wd-switch",
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
virtualHost: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
};
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: uni_modules_wotDesignUni_components_wdSwitch_types.switchProps,
|
||||
emits: ["change", "update:modelValue"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const rootClass = common_vendor.computed(() => {
|
||||
return `wd-switch ${props.customClass} ${props.disabled ? "is-disabled" : ""} ${props.modelValue === props.activeValue ? "is-checked" : ""}`;
|
||||
});
|
||||
const rootStyle = common_vendor.computed(() => {
|
||||
const rootStyle2 = {
|
||||
background: props.modelValue === props.activeValue ? props.activeColor : props.inactiveColor,
|
||||
"border-color": props.modelValue === props.activeValue ? props.activeColor : props.inactiveColor
|
||||
};
|
||||
if (props.size) {
|
||||
rootStyle2["font-size"] = uni_modules_wotDesignUni_components_common_util.addUnit(props.size);
|
||||
}
|
||||
return `${uni_modules_wotDesignUni_components_common_util.objToStyle(rootStyle2)}${props.customStyle}`;
|
||||
});
|
||||
const circleStyle = common_vendor.computed(() => {
|
||||
const circleStyle2 = props.modelValue === props.activeValue && props.activeColor || props.modelValue !== props.activeValue && props.inactiveColor ? "box-shadow: none;" : "";
|
||||
return circleStyle2;
|
||||
});
|
||||
function switchValue() {
|
||||
if (props.disabled)
|
||||
return;
|
||||
const newVal = props.modelValue === props.activeValue ? props.inactiveValue : props.activeValue;
|
||||
if (props.beforeChange && uni_modules_wotDesignUni_components_common_util.isFunction(props.beforeChange)) {
|
||||
props.beforeChange({
|
||||
value: newVal,
|
||||
resolve: (pass) => {
|
||||
if (pass) {
|
||||
emit("update:modelValue", newVal);
|
||||
emit("change", {
|
||||
value: newVal
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
emit("update:modelValue", newVal);
|
||||
emit("change", {
|
||||
value: newVal
|
||||
});
|
||||
}
|
||||
}
|
||||
common_vendor.onBeforeMount(() => {
|
||||
if ([props.activeValue, props.inactiveValue].indexOf(props.modelValue) === -1) {
|
||||
emit("update:modelValue", props.inactiveValue);
|
||||
emit("change", {
|
||||
value: props.inactiveValue
|
||||
});
|
||||
}
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.s(circleStyle.value),
|
||||
b: common_vendor.n(rootClass.value),
|
||||
c: common_vendor.s(rootStyle.value),
|
||||
d: common_vendor.o(switchValue)
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-751565c9"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="{{['data-v-751565c9', b]}}" style="{{c}}" bindtap="{{d}}"><view class="wd-switch__circle data-v-751565c9" style="{{a}}"></view></view>
|
||||
218
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.wxss
vendored
Normal file
218
unpackage/dist/dev/mp-weixin/uni_modules/wot-design-uni/components/wd-switch/wd-switch.wxss
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
/* 水平间距 */
|
||||
/* 水平间距 */
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* UI规范基础变量
|
||||
*/
|
||||
/*----------------------------------------- Theme color. start ----------------------------------------*/
|
||||
/* 主题颜色 */
|
||||
/* 辅助色 */
|
||||
/* 文字颜色(默认浅色背景下 */
|
||||
/* 暗黑模式 */
|
||||
/* 图形颜色 */
|
||||
/*----------------------------------------- Theme color. end -------------------------------------------*/
|
||||
/*-------------------------------- Theme color application size. start --------------------------------*/
|
||||
/* 文字字号 */
|
||||
/* 文字字重 */
|
||||
/* 尺寸 */
|
||||
/*-------------------------------- Theme color application size. end --------------------------------*/
|
||||
/* component var */
|
||||
/* action-sheet */
|
||||
/* badge */
|
||||
/* button */
|
||||
/* cell */
|
||||
/* calendar */
|
||||
/* checkbox */
|
||||
/* collapse */
|
||||
/* divider */
|
||||
/* drop-menu */
|
||||
/* input-number */
|
||||
/* input */
|
||||
/* textarea */
|
||||
/* loadmore */
|
||||
/* message-box */
|
||||
/* notice-bar */
|
||||
/* pagination */
|
||||
/* picker */
|
||||
/* col-picker */
|
||||
/* overlay */
|
||||
/* popup */
|
||||
/* progress */
|
||||
/* radio */
|
||||
/* search */
|
||||
/* slider */
|
||||
/* sort-button */
|
||||
/* steps */
|
||||
/* switch */
|
||||
/* tabs */
|
||||
/* tag */
|
||||
/* toast */
|
||||
/* loading */
|
||||
/* tooltip */
|
||||
/* popover */
|
||||
/* grid-item */
|
||||
/* statustip */
|
||||
/* card */
|
||||
/* upload */
|
||||
/* curtain */
|
||||
/* notify */
|
||||
/* skeleton */
|
||||
/* circle */
|
||||
/* swiper */
|
||||
/* swiper-nav */
|
||||
/* segmented */
|
||||
/* tabbar */
|
||||
/* tabbar-item */
|
||||
/* navbar */
|
||||
/* navbar-capsule */
|
||||
/* table */
|
||||
/* sidebar */
|
||||
/* sidebar-item */
|
||||
/* fab */
|
||||
/* count-down */
|
||||
/* keyboard */
|
||||
/* number-keyboard */
|
||||
/* passwod-input */
|
||||
/* form-item */
|
||||
/* backtop */
|
||||
/* index-bar */
|
||||
/* text */
|
||||
/* video-preview */
|
||||
/* img-cropper */
|
||||
/* floating-panel */
|
||||
/* signature */
|
||||
/**
|
||||
* 混合宏
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* BEM,定义块(b)
|
||||
*/
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 此方法用于生成穿透样式 */
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 定义状态(m) */
|
||||
/* 定义状态(m) */
|
||||
/* 对于需要需要嵌套在 m 底下的 e,调用这个混合宏,一般在切换整个组件的状态,如切换颜色的时候 */
|
||||
/* 状态,生成 is-$state 类名 */
|
||||
/**
|
||||
* 常用混合宏
|
||||
*/
|
||||
/* 单行超出隐藏 */
|
||||
/* 多行超出隐藏 */
|
||||
/* 清除浮动 */
|
||||
/* 0.5px 边框 指定方向*/
|
||||
/* 0.5px 边框 环绕 */
|
||||
/**
|
||||
* 三角形实现尖角样式,适用于背景透明情况
|
||||
* @param $size 三角形高,底边为 $size * 2
|
||||
* @param $bg 三角形背景颜色
|
||||
*/
|
||||
/**
|
||||
* 正方形实现尖角样式,适用于背景不透明情况
|
||||
* @param $size 正方形边长
|
||||
* @param $bg 正方形背景颜色
|
||||
* @param $z-index z-index属性值,不得大于外部包裹器
|
||||
* @param $box-shadow 阴影
|
||||
*/
|
||||
.wd-switch.data-v-751565c9 {
|
||||
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 0.3s;
|
||||
}
|
||||
.wd-switch__checkbox.data-v-751565c9 {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.wd-switch__circle.data-v-751565c9 {
|
||||
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 0.3s ease-out;
|
||||
box-shadow: 0 2px 4px 0 var(--wot-switch-inactive-shadow-color, rgba(155, 155, 155, 0.5));
|
||||
}
|
||||
.wd-switch__circle.data-v-751565c9::after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
width: calc(200% - 2px);
|
||||
height: calc(200% - 2px);
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) scale(0.5);
|
||||
border: 1px solid var(--wot-switch-border-color, #e5e5e5);
|
||||
border-radius: 50%;
|
||||
}
|
||||
.wd-switch.is-checked.data-v-751565c9 {
|
||||
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-751565c9 {
|
||||
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, 0.5));
|
||||
}
|
||||
.wd-switch.is-disabled.data-v-751565c9 {
|
||||
opacity: 0.5;
|
||||
}
|
||||
Reference in New Issue
Block a user