Fix svg sprite
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Philipp Lang 2023-06-01 11:31:12 +02:00
parent 1d8b5b4670
commit 9e1fe63c33
4 changed files with 28 additions and 18 deletions

View File

@ -24,7 +24,7 @@ steps:
- name: node
image: node:17.9.0-slim
commands:
- npm ci && npm run prod && npm run img && rm -R node_modules
- npm ci && npm run img && npm run prod && rm -R node_modules
- name: phpunit_tests
image: php:8.1.6

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
/node_modules
/public/build
/public/sprite.svg
/public/hot
/storage/*.key
/vendor
.env

View File

@ -2,12 +2,12 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "npx mix build",
"watch": "npx mix watch",
"hot": "npx mix watch --hot",
"prod": "npx mix build --production",
"development": "npx vite",
"watch": "npx vite",
"hot": "npx vite",
"prod": "npx vite build",
"production": "npm run prod",
"img": "rm -R public/img && cd resources/img/svg && npx svg-sprite -s --symbol-dest=sprite *.svg && mv sprite/svg/sprite.css.svg ../sprite.svg && rm -R sprite && cd ../../../ && cp -R resources/img public/img",
"img": "cd resources/img/svg && npx svg-sprite -s --symbol-dest=sprite *.svg && mv sprite/svg/sprite.css.svg ../../../public/sprite.svg && rm -R sprite",
"lint": "eslint \"resources/js/**/*.{js,vue}\"",
"fix": "eslint \"resources/js/**/*.{js,vue}\" --fix"
},

View File

@ -1,17 +1,25 @@
export default {
props: {
src: { required: true, type: String }
src: {required: true, type: String},
},
render: function(createElement) {
render: function (createElement) {
var attr = this.$attrs.class ? this.$attrs.class : '';
return createElement('svg', {
class: attr + ' fill-current'
}, [
createElement('use', {
'attrs': {
'xlink:href': `/img/sprite.svg#${this.$props.src}`
}
}, '')
] );
}
return createElement(
'svg',
{
class: attr + ' fill-current',
},
[
createElement(
'use',
{
attrs: {
'xlink:href': `/sprite.svg#${this.$props.src}`,
},
},
''
),
]
);
},
};