Skip to content

fix(tag): 修复关闭icon没有垂直居中的bug #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/devui-vue/devui/tag/src/hooks/use-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { tagProps, TagProps } from '../tag-types'

export default function (props: TagProps) {
return computed(() => {
const { type, color } = props
return `devui-tag devui-tag-${type || (color ? 'colorful' : '') || 'default'}`
const { type, color, deletable } = props
return `devui-tag devui-tag-${type || (color ? 'colorful' : '') || 'default'} ${
deletable ? 'devui-tag-deletable' : ''
}`
})
}
15 changes: 11 additions & 4 deletions packages/devui-vue/devui/tag/src/tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ $devui-tag-normal-config: (
),
colorful: (
background-color: #fff
),
deletable: (
padding-right: 32px
)
);

Expand All @@ -48,7 +51,7 @@ $devui-tag-normal-config: (
position: relative;
cursor: default;

@each $type in default, primary, success, warning, danger, colorful {
@each $type in default, primary, success, warning, danger, colorful, deletable {
&.devui-tag-#{$type} {
@each $key, $value in map-get($devui-tag-normal-config, $type) {
#{$key}: $value;
Expand All @@ -66,8 +69,12 @@ $devui-tag-normal-config: (
line-height: 12px;
border-radius: 50%;
text-align: center;
position: relative;
top: -0.22em;
vertical-align: middle;
position: absolute;
top: 50%;
transform: translateY(-50%);
i {
/* 取消icon自带的偏移 */
vertical-align: 0;
}
}
}