Last active
April 24, 2025 17:16
-
-
Save Kcko/4355df62df7c913a7c9ace6a95a6d189 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// my version - inspired by https://michaelnthiessen.com/stealing-prop-types/ | |
// iconDefault.js | |
export const iconDefaults = { | |
size: 'medium', | |
shape: 'circle', | |
icon: 'default', | |
animation: 'none' | |
}; | |
<!-- Icon.vue --> | |
<script setup> | |
import { iconDefaults } from './iconDefaults.js'; | |
const props = defineProps({ | |
size: { type: String, default: iconDefaults.size }, | |
shape: { type: String, default: iconDefaults.shape }, | |
icon: { type: String, default: iconDefaults.icon }, | |
animation: { type: String, default: iconDefaults.animation } | |
}); | |
</script> | |
<!-- Panel.vue --> | |
<script setup> | |
import Icon from './Icon.vue'; | |
import { iconDefaults } from './iconDefaults.js'; | |
import { computed } from 'vue'; | |
const props = defineProps({ | |
heading: String, | |
withIcons: Boolean, | |
iconConfig: { | |
type: Object, | |
default: () => ({ ...iconDefaults }) | |
} | |
}); | |
const finalIconConfig = computed(() => { | |
return { ...iconDefaults, ...props.iconConfig }; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment