CI pipeline for a Swift application using Azure DevOps

Nowadays it is hard even to think on having to work on a project without having continuous integration (CI) and continuous deployment (CD) pipelines as part of your development flow. There are simple…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Building Web Components with native Custom Elements

Say we need a modal. We need just one component that behaves in a certain way, without having the overhead of dealing with a new JS/CSS library and all the complexity that comes with it. That’s when the Custom-Element API blows off the doors.

The great thing about this technique is that every custom element comes along with a JS class, so we can write any functionality we want for any element.

So if we name our custom element “CustomModal”, this will be the corresponding ES6 class:

Let’s write some basic modal behavior, we’ll need to show and hide it:

At last, don’t forget to let the browser know there’s a new element in town:

And that’s all the JS we’ll need for today, the rest is HTML & CSS, we’ll need a couple of things, a button to toggle the modal, and the modal:

As for the CSS, we’ll need to drop some shadow on the background, make a floating modal on top of it, and make a class to toggle the visibility of the whole element.

Keep in mind that this technique can serve any kind of UI/UX requirements and really easy to implement.

Add a comment

Related posts:

My Top Ten NFL Running Backs of All Time!!!

The NFL Network decided to create a show ranking the Top 100 players of all time. Recently it was revealed 12 running backs made their list. Once I saw this, I just knew I had to post my own personal…