-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
958edef
commit 839b601
Showing
26 changed files
with
630 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ColorRadioPicker from './src/ColorRadioPicker.vue' | ||
|
||
export { ColorRadioPicker } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script setup lang="ts"> | ||
import { PropType, watch, unref, ref } from 'vue' | ||
import { propTypes } from '@/utils/propTypes' | ||
const props = defineProps({ | ||
schema: { | ||
type: Array as PropType<string[]>, | ||
default: () => [] | ||
}, | ||
modelValue: propTypes.string.def('') | ||
}) | ||
const emit = defineEmits(['update:modelValue', 'change']) | ||
const colorVal = ref(props.modelValue) | ||
watch( | ||
() => props.modelValue, | ||
(val: string) => { | ||
if (val === unref(colorVal)) return | ||
colorVal.value = val | ||
} | ||
) | ||
// 监听 | ||
watch( | ||
() => colorVal.value, | ||
(val: string) => { | ||
emit('update:modelValue', val) | ||
emit('change', val) | ||
} | ||
) | ||
</script> | ||
|
||
<template> | ||
<div class="v-color-radio-picker flex flex-wrap space-x-14px"> | ||
<span | ||
v-for="(item, i) in schema" | ||
:key="`radio-${i}`" | ||
class="v-color-radio-picker w-20px h-20px cursor-pointer rounded-2px border-solid border-gray-300 border-2px text-center leading-20px mb-5px" | ||
:class="{ 'is-active': colorVal === item }" | ||
:style="{ | ||
background: item | ||
}" | ||
@click="colorVal = item" | ||
> | ||
<Icon v-if="colorVal === item" color="#fff" icon="ep:check" :size="16" /> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<style lang="less" scoped> | ||
@prefix-cls: ~'@{namespace}-color-radio-picker'; | ||
.@{prefix-cls} { | ||
.is-active { | ||
border-color: var(--el-color-primary); | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.