How to use wa-card with Vue
Last month, I talked about wanting to spend some time exploring Web Awesome and Vue.js. I figured that we would start with the wa-card element. This is a great option for displaying a collection of elements that have photos, names, and descriptions. Let’s take a look at a simple example.
See the Pen
wa-card demo 1 by Joe Steinbring (@steinbring)
on CodePen.
Web Awesome is an open-source library of web-standards-based and framework-agnostic UI components, so adapting them to work with Vue.js is easy. We just need variables for each of the elements of the content and a little createApp() magic.
See the Pen
wa-card demo 2: Duplicating with Vue by Joe Steinbring (@steinbring)
on CodePen.
The above example gives you the same result as the first one, but instead of the values being in the markup, they are in JavaScript variables. So, how do we adapt this to work with more complex data?
See the Pen
wa-card demo 3: Rendering an array by Joe Steinbring (@steinbring)
on CodePen.
In the above example, we are looping over a 3-item array using v-for. Since the only styling on the example is a width on the cards, it looks a little off. We can fix that with a little grid magic, though.
See the Pen
wa-card demo 4: Rendering an array with extra styling by Joe Steinbring (@steinbring)
on CodePen.
In the next post, let’s see if we can take this to the next level.
First example: https://codepen.io/steinbring/pen/myVGdNZ/18bc9a394c2cd81a5e2b681fc6b82a8b
Second example: https://codepen.io/steinbring/pen/EaPeaVL/1beda6ab3caf156ee035c3b7927abf86
Third example: https://codepen.io/steinbring/pen/qEbJYmK/9b204ee51460e0811d9725260f93381f
Fourth example: https://codepen.io/steinbring/pen/JoGmvmm/2b3a7a1cf0eef1bb42b2614a965f6ee0
#VueJs #WebAwesome