Skip to content

Commit

Permalink
feat: CIcon component - add 'use' prop, update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
woothu committed Feb 4, 2020
1 parent 01a354e commit 305f295
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/CIconRaw.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<template>
<svg
v-if="!src"
v-if="!src && !use"
xmlns="http://www.w3.org/2000/svg"
:viewBox="viewBox"
:class="computedClasses"
v-html="titleCode + iconCode"
role="img"
></svg>
<img
v-else
v-else-if="src"
:src="src"
role="img"
/>
<svg
v-else-if="use"
xmlns="http://www.w3.org/2000/svg"
:class="computedClasses"
role="img"
>
<use :href="use"></use>
</svg>
</template>

<script>
Expand All @@ -29,7 +37,8 @@ export default {
},
customClasses: [String, Array, Object],
src: String,
title: String
title: String,
use: String
},
computed: {
iconName () {
Expand Down
5 changes: 3 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Vue from 'vue'

export declare class CIcon extends Vue {
export declare class CIconRaw extends Vue {
name: string
content: [string, Array<string>]
size: string
customClasses: [string, Array<any>, object]
src: string
title: string
use: string
}

export declare class CIconRaw extends CIcon {}
export declare class CIcon extends CIconRaw {}

0 comments on commit 305f295

Please sign in to comment.