Skip to content

Commit

Permalink
Merge pull request #51 from Lsq128/main
Browse files Browse the repository at this point in the history
feat(components): svgIcon,添加type,调整size方案
  • Loading branch information
honghuangdc authored Feb 27, 2022
2 parents 1a9efee + ce4e039 commit f92d7ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 35 deletions.
42 changes: 15 additions & 27 deletions src/components/svg/SvgIcon.vue
Original file line number Diff line number Diff line change
@@ -1,43 +1,31 @@
<template>
<svg :style="svgStyle" class="svg-icon" aria-hidden="true">
<svg class="svg-icon" aria-hidden="true">
<use :xlink:href="symbolId" :fill="fill" />
</svg>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
prefix: {
type: String,
default: 'icon'
},
name: {
type: String,
required: true
},
size: {
type: [String, Number],
default: 30
},
color: {
type: String,
default: ''
}
});
const svgStyle = computed(() => {
const { size } = props;
let s = `${size}`;
s = `${s.replace('px', '')}px`;
return {
width: s,
height: s
};
interface Props {
/** icon前缀 */
prefix?: string;
/** icon 名称 */
name: string;
/** 填充颜色 */
color?: string;
}
const props = withDefaults(defineProps<Props>(), {
prefix: 'icon',
name: '',
color: ''
});
const fill = computed(() => props.color || 'currentColor');
const symbolId = computed(() => `#${props.prefix}-${props.name}`);
</script>
<style scoped>
.svg-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
overflow: hidden;
}
Expand Down
7 changes: 0 additions & 7 deletions src/plugins/svg-icon.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/views/plugin/icon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="grid grid-cols-10">
<template v-for="item in svgIcons" :key="item">
<div class="mt-5px flex-x-center">
<svg-icon :name="item" />
<svg-icon :name="item" class="text-30px" />
</div>
</template>
</div>
Expand Down

1 comment on commit f92d7ec

@vercel
Copy link

@vercel vercel bot commented on f92d7ec Feb 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.