Last active
June 8, 2020 18:24
-
-
Save mikermcneil/c82e89f01687896a873ae95b1b8bb81c to your computer and use it in GitHub Desktop.
Reference component (parasails / Vue)
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
/** | |
* <avatar> | |
* ----------------------------------------------------------------------------- | |
* | |
* @type {Component} | |
* | |
* --- SLOTS: --- | |
* N/A | |
* | |
* --- EVENTS EMITTED: --- | |
* N/A | |
* | |
* ----------------------------------------------------------------------------- | |
*/ | |
parasails.registerComponent('avatar', { | |
// ╔═╗╦ ╦╔╗ ╦ ╦╔═╗ ╔═╗╦═╗╔═╗╔═╗╔═╗ | |
// ╠═╝║ ║╠╩╗║ ║║ ╠═╝╠╦╝║ ║╠═╝╚═╗ | |
// ╩ ╚═╝╚═╝╩═╝╩╚═╝ ╩ ╩╚═╚═╝╩ ╚═╝ | |
props: [ | |
'user',// dictionary consisting of "id", "firstName", and "lastName" (the former for building an image src, the latter two for initials) | |
'size',// "small" , "medium", or "large" | |
], | |
// ╦╔╗╔╦╔╦╗╦╔═╗╦ ╦╔╗╔╔╦╗╔═╗╦═╗╔╗╔╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗ | |
// ║║║║║ ║ ║╠═╣║ ║║║║ ║ ║╣ ╠╦╝║║║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣ | |
// ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╩╝╚╝ ╩ ╚═╝╩╚═╝╚╝╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝ | |
data: function () { | |
return { | |
// TODO: private state | |
}; | |
}, | |
beforeMount: function() { | |
// TODO: validate & absorb props | |
}, | |
// ╦ ╦╔╦╗╔╦╗╦ | |
// ╠═╣ ║ ║║║║ | |
// ╩ ╩ ╩ ╩ ╩╩═╝ | |
template: ` | |
<div> | |
hello | |
</div> | |
`, | |
// ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗ | |
// ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣ | |
// ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝ | |
mounted: async function () { | |
}, | |
watch: { | |
size: function(that) { | |
// TODO (but only if we'll react to changes to this prop from the outside) | |
}, | |
user: function(that) { | |
// TODO (but only if we'll react to changes to this prop from the outside) | |
}, | |
}, | |
beforeDestroy: function() { | |
}, | |
// ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗ | |
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗ | |
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝ | |
methods: { | |
// ╦╔╗╔╔╦╗╔═╗╦═╗╔╗╔╔═╗╦ ╔═╗╦ ╦╔═╗╔╗╔╔╦╗ ╦ ╦╔═╗╔╗╔╔╦╗╦ ╔═╗╦═╗╔═╗ | |
// ║║║║ ║ ║╣ ╠╦╝║║║╠═╣║ ║╣ ╚╗╔╝║╣ ║║║ ║ ╠═╣╠═╣║║║ ║║║ ║╣ ╠╦╝╚═╗ | |
// ╩╝╚╝ ╩ ╚═╝╩╚═╝╚╝╩ ╩╩═╝ ╚═╝ ╚╝ ╚═╝╝╚╝ ╩ ╩ ╩╩ ╩╝╚╝═╩╝╩═╝╚═╝╩╚═╚═╝ | |
//… | |
// ╔═╗╦ ╦╔╗ ╦ ╦╔═╗ ╔╦╗╔═╗╔╦╗╦ ╦╔═╗╔╦╗╔═╗ | |
// ╠═╝║ ║╠╩╗║ ║║ ║║║║╣ ║ ╠═╣║ ║ ║║╚═╗ | |
// ╩ ╚═╝╚═╝╩═╝╩╚═╝ ╩ ╩╚═╝ ╩ ╩ ╩╚═╝═╩╝╚═╝ | |
// > Public methods are rarely exposed by Vue components, but sometimes they | |
// > are an important escape hatch. They are callable via something like | |
// > `this.$refs.avatar.doSomething())`, and, by convention, are always | |
// > prefixed with "do". | |
// N/A | |
// ╔═╗╦═╗╦╦ ╦╔═╗╔╦╗╔═╗ ╔╦╗╔═╗╔╦╗╦ ╦╔═╗╔╦╗╔═╗ | |
// ╠═╝╠╦╝║╚╗╔╝╠═╣ ║ ║╣ ║║║║╣ ║ ╠═╣║ ║ ║║╚═╗ | |
// ╩ ╩╚═╩ ╚╝ ╩ ╩ ╩ ╚═╝ ╩ ╩╚═╝ ╩ ╩ ╩╚═╝═╩╝╚═╝ | |
//… | |
} | |
}); |
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
/** | |
* <avatar> | |
* | |
* App-wide styles for our avatars. | |
*/ | |
[parasails-component='avatar'] { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment