-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve svg icon support (#933)
Co-authored-by: Lee Chase <[email protected]>
- Loading branch information
Showing
9 changed files
with
112 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
exampleSvgString: ` | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" id="root"> | ||
<g fill-rule="evenodd" id="g"> | ||
<path id="path" d="M7 7H4v2h3v3h2V9h3V7H9V4H7v3zm1 9A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"/> | ||
</g> | ||
</svg> | ||
`, | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script> | ||
import CvWrapper from '../cv-wrapper/_cv-wrapper'; | ||
export default { | ||
name: 'CvSvg', | ||
components: { CvWrapper }, | ||
props: { | ||
svg: { | ||
type: [String, Object], | ||
default: undefined, | ||
validator(val) { | ||
if (!val || typeof val === 'string') { | ||
return true; | ||
} | ||
return val.render !== null; | ||
}, | ||
}, | ||
}, | ||
computed: { | ||
isSvg() { | ||
return this.svg !== undefined && this.svg.indexOf('<svg') >= 0; | ||
}, | ||
isSymbol() { | ||
return this.svg !== undefined && !this.isSvg && this.svg.indexOf('#') >= 0; | ||
}, | ||
}, | ||
render(createElement) { | ||
if (typeof this.svg === 'object') { | ||
return createElement('component', { is: this.svg }); | ||
} else if (this.isSvg) { | ||
return createElement('svg', { domProps: { innerHTML: this.svg } }); | ||
} else { | ||
if (this.isSymbol) { | ||
return createElement('svg', {}, [createElement('use', { attrs: { href: this.svg } })]); | ||
} else { | ||
return createElement('img', { attrs: { src: this.svg } }); | ||
} | ||
} | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters