This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee82b45
commit 9a16b3d
Showing
10 changed files
with
75 additions
and
51 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
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
module.exports = { | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
env: { | ||
test: { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
'@babel/preset-env', | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} | ||
targets: { | ||
node: 'current', | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: ['require-context-hook'], | ||
}, | ||
}, | ||
}; |
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,17 @@ | ||
<template> | ||
<component :is="name" class="icon" /> | ||
</template> | ||
|
||
<script> | ||
import components from '~/utils/get-icons'; | ||
export default { | ||
components, | ||
props: { | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</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
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 |
---|---|---|
@@ -1,33 +1,7 @@ | ||
/** | ||
* Inject a global `VueIcon` component. | ||
* Inject the `VueIcon` component globally. | ||
*/ | ||
import Vue from 'vue'; | ||
import VueIcon from '~/components/Icon'; | ||
|
||
const files = require.context('~/assets/svg', true, /[\s\S]*$/); | ||
const components = files.keys().reduce((icons, path) => { | ||
const file = path.replace('./', ''); | ||
const key = file.replace('.svg', ''); | ||
icons[key] = async () => import(`~/assets/svg/${file}`); | ||
return icons; | ||
}, {}); | ||
|
||
Vue.component('vue-icon', { | ||
components, | ||
props: { | ||
/** | ||
* The name of the icon. | ||
*/ | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
render(h) { | ||
console.log(this); | ||
return h(this.name, { | ||
class: 'icon', | ||
on: this.$listeners, | ||
attr: this.$attrs, | ||
}); | ||
}, | ||
}); | ||
Vue.component('vue-icon', VueIcon); |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Logo from '@/components/Logo'; | ||
import { createLocalVue, shallowMount } from '@vue/test-utils'; | ||
import VueIcon from '~/components/Icon'; | ||
import Logo from '~/components/Logo'; | ||
|
||
const localVue = createLocalVue(); | ||
localVue.component('vue-icon', VueIcon); | ||
|
||
describe('Logo', () => { | ||
test('is a Vue instance', () => { | ||
const wrapper = mount(Logo); | ||
const wrapper = shallowMount(Logo, { localVue }); | ||
expect(wrapper.isVueInstance()).toBeTruthy(); | ||
}); | ||
}); |
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,3 @@ | ||
import registerRequireContextHook from 'babel-plugin-require-context-hook/register'; | ||
|
||
registerRequireContextHook(); |
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,9 @@ | ||
const files = require.context('../assets/svg/', true, /\.svg$/); | ||
const components = files.keys().reduce((icons, path) => { | ||
const file = path.replace('./', ''); | ||
const key = file.replace('.svg', ''); | ||
icons[key] = async () => import(`~/assets/svg/${file}`); | ||
return icons; | ||
}, {}); | ||
|
||
export default components; |