diff --git a/packages/varlet-ui/src/badge/Badge.vue b/packages/varlet-ui/src/badge/Badge.vue new file mode 100644 index 00000000000..83ee0a68851 --- /dev/null +++ b/packages/varlet-ui/src/badge/Badge.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/packages/varlet-ui/src/badge/__tests__/index.spec.js b/packages/varlet-ui/src/badge/__tests__/index.spec.js new file mode 100644 index 00000000000..b692cf95e71 --- /dev/null +++ b/packages/varlet-ui/src/badge/__tests__/index.spec.js @@ -0,0 +1,7 @@ +const Badge = require('../../../cjs/badge').default +const { render } = require('@testing-library/vue') + +test('test badge', async () => { + const wrapper = render(Badge) + console.log(wrapper) +}) diff --git a/packages/varlet-ui/src/badge/badge.less b/packages/varlet-ui/src/badge/badge.less new file mode 100644 index 00000000000..bd72b6b8410 --- /dev/null +++ b/packages/varlet-ui/src/badge/badge.less @@ -0,0 +1,94 @@ +@import "../styles/var"; + +.var { + &-fade-leave-to { + opacity: 0; + } + + &-fade-leave-active { + transition: opacity .3s; + } +} + +.var-badge { + display: inline-block; + position: relative; + &__content { + color: #fff; + font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif; + border-radius: 100px; + font-size: 12px; + padding: 2px 6px; + vertical-align: middle; + text-align: center; + display: inline-block; + //.v-icon{ + // font-size: 12px; + // margin: 0 -2px; + //} + } + + &--default { + background: @color-background-base; + } + + &--primary { + background: @color-primary; + } + + &--info { + background: @color-info; + } + + &--warning { + background: @color-warning; + } + + &--success { + background: @color-success; + } + + &--danger { + background: @color-danger; + } + &--right-top{ + position: absolute; + top: 0; + right: 10px; + transform: translateY(-50%) translateX(100%); + } + &--left-top{ + position: absolute; + top: 0; + left: 10px; + transform: translateY(-50%) translateX(-100%); + } + &--right-bottom{ + position: absolute; + bottom: 0; + right: 10px; + transform: translateY(50%) translateX(100%); + } + &--left-bottom{ + position: absolute; + bottom: 0; + left: 10px; + transform: translateY(50%) translateX(-100%); + } + &--position{ + border: 2px #ffffff solid; + } + &--dot { + box-sizing: content-box; + width: 8px; + height: 8px; + border-radius: 8px; + padding: 0; + } + &--dot-right{ + right: 6px; + } + &--dot-left{ + left: 6px; + } +} diff --git a/packages/varlet-ui/src/badge/docs/en_US.md b/packages/varlet-ui/src/badge/docs/en_US.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/varlet-ui/src/badge/docs/zh_CN.md b/packages/varlet-ui/src/badge/docs/zh_CN.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/varlet-ui/src/badge/example/index.vue b/packages/varlet-ui/src/badge/example/index.vue new file mode 100644 index 00000000000..0d81986b917 --- /dev/null +++ b/packages/varlet-ui/src/badge/example/index.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/packages/varlet-ui/src/badge/index.ts b/packages/varlet-ui/src/badge/index.ts new file mode 100644 index 00000000000..e4928999fb6 --- /dev/null +++ b/packages/varlet-ui/src/badge/index.ts @@ -0,0 +1,7 @@ +import Badge from './Badge.vue' + +Badge.install = function(app: any) { + app.component(Badge.name, Badge) +} + +export default Badge diff --git a/packages/varlet-ui/src/badge/props.ts b/packages/varlet-ui/src/badge/props.ts new file mode 100644 index 00000000000..e05620e29f8 --- /dev/null +++ b/packages/varlet-ui/src/badge/props.ts @@ -0,0 +1,48 @@ +function typeValidator(type: string): boolean { + return ['default', 'primary', 'info', 'success', 'warning', 'danger'].includes(type) +} + +function positionValidator(position: string): boolean { + return ['right-top', 'right-bottom', 'left-top', 'left-bottom'].includes(position) +} + +export const props = { +// 徽标类型 + type: { + type: String, + default: 'default', + validator: typeValidator + }, +// 是否隐藏徽标 + hidden: { + type: Boolean, + default: false + }, +// 是否是小圆点 + dot: { + type: Boolean, + default: false + }, +// 显示的值 + value: { + type: [String, Number], + default: 0 + }, +// 显示最大值 + maxValue: { + type: [String, Number] + }, +// 自定义徽标颜色 + color: { + type: String + }, +// 定位位置 + position: { + type: String, + validator: positionValidator + }, +// 图标 + icon:{ + type:String + } +} diff --git a/packages/varlet-ui/src/chip/Chip.vue b/packages/varlet-ui/src/chip/Chip.vue index 22db5210621..e7d467b8a4b 100644 --- a/packages/varlet-ui/src/chip/Chip.vue +++ b/packages/varlet-ui/src/chip/Chip.vue @@ -11,7 +11,7 @@ :class="[ `var-chip--${size}`, block ? 'var--flex' : 'var--inline-flex', - round ? 'var-chip--round' : null, + {'var-chip--round':round}, plain ? `var-chip--plain-${type}` : `var-chip--${type}`, plain ? `var-chip--plain` : `var-elevation--2`, ]" diff --git a/packages/varlet-ui/src/chip/docs/zh_CN.md b/packages/varlet-ui/src/chip/docs/zh_CN.md index 55867ff223a..4895e56bbe5 100644 --- a/packages/varlet-ui/src/chip/docs/zh_CN.md +++ b/packages/varlet-ui/src/chip/docs/zh_CN.md @@ -129,9 +129,9 @@ return {show,show1}; ### 事件 -| 事件名 | 说明 | 回调参数 | 默认值 | -| ---- | ---- | ---- | ----| -|close |点击关闭按钮时触发,只有在显示关闭按钮的时候才能使用| _ | _ | +| 事件名 | 说明 | 回调参数 | +| ---- | ---- | ---- | +| close | 点击关闭按钮时触发,只有在显示关闭按钮的时候才能使用| _ | diff --git a/packages/varlet-ui/src/chip/example/index.vue b/packages/varlet-ui/src/chip/example/index.vue index 24de43919cf..c72e53e62be 100644 --- a/packages/varlet-ui/src/chip/example/index.vue +++ b/packages/varlet-ui/src/chip/example/index.vue @@ -1,60 +1,61 @@ @@ -62,7 +63,6 @@ import { defineComponent, Ref, ref } from 'vue' import Chip from '..' import Icon from '../../icon' - import Snackbar from '../../snackbar' export default defineComponent({ name: 'ChipExample', @@ -92,10 +92,6 @@