import * as React from 'react'; import * as ReactDOM from 'react-dom'; import './App.css'; import JqxNavigationBar from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxnavigationbar'; class App extends React.PureComponent<{}> { constructor(props: {}) { super(props); } public componentDidMount() { const Tolkien =
The Hobbit
The Lord of the Rings
The Silmarillion
; const Brooks =
The Sword of Shannara
The Elfstones of Shannara
The Wishsong of Shannara
Running with the Demon
A Knight of the Word
Angel Fire East
; const Rowling =
Harry Potter and the Philosopher's Stone
Harry Potter and the Chamber of Secrets
Harry Potter and the Prisoner of Azkaban
Harry Potter and the Goblet of Fire
Harry Potter and the Order of the Phoenix
Harry Potter and the Half-Blood Prince
Harry Potter and the Deathly Hallows
; const Wells =
The Time Machine
The War of the Worlds
; const Green =
Deathstalker
Deathstalker Rebellion
Deathstalker War
Deathstalker Honor
Deathstalker Destiny
; const Lovecraft =
The Call of Cthulhu
At the Mountains of Madness
; const King =
Carrie
Night Shift
It
The Dark Half
; const bookShelf = document.getElementById('bookShelf'); ReactDOM.render(Tolkien, bookShelf, () => { let booksNum = 0; const addToShoppingCart = () => { booksNum++; document.getElementById('text')!.innerHTML = 'Added ' + booksNum + (booksNum === 1 ? ' book' : ' books') + ' to shopping cart.'; }; const booksImages = document.querySelectorAll('.book img'); Array.prototype.forEach.call(booksImages, (image: HTMLImageElement) => { image.addEventListener('click', addToShoppingCart); image.style.cursor = 'pointer'; }); const liTags = document.getElementsByTagName('li'); Array.prototype.forEach.call(liTags, (liTag: HTMLLIElement, index: number) => { liTag.addEventListener('click', () => { ReactDOM.unmountComponentAtNode(bookShelf!); let newBook: any; switch (index) { case 0: newBook = Tolkien; break; case 1: newBook = Brooks; break; case 2: newBook = Rowling; break; case 3: newBook = Wells; break; case 4: newBook = Green; break; case 5: newBook = Lovecraft; break; case 6: newBook = King; break; }; ReactDOM.render(newBook!, bookShelf, () => { const booksImagesEl = document.querySelectorAll('.book img'); Array.prototype.forEach.call(booksImagesEl, (image: HTMLImageElement) => { image.addEventListener('click', addToShoppingCart); image.style.cursor = 'pointer'; }); }); }); }); }); } public render() { return (
Fantasy
  • J. R. R. Tolkien
  • Terry Brooks
  • J. K. Rowling
Science Fiction
  • H. G. Wells
  • Simon R. Green
Horror
  • H. P. Lovecraft
  • Stephen King
Shopping cart is empty.
); } } export default App;