mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-11 12:57:10 +08:00
first commit
This commit is contained in:
66
src/components/GiTag/index.tsx
Normal file
66
src/components/GiTag/index.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { defineComponent, computed, type PropType } from 'vue'
|
||||
import './tag.scss'
|
||||
|
||||
type TPropsType = 'dark' | 'light' | 'outline' | 'light-outline'
|
||||
type TPropsStatus = 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
||||
type TPropsSize = 'mini' | 'small' | 'large'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'GiTag',
|
||||
props: {
|
||||
type: {
|
||||
type: String as PropType<TPropsType>,
|
||||
default: 'light'
|
||||
},
|
||||
status: {
|
||||
type: String as PropType<TPropsStatus>,
|
||||
default: 'primary'
|
||||
},
|
||||
size: {
|
||||
type: String as PropType<TPropsSize>,
|
||||
default: 'small'
|
||||
},
|
||||
closable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['click', 'close'],
|
||||
setup(props, { slots, emit }) {
|
||||
const className = computed(() => {
|
||||
const arr = ['gi-tag']
|
||||
if (props.type) {
|
||||
arr.push(`gi-tag-${props.type}`)
|
||||
}
|
||||
if (props.size) {
|
||||
arr.push(`gi-tag-size-${props.size}`)
|
||||
}
|
||||
if (props.status) {
|
||||
arr.push(`gi-tag-status-${props.status === 'info' ? 'gray' : props.status}`)
|
||||
}
|
||||
return arr
|
||||
})
|
||||
|
||||
const handleClick = () => {
|
||||
emit('click')
|
||||
}
|
||||
|
||||
const handleClose = (event: MouseEvent) => {
|
||||
event.stopPropagation()
|
||||
emit('close')
|
||||
}
|
||||
|
||||
const CloseIcon = (
|
||||
<span class="gi-tag-close-btn" onClick={(e) => handleClose(e)}>
|
||||
<icon-close class="close-icon" />
|
||||
</span>
|
||||
)
|
||||
|
||||
return () => (
|
||||
<span class={className.value} onClick={handleClick}>
|
||||
{slots.default?.()}
|
||||
{props.closable && CloseIcon}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
})
|
||||
156
src/components/GiTag/tag.scss
Normal file
156
src/components/GiTag/tag.scss
Normal file
@@ -0,0 +1,156 @@
|
||||
.gi-tag {
|
||||
display: inline-flex;
|
||||
padding: 0 8px;
|
||||
// padding-top: 1px;
|
||||
height: 20px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
border-radius: 3px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.gi-tag-close-btn {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
margin-left: 4px;
|
||||
|
||||
.close-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
&::before {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
content: '';
|
||||
position: absolute;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
background-color: transparent;
|
||||
border-radius: var(--border-radius-circle);
|
||||
transition: background-color 0.1s cubic-bezier(0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$status: primary, success, warning, danger, 'gray';
|
||||
|
||||
.gi-tag-dark {
|
||||
color: #fff;
|
||||
|
||||
@each $i in $status {
|
||||
&.gi-tag-status-#{$i} {
|
||||
border: 1px solid rgb(var(--#{$i}-6));
|
||||
background-color: rgb(var(--#{$i}-6));
|
||||
|
||||
.gi-tag-close-btn {
|
||||
&:hover {
|
||||
color: rgb(var(--#{$i}-6));
|
||||
|
||||
&::before {
|
||||
background-color: rgb(var(--#{$i}-2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gi-tag-light {
|
||||
color: #fff;
|
||||
|
||||
@each $i in $status {
|
||||
&.gi-tag-status-#{$i} {
|
||||
color: rgb(var(--#{$i}-6));
|
||||
background-color: rgb(var(--#{$i}-1));
|
||||
|
||||
.gi-tag-close-btn {
|
||||
&:hover {
|
||||
color: #fff;
|
||||
|
||||
&::before {
|
||||
background-color: rgb(var(--#{$i}-6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gi-tag-outline {
|
||||
background: transparent;
|
||||
|
||||
@each $i in $status {
|
||||
&.gi-tag-status-#{$i} {
|
||||
color: rgb(var(--#{$i}-6));
|
||||
border: 1px solid rgb(var(--#{$i}-6));
|
||||
|
||||
.gi-tag-close-btn {
|
||||
&:hover {
|
||||
color: #fff;
|
||||
|
||||
&::before {
|
||||
background-color: rgb(var(--#{$i}-6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gi-tag-light-outline {
|
||||
@each $i in $status {
|
||||
&.gi-tag-status-#{$i} {
|
||||
color: rgb(var(--#{$i}-6));
|
||||
border: 1px solid rgb(var(--#{$i}-2));
|
||||
background-color: rgb(var(--#{$i}-1));
|
||||
|
||||
.gi-tag-close-btn {
|
||||
&:hover {
|
||||
color: #fff;
|
||||
|
||||
&::before {
|
||||
background-color: rgb(var(--#{$i}-6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gi-tag-size-mini {
|
||||
height: 22px;
|
||||
padding: 0 4px;
|
||||
|
||||
.gi-tag-close-btn {
|
||||
.close-icon {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
&::before {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.gi-tag-size-small {
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.gi-tag-size-large {
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
Reference in New Issue
Block a user