更新:登录功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
@import "./../common/abstracts/_mixin.scss";
|
||||
@import "./../common/abstracts/variable.scss";
|
||||
|
||||
.wot-theme-dark {
|
||||
@include b(radio-group) {
|
||||
background-color: $-dark-background2;
|
||||
}
|
||||
}
|
||||
|
||||
@include b(radio-group) {
|
||||
background-color: $-radio-bg;
|
||||
font-size: 0;
|
||||
|
||||
// 上下20px 左右15px 内部间隔12px
|
||||
@include when(button) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 8px 3px 20px 15px;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { type InjectionKey } from 'vue'
|
||||
import type { RadioShape, RadioIconPlacement } from '../wd-radio/types'
|
||||
import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'
|
||||
|
||||
export type RadioGroupProvide = {
|
||||
props: {
|
||||
modelValue?: string | number | boolean
|
||||
shape?: RadioShape
|
||||
checkedColor?: string
|
||||
disabled?: boolean
|
||||
cell?: boolean
|
||||
size?: string
|
||||
inline?: boolean
|
||||
iconPlacement?: RadioIconPlacement
|
||||
}
|
||||
updateValue: (value: string | number | boolean) => void
|
||||
}
|
||||
|
||||
export const RADIO_GROUP_KEY: InjectionKey<RadioGroupProvide> = Symbol('wd-radio-group')
|
||||
|
||||
export const radioGroupProps = {
|
||||
...baseProps,
|
||||
/** 会自动选中value对应的单选框 */
|
||||
modelValue: [String, Number, Boolean],
|
||||
/** 单选框形状,可选值为 dot / button / check,默认为 check */
|
||||
shape: makeStringProp<RadioShape>('check'),
|
||||
/** 选中的颜色,默认为 #4D80F0 */
|
||||
checkedColor: String,
|
||||
/** 是否禁用,默认为 false */
|
||||
disabled: makeBooleanProp(false),
|
||||
/** 表单模式,默认为 false */
|
||||
cell: makeBooleanProp(false),
|
||||
/** 设置大小,默认为空 */
|
||||
size: makeStringProp(''),
|
||||
/** 同行展示,默认为 false */
|
||||
inline: makeBooleanProp(false),
|
||||
/** 图标位置,默认为 left */
|
||||
iconPlacement: makeStringProp<RadioIconPlacement>('auto')
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<view :class="`wd-radio-group ${customClass} ${cell && shape === 'button' ? 'is-button' : ''}`" :style="customStyle">
|
||||
<slot />
|
||||
</view>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'wd-radio-group',
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: 'shared'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch } from 'vue'
|
||||
import { useChildren } from '../composables/useChildren'
|
||||
import { RADIO_GROUP_KEY, radioGroupProps } from './types'
|
||||
|
||||
const props = defineProps(radioGroupProps)
|
||||
const emit = defineEmits(['change', 'update:modelValue'])
|
||||
|
||||
const { linkChildren, children } = useChildren(RADIO_GROUP_KEY)
|
||||
|
||||
linkChildren({ props, updateValue })
|
||||
|
||||
watch(
|
||||
() => props.shape,
|
||||
(newValue) => {
|
||||
// type: 'dot', 'button', 'check'
|
||||
const type = ['check', 'dot', 'button']
|
||||
if (type.indexOf(newValue) === -1) console.error(`shape must be one of ${type.toString()}`)
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
)
|
||||
|
||||
/**
|
||||
* @description 处理radio子节点通知
|
||||
*/
|
||||
function updateValue(value: string | number | boolean) {
|
||||
emit('update:modelValue', value)
|
||||
emit('change', {
|
||||
value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './index.scss';
|
||||
</style>
|
||||
Reference in New Issue
Block a user