How to create a button that open and closed side bar?

I have developed a similar solution few time ago

You can check it here: