├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── App.vue ├── assets └── icons │ ├── badge-check.svg │ ├── cog-solid.svg │ ├── exclamation.svg │ ├── fire.svg │ └── send.svg ├── components ├── SvgIcon.vue └── SvgSprite.vue └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue SVG Icon Demo 2 | 3 | This is a demo repo for a CSS-Tricks article on building [A Font-Like SVG Icon System for Vue](https://css-tricks.com/a-font-like-svg-icon-system-for-vue/). 4 | 5 | [View Live Demo](https://nervous-noyce-943776.netlify.app/) 6 | 7 | The following icons are used for this demo: 8 | - `badge-check` from [Heroicons](https://github.com/refactoringui/heroicons) 9 | - `cog-solid` from [Font Awesome](https://fontawesome.com/icons) 10 | - `excalamation` from [Heroicons](https://github.com/refactoringui/heroicons) 11 | - `fire` from [Heroicons](https://github.com/refactoringui/heroicons) 12 | - `send` from [Material Design Icons](https://material.io/resources/icons) 13 | 14 | ## Install dependencies 15 | ``` 16 | npm install 17 | ``` 18 | 19 | ### Build and run development server 20 | ``` 21 | npm run serve 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-svg-icon-demo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build" 8 | }, 9 | "dependencies": { 10 | "core-js": "^3.6.5", 11 | "vue": "^2.6.11" 12 | }, 13 | "devDependencies": { 14 | "@vue/cli-plugin-babel": "^4.4.0", 15 | "@vue/cli-service": "^4.4.0", 16 | "svg-inline-loader": "^0.8.2", 17 | "vue-template-compiler": "^2.6.11" 18 | }, 19 | "browserslist": [ 20 | "> 1%", 21 | "last 2 versions", 22 | "not dead" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinleedrum/vue-svg-icon-demo/4bf82b340f1e976b857c2856ae3aa7759daef9ea/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 48 | 49 | 127 | -------------------------------------------------------------------------------- /src/assets/icons/badge-check.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/cog-solid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/exclamation.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/fire.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/icons/send.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/SvgIcon.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 22 | 23 | 45 | -------------------------------------------------------------------------------- /src/components/SvgSprite.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 28 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App), 8 | }).$mount('#app') 9 | --------------------------------------------------------------------------------