mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2026-02-07 08:34:07 +00:00
Add ReactSpa template
This commit is contained in:
11
templates/ReactSpa/ClientApp/components/About.tsx
Normal file
11
templates/ReactSpa/ClientApp/components/About.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export class About extends React.Component<void, void> {
|
||||
public render() {
|
||||
return <div>
|
||||
<h2>About</h2>
|
||||
|
||||
<p>Use this area to provide additional information.</p>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
30
templates/ReactSpa/ClientApp/components/Counter.tsx
Normal file
30
templates/ReactSpa/ClientApp/components/Counter.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as React from 'react';
|
||||
|
||||
interface CounterState {
|
||||
currentCount: number;
|
||||
}
|
||||
|
||||
export class Counter extends React.Component<void, CounterState> {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = { currentCount: 0 };
|
||||
}
|
||||
|
||||
public render() {
|
||||
return <div>
|
||||
<h2>Counter</h2>
|
||||
|
||||
<p>This is a simple example of a React component.</p>
|
||||
|
||||
<p>Current count: <strong>{ this.state.currentCount }</strong></p>
|
||||
|
||||
<button onClick={ () => { this.incrementCounter() } }>Increment</button>
|
||||
</div>;
|
||||
}
|
||||
|
||||
incrementCounter() {
|
||||
this.setState({
|
||||
currentCount: this.state.currentCount + 1
|
||||
});
|
||||
}
|
||||
}
|
||||
53
templates/ReactSpa/ClientApp/components/Home.tsx
Normal file
53
templates/ReactSpa/ClientApp/components/Home.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import * as React from 'react';
|
||||
import { carouselItems } from '../data/CarouselItems';
|
||||
import { linkLists } from '../data/HomepageLinkLists';
|
||||
|
||||
export class Home extends React.Component<void, void> {
|
||||
public render() {
|
||||
return <div>
|
||||
{ /* Carousel */ }
|
||||
<div id="myCarousel" className="carousel slide" data-ride="carousel" data-interval="6000">
|
||||
<ol className="carousel-indicators">
|
||||
{ carouselItems.map((item, index) =>
|
||||
<li key={ index } data-target="#myCarousel" data-slide-to={ index } className={ index == 0 ? "active" : "" }></li>
|
||||
)}
|
||||
</ol>
|
||||
<div className="carousel-inner" role="listbox">
|
||||
{ carouselItems.map((item, index) =>
|
||||
<div key={ index } className={ "item " + (index == 0 ? "active" : "") }>
|
||||
<img src={ item.imageUrl } alt={ item.imageAlt } className="img-responsive" />
|
||||
<div className="carousel-caption">
|
||||
<p>
|
||||
{ item.text }
|
||||
<a className="btn btn-default" href={ item.learnMoreUrl }>Learn More</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<a className="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
|
||||
<span className="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
||||
<span className="sr-only">Previous</span>
|
||||
</a>
|
||||
<a className="right carousel-control" href="#myCarousel" role="button" data-slide="next">
|
||||
<span className="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
||||
<span className="sr-only">Next</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{ /* Lists of links */ }
|
||||
<div className="row">
|
||||
{ linkLists.map((list, listIndex) =>
|
||||
<div key={listIndex} className="col-md-3">
|
||||
<h2>{ list.title }</h2>
|
||||
<ul>
|
||||
{ list.entries.map((entry, entryIndex) =>
|
||||
<li key={ entryIndex }>{ entry }</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
26
templates/ReactSpa/ClientApp/components/NavMenu.tsx
Normal file
26
templates/ReactSpa/ClientApp/components/NavMenu.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as React from 'react';
|
||||
import { Link } from 'react-router';
|
||||
export class NavMenu extends React.Component<void, void> {
|
||||
public render() {
|
||||
return <div className="navbar navbar-inverse navbar-fixed-top">
|
||||
<div className="container">
|
||||
<div className="navbar-header">
|
||||
<button type="button" className="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span className="sr-only">Toggle navigation</span>
|
||||
<span className="icon-bar"></span>
|
||||
<span className="icon-bar"></span>
|
||||
<span className="icon-bar"></span>
|
||||
</button>
|
||||
<Link className="navbar-brand" to={ '/' }>WebApplicationBasic</Link>
|
||||
</div>
|
||||
<div className="navbar-collapse collapse">
|
||||
<ul className="nav navbar-nav">
|
||||
<li><Link to={ '/' }>Home</Link></li>
|
||||
<li><Link to={ '/about' }>About</Link></li>
|
||||
<li><Link to={ '/counter' }>Counter</Link></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user