This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Initial commit for react-tic-tac-toe sample #86
Open
liminzhu
wants to merge
4
commits into
microsoft:master
Choose a base branch
from
liminzhu:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# compiled and bundled source | ||
dist | ||
|
||
# Node modules | ||
node_modules | ||
|
||
# type definitions | ||
typings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# React Tic Tac Toe | ||
|
||
A game example built using [TypeScript](https://github.com/Microsoft/TypeScript) and [React](https://github.com/facebook/react), following guidelines from [react-webpack guide](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/quick-start/react-webpack.md) from TypeScript handbook. | ||
|
||
## Build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline after the header There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fbbea5d |
||
|
||
``` | ||
npm install -g typescript webpack typings | ||
npm install | ||
npm link typescript | ||
typings install | ||
webpack | ||
``` | ||
|
||
## Run | ||
|
||
Open ```index.html```. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline after the header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
html { | ||
box-sizing: border-box; | ||
} | ||
* { | ||
box-sizing: inherit; | ||
} | ||
|
||
.app { | ||
font-family: 'Open Sans', sans-serif; | ||
margin: 100px; | ||
width: 500px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
-webkit-touch-callout: none; | ||
-webkit-user-select: none; | ||
-khtml-user-select: none; | ||
-moz-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
} | ||
|
||
.board { | ||
position: relative; | ||
width: 500px; | ||
height:500px; | ||
} | ||
|
||
.cell { | ||
float: left; | ||
width: 33.3333%; | ||
height: 33.3333%; | ||
line-height: 166.67px; | ||
color: black; | ||
font-size: 90pt; | ||
text-align: center; | ||
border-color: orangered; | ||
border-width: 3px; | ||
} | ||
.cell.top { | ||
border-bottom-style:solid; | ||
} | ||
.cell.bottom { | ||
border-top-style:solid; | ||
} | ||
.cell.left { | ||
border-right-style:solid; | ||
} | ||
.cell.right { | ||
border-left-style:solid; | ||
} | ||
|
||
.X{ | ||
animation-name: appear; | ||
animation-duration: .3s; | ||
} | ||
.O{ | ||
animation-name: appear; | ||
animation-duration: .3s; | ||
animation-delay:.3s; | ||
animation-fill-mode: forwards; | ||
opacity: 0; | ||
} | ||
@keyframes appear { | ||
from { font-size: 90pt; opacity: 0;} | ||
to { font-size: 100pt; opacity: 1;} | ||
} | ||
|
||
.description{ | ||
cursor:pointer; | ||
font-size:25px; | ||
font-weight:bold; | ||
padding:15px 0px; | ||
position: relative; | ||
display: inline-block; | ||
width: 200px; | ||
text-align: center; | ||
margin-top: 30px; | ||
margin-right: -35px; | ||
} | ||
.t1{ | ||
margin-left: 60px; | ||
} | ||
.t2{ | ||
margin-right: 60px; | ||
} | ||
|
||
.gameStateBar { | ||
text-align: center; | ||
font-size: 60px; | ||
font-weight: bold; | ||
height: 60px; | ||
} | ||
|
||
.restartBtn { | ||
box-shadow: 3px 3px 9px 2px #54a3f7; | ||
background-color:#007dc1; | ||
border-radius:28px; | ||
border:1px solid #124d77; | ||
cursor:pointer; | ||
color:#ffffff; | ||
font-size:25px; | ||
font-weight:bold; | ||
padding:15px 36px; | ||
text-decoration:none; | ||
text-shadow:0px 0px 7px #154682; | ||
position: relative; | ||
display: block; | ||
margin: 40px auto; | ||
width: 160px; | ||
text-align: center; | ||
} | ||
.restartBtn:hover { | ||
background-color:#0061a7; | ||
} | ||
.restartBtn:active { | ||
position:relative; | ||
top:1px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>TicTacToe with TypeScript and React</title> | ||
<link rel="stylesheet" href="css/style.css"> | ||
<script src="./node_modules/react/dist/react.js"></script> | ||
<script src="./node_modules/react-dom/dist/react-dom.js"></script> | ||
</head> | ||
<body> | ||
<div id="content"></div> | ||
<script src="./dist/bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
TicTacToe / | ||
|---- css/ // css style sheets | ||
|---- dist/ // folder for typescript-compiled and webpack-bundled js files | ||
|---- node_modules/ // dependent node modules | ||
|---- src/ // .ts and .tsx source files | ||
|---- app.tsx // the App React component | ||
|---- board.tsx // the TicTacToe Board React component | ||
|---- constants.ts // some shared constants and types | ||
|---- gameStateBar.tsx // GameStatusBar React component | ||
|---- restartBtn.tsx // RestartBtn React component | ||
|---- typings/ // type definition .d.ts files | ||
|---- index.html // web page for our app | ||
|---- layout.html // project structure | ||
|---- package.json // node package configuration file | ||
|---- README.md // RAEDME file | ||
|---- tsconfig.json // typescript configuration file | ||
|---- typings.json // typings configuration file | ||
|---- webpack.config.js // webpack configuration file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "TicTacToe", | ||
"version": "1.0.0", | ||
"description": "Tic Tac Toe built with TypeScript and React", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Limin Zhu", | ||
"license": "ISC", | ||
"dependencies": { | ||
"react": "^0.14.7", | ||
"react-dom": "^0.14.7" | ||
}, | ||
"devDependencies": { | ||
"source-map-loader": "^0.1.5", | ||
"ts-loader": "^0.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import { Board } from "./Board"; | ||
import { RestartBtn } from "./RestartBtn"; | ||
import { GameStateBar } from "./GameStateBar"; | ||
import { GameState } from "./constants"; | ||
|
||
class App extends React.Component<void, void> { | ||
render() { | ||
return ( | ||
<div className="app"> | ||
<Board /> | ||
<div> | ||
<span className="description t1"> Player(X) </span> | ||
<span className="description t2"> Computer(O) </span> | ||
</div> | ||
<RestartBtn /> | ||
<GameStateBar /> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
<App />, document.getElementById("content") | ||
); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
typings
anddist
to the.gitignore
and remove them