Commit 5b7b326d by licheng

feat: 新增图标按钮组件

parent 8db54c2d
<template>
<div
class="icon-btn"
:class="{ disabled: disabled }"
:style="{ width: size + 'px', height: size + 'px' }"
>
<Icon class="icon" :icon="icon" :size="size * 0.5" />
</div>
</template>
<script setup lang="ts">
interface IconButtonProps {
size?: number
icon: string
disabled?: boolean
}
withDefaults(defineProps<IconButtonProps>(), {
size: 40,
icon: '',
disabled: false
})
</script>
<style lang="scss" scoped>
.icon-btn {
background-image: url('@/assets/imgs/button/icon_btn.png');
background-size: 100% 100%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: filter 0.2s;
.icon {
color: #ffffffb5;
}
/* hover 变亮 */
&:hover {
filter: brightness(1.2);
background-color: transparent;
}
/* 按下变暗 */
&:active:not(.disabled) {
filter: brightness(0.95);
background-color: transparent;
}
/* 禁用状态 */
&.disabled {
filter: brightness(0.9);
cursor: not-allowed;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment