[js] A large refactor into components