Initial commit.
This commit is contained in:
commit
bf8a79e467
13 changed files with 5884 additions and 0 deletions
10
src/client/components/About/About.css
Normal file
10
src/client/components/About/About.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
.text {
|
||||
color: brown;
|
||||
font-size: 25pt;
|
||||
}
|
||||
.count {
|
||||
color: blue;
|
||||
}
|
||||
.button {
|
||||
color: red;
|
||||
}
|
19
src/client/components/About/About.test.tsx
Normal file
19
src/client/components/About/About.test.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import "jsdom-global/register";
|
||||
import { configure, mount, render, shallow } from "enzyme";
|
||||
import InfernoEnzymeAdapter = require("enzyme-adapter-inferno");
|
||||
import { should } from "fuse-test-runner";
|
||||
import { Component } from "inferno";
|
||||
import { renderToSnapshot } from "inferno-test-utils";
|
||||
import About from "./About";
|
||||
configure({ adapter: new InfernoEnzymeAdapter() });
|
||||
|
||||
export class AboutTest {
|
||||
public "Should be okay"() {
|
||||
const wrapper = mount(<About />);
|
||||
wrapper.find(".button").simulate("click");
|
||||
const countText = wrapper.find(".count").text();
|
||||
should(countText)
|
||||
.beString()
|
||||
.equal("1");
|
||||
}
|
||||
}
|
32
src/client/components/About/About.tsx
Normal file
32
src/client/components/About/About.tsx
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { Component } from "inferno";
|
||||
import "./About.css";
|
||||
interface IState {
|
||||
clickCount: number;
|
||||
}
|
||||
interface IProps {}
|
||||
export default class About extends Component<IProps, IState> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
clickCount: 0
|
||||
};
|
||||
this.increment = this.increment.bind(this);
|
||||
}
|
||||
protected increment() {
|
||||
this.setState({
|
||||
clickCount: this.state.clickCount + 1
|
||||
});
|
||||
}
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
Simple Inferno SSR template
|
||||
<p className="text">Hello, world!</p>
|
||||
<button onClick={this.increment} className="button">
|
||||
Increment
|
||||
</button>
|
||||
<p className="count">{this.state.clickCount}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
36
src/client/components/App/App.tsx
Normal file
36
src/client/components/App/App.tsx
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { Component, render } from "inferno";
|
||||
import { Link, Route, StaticRouter, Switch } from "inferno-router";
|
||||
import About from "../About/About";
|
||||
import Home from "../Home/Home";
|
||||
interface IState {}
|
||||
interface IProps {name: string}
|
||||
export default class App extends Component<IProps, IState> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<h3>{this.props.name}</h3>
|
||||
<div>
|
||||
<Link to="/Home">
|
||||
<p>Home</p>
|
||||
</Link>
|
||||
</div>
|
||||
<div>
|
||||
<Link to="/About" className="link">
|
||||
<p>About</p>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Switch>
|
||||
<Route exact path="/Home" component={Home} />
|
||||
<Route exact path="/About" component={About} />
|
||||
</Switch>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
22
src/client/components/Home/Home.tsx
Normal file
22
src/client/components/Home/Home.tsx
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { Component } from "inferno";
|
||||
interface IState {}
|
||||
interface IProps {}
|
||||
export default class Home extends Component<IProps, IState> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
protected click() {
|
||||
/**
|
||||
* Try to debug next line
|
||||
*/
|
||||
console.log("hi");
|
||||
}
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
Home page
|
||||
<button onClick={this.click}>Click me</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
21
src/client/index.tsx
Normal file
21
src/client/index.tsx
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { Component } from "inferno";
|
||||
import { hydrate } from 'inferno-hydrate';
|
||||
import { BrowserRouter } from "inferno-router";
|
||||
import App from "./components/App/App";
|
||||
import { initDevTools } from "inferno-devtools";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
isoData: {
|
||||
name: string,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const wrapper = (
|
||||
<BrowserRouter>
|
||||
<App name={window.isoData.name}/>
|
||||
</BrowserRouter>
|
||||
);
|
||||
initDevTools();
|
||||
hydrate(wrapper, document.getElementById("root"));
|
Loading…
Add table
Add a link
Reference in a new issue