RayIcon组件调整

This commit is contained in:
ray_wuhao 2023-02-17 14:57:21 +08:00
parent 3eda36374e
commit 646066b918
3 changed files with 30 additions and 12 deletions

View File

@ -1,5 +1,16 @@
.ray-icon {
width: var(--ray-icon-width);
height: var(--ray-icon-height);
border: none;
outline: none;
@include flexCenter;
text-align: center;
display: inline-block;
position: relative;
fill: currentColor;
transform: translateZ(0);
& svg[rayIconAttribute="ray-icon"] {
width: var(--ray-icon-width);
height: var(--ray-icon-height);
}
}

View File

@ -16,7 +16,7 @@ const RayIcon = defineComponent({
props: {
color: {
type: String,
default: '',
default: 'currentColor',
},
prefix: {
type: String,
@ -46,25 +46,32 @@ const RayIcon = defineComponent({
setup(props) {
const modelColor = computed(() => props.color)
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const cssVars = computed(() => {
const cssVar = {
'--ray-icon-width': props.width
? props.width + 'px'
: props.size + 'px',
'--ray-icon-height': props.width
? props.height + 'px'
: props.size + 'px',
}
return cssVar
})
return {
modelColor,
symbolId,
cssVars,
}
},
render() {
return (
<div class={`ray-icon ${this.customClassName}`}>
<svg
ariaHidden={true}
style={{
width: `${this.width ? this.width : this.size}px`,
height: `${this.height ? this.height : this.size}px`,
}}
>
<span class={['ray-icon', this.customClassName]} style={[this.cssVars]}>
<svg rayIconAttribute="ray-icon" ariaHidden={true}>
<use xlink:href={this.symbolId} fill={this.modelColor} />
</svg>
</div>
</span>
)
},
})

View File

@ -43,7 +43,7 @@ const RayLink = defineComponent({
},
{
key: 'ray-template-doc-out',
src: 'https://ray.yunkuangao.com/ray-template-doc/',
src: 'https://ray-template.yunkuangao.com/',
tooltip: 'Ray Template Doc (国内地址)',
icon: 'https://yunkuangao.com/images/longmao.jpeg',
},