Integrating a simple CSS Class Replacement plugin with Bootstrap 4
In this recipe, we will build on the concepts discussed in the preceding recipe. The plugin we make in this recipe will be used to help us showcase Flexbox layout options in the next chapter. For now, we will focus on making the plugin itself. The goal of the plugin is very simple--we want to have a plugin that we can pass two classes to. Then, in our HTML, we will add a button, and it will serve as a toggle. On clicking it, it will find the first css
class and replace it with the second one. On another click, it will do the opposite.
Getting ready
To get ready, you can review the completed recipe by running harp server in the chapter7/complete
folder and navigating to localhost:9000/recipe07-03
. To see the simple effect we can achieve with this plugin, click on the button that reads Toggle Navbar Color
.
After previewing the result we are trying to achieve, navigate to the chapter7/start
folder and open the _js.ejs
, _nav.ejs...