Advertisement
Guest User

index.js

a guest
Oct 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // @flow
  2. /* eslint eqeqeq: "off" */
  3.  
  4. import ReactDOM from 'react-dom';
  5. import * as React from 'react';
  6. import { Component, sharedComponentData } from 'react-simplified';
  7. import { HashRouter, Route, NavLink } from 'react-router-dom';
  8.  
  9. import { createHashHistory } from 'history';
  10. const history = createHashHistory(); // Use history.push(...) to programmatically change path, for instance after successfully saving a student
  11.  
  12. class CardBig extends Component<{
  13.   headline: string,
  14.   image: string,
  15.   case_id: number,
  16.   children?: React.Node
  17. }> {
  18.   render() {
  19.     return (
  20.         <section>
  21.           <div className="container">
  22.             <div className="card"  onClick={this.onClick}>
  23.               <div className="card-body">
  24.                 <div className="row">
  25.                   <div className="col-md-6">
  26.                     <div className="card-block">
  27.                       <h4 className="card-title">{this.props.headline}</h4>
  28.                       {this.props.children}
  29.                     </div>
  30.                   </div>
  31.                   <div className="col-md-6">
  32.                     <div className="card-img-bottom">
  33.                       <img className="CardBigImage" src={this.props.image}></img>
  34.                     </div>
  35.                   </div>
  36.                 </div>
  37.               </div>
  38.             </div>
  39.           </div>
  40.         </section>
  41.     );
  42.   }
  43.   onClick() {
  44.     history.push('/case/' + this.props.case_id)
  45.   }
  46. }
  47.  
  48. class CaseCard extends Component<{
  49.   case_id: number,
  50. }> {
  51.   headline = "test";
  52.   content = "test";
  53.   post_time = 1;
  54.   image = "https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg";
  55.   priority = 1;
  56.  
  57.   render() {
  58.  
  59.     return (
  60.         <section>
  61.           <div className="container">
  62.             <div className="card"  onClick={this.onClick}>
  63.               <div className="card-body">
  64.                 <div className="row">
  65.                   <div className="col-md-6">
  66.                     <div className="card-block">
  67.                       <h4 className="card-title">{this.headline}</h4>
  68.                       <p className="card-text">{this.content}</p>
  69.                     </div>
  70.                   </div>
  71.                   <div className="col-md-6">
  72.                     <div className="card-img-bottom">
  73.                       <img className="CaseImage" src={this.image}></img>
  74.                     </div>
  75.                   </div>
  76.                 </div>
  77.               </div>
  78.             </div>
  79.           </div>
  80.         </section>
  81.     );
  82.   }
  83. }
  84.  
  85. class CardSmall extends Component<{
  86.   headline: string,
  87.   case_id: number,
  88.   children?: React.Node,
  89.   onClick?: () => mixed
  90. }> {
  91.   render() {
  92.     return (
  93.         <section>
  94.           <div className="container">
  95.             <div className="card"  onClick={this.onClickCase}>
  96.               <div className="card-body">
  97.                 <div className="row">
  98.                   <div className="card-block">
  99.                     <h4 className="card-title">{this.props.headline}</h4>
  100.                     {this.props.children}
  101.                   </div>
  102.                 </div>
  103.               </div>
  104.             </div>
  105.           </div>
  106.         </section>
  107.     );
  108.   }
  109.   onClickCase() {
  110.     history.push('/case/' + this.case_id)
  111.   }
  112. }
  113.  
  114. class Banner extends Component {
  115.   render() {
  116.     return <div className="card" onClick={this.onClick}>
  117.       <div className="card-body">
  118.         <h5 className="card-title">VĂĽr Avis</h5>
  119.       </div>
  120.     </div>;
  121.   }
  122.   onClick() {
  123.     history.push('/')
  124.   }
  125. }
  126.  
  127. class Navbar extends Component {
  128.   render() {
  129.     return <div>
  130.       <nav className="navbar navbar-expand-lg navbar-light bg-light">
  131.         <ul className="navbar-nav mr-auto">
  132.           <li className="nav-item active">
  133.             <a className="navbar-brand" href="/">Hjem<span className="sr-only">(current)</span></a>
  134.           </li>
  135.           <li className="nav-item">
  136.             <a className="nav-link" href="/">Kategorier</a>
  137.           </li>
  138.           <li className="nav-item">
  139.             <a className="nav-link" href="#/add">Legg Til</a>
  140.           </li>
  141.         </ul>
  142.       </nav>
  143.     </div>;
  144.   }
  145. }
  146.  
  147. class Case extends Component<{ match: { params: { id: number } } }> {
  148.   header = "Header";
  149.   content = "Content";
  150.   image = "https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg";
  151.  
  152.   render() {
  153.     return <div className="card">
  154.       <div className="card-body">
  155.         <div className="row">
  156.           <div className="col-md-6">
  157.           <h4 className="card-title">{this.header}</h4>
  158.             <p>{this.content}</p>
  159.           </div>
  160.           <div className="col-md-6">
  161.             <img className="CaseImage" src={this.image}></img>
  162.           </div>
  163.         </div>
  164.       </div>
  165.     </div>
  166.   }
  167. }
  168.  
  169. class CaseAdd extends Component<{ match: { params: { id: number } } }> {
  170.   render() {
  171.     return <div className="card card-body">
  172.       <form>
  173.         <div className="row">
  174.           <div className="col-md-6">
  175.             <h5 className="card-title">Tittel*</h5>
  176.             <input className="input-group-text input-group" />
  177.             <h5 className="card-title">Beskrivelse*</h5>
  178.             <input className="input-group-text input-group" />
  179.             <h5 className="card-title">Innhold*</h5>
  180.             <input className="input-group-text input-group CaseInput" />
  181.           </div>
  182.           <div className="col-md-6">
  183.             <h5 className="card-title">Bilde-adresse*</h5>
  184.             <input className="input-group-text input-group" />
  185.             <h5 className="card-title">Bildetekst*</h5>
  186.             <input className="input-group-text input-group" />
  187.             <h5 className="card-title">Forfatter*</h5>
  188.             <input className="input-group-text input-group " />
  189.           </div>
  190.         </div>
  191.       </form>
  192.     </div>
  193.   }
  194. }
  195.  
  196. class Home extends Component {
  197.   render() {
  198.     return <div>
  199.       <div className="card cardInLine">
  200.         <div className="row card-body">
  201.           <div className="col-sm-2">
  202.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  203.           </div>
  204.           <div className="col-sm-2">
  205.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  206.           </div>
  207.           <div className="col-sm-2">
  208.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  209.           </div>
  210.           <div className="col-sm-2">
  211.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  212.           </div>
  213.           <div className="col-sm-2">
  214.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  215.           </div>
  216.           <div className="col-sm-2">
  217.             <CardSmall case_id="22" headline="test">General Kenobi</CardSmall>
  218.           </div>
  219.         </div>
  220.       </div>
  221.       <div>
  222.         <div className="card card-body">
  223.           <div className="row card-columns">
  224.             <div className="col-sm-6">
  225.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  226.             </div>
  227.             <div className="col-sm-6">
  228.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  229.             </div>
  230.           </div>
  231.           <div className="row card-columns">
  232.             <div className="col-sm-6">
  233.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  234.             </div>
  235.             <div className="col-sm-6">
  236.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  237.             </div>
  238.           </div>
  239.           <div className="row card-columns">
  240.             <div className="col-sm-6">
  241.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  242.             </div>
  243.             <div className="col-sm-6">
  244.               <CardBig case_id="11" headline="test" image="https://www.outbrain.com/techblog/wp-content/uploads/2017/05/road-sign-361513_960_720.jpg">Hello there. I am the the the the the the the the the the the the the the the the the the the the </CardBig>
  245.             </div>
  246.           </div>
  247.         </div>
  248.       </div>
  249.     </div>;
  250.   }
  251. }
  252.  
  253. const root = document.getElementById('root');
  254. if (root)
  255.   ReactDOM.render(
  256.       <HashRouter>
  257.         <div>
  258.           <Banner />
  259.           <Navbar />
  260.           <Route exact path="/" component={Home} />
  261.           <Route path="/case/:id" component={Case} />
  262.           <Route path="/add" component={CaseAdd} />
  263.         </div>
  264.       </HashRouter>,
  265.       root
  266.   );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement