diff --git a/source/_posts/2018-12-16-published-my-first-npm-package.md b/source/_posts/2018-12-16-published-my-first-npm-package.md new file mode 100644 index 00000000..d8db8178 --- /dev/null +++ b/source/_posts/2018-12-16-published-my-first-npm-package.md @@ -0,0 +1,95 @@ +--- +title: Published my first NPM package +tags: + - npm + - tailwind-css + - vuejs +--- +{% block excerpt %} +Yesterday I published my first module onto NPM, and it’s a plugin for [Tailwind CSS][tailwind] to be used alongside [Vue.js](https://vuejs.org). +{% endblock %} + +{% block content %} +The plugin adds classes for showing and hiding elements in different display variations in combination with Vue's [v-cloak directive](https://vuejs.org/v2/api/#v-cloak), which I originally saw in [the first 'Building Kitetail' video](https://youtu.be/XUXpcbYQ_iQ?t=2360). These are useful for when you want an element to be visible whilst Vue is compiling, and hidden afterwards. + +Here is the compiled CSS that is added by the plugin: + +```css +[v-cloak] .v-cloak-block { + display: block; +} + +[v-cloak] .v-cloak-flex { + display: flex; +} + +[v-cloak] .v-cloak-hidden { + display: none; +} + +[v-cloak] .v-cloak-inline { + display: inline; +} + +[v-cloak] .v-cloak-inline-block { + display: inline-block; +} + +[v-cloak] .v-cloak-inline-flex { + display: inline-flex; +} + +[v-cloak] .v-cloak-invisible { + visibility: hidden; +} + +.v-cloak-block, +.v-cloak-flex, +.v-cloak-inline, +.v-cloak-inline-block, +.v-cloak-inline-flex { + display: none; +} +``` + +The `v-cloak` directive exists on an element until Vue finishes compiling, after which it is removed. Therefore adding a `v-cloak-block` class to an element will make it `display: block` whilst Vue is compiling and the element is cloaked, and `display: none` afterwards when the Vue markup is compiled and rendered. + +In my `base.html.twig` template, I’ve added `v-cloak` to the wrapper div within the `body`. + +{% raw %}