Skip to content

Commit

Permalink
add more css and use pure css loader
Browse files Browse the repository at this point in the history
  • Loading branch information
wylie39 committed Mar 6, 2021
1 parent 44d04e8 commit 7071275
Show file tree
Hide file tree
Showing 8 changed files with 15,524 additions and 14,074 deletions.
29,510 changes: 15,457 additions & 14,053 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
"dependencies": {
"@teachablemachine/image": "^0.8.4",
"@tensorflow/tfjs": "^3.2.0",
"blueimp-load-image": "^5.14.0",
"bootstrap": "^4.6.0",
"react": "16.13.1",
"react-bootstrap": "^1.5.1",
"react-dom": "16.13.1",
"react-epic-spinners": "^0.5.0",
"react-images-upload": "^1.2.8",
"react-scripts": "3.4.3"
},
"devDependencies": {
Expand Down
30 changes: 28 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ body {
.loading {
margin: 0;
position: absolute;
top: 25%;
top: 30%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
left: 35%;
left: 40%;
}
.loading-msg {
width: 20rem;
Expand All @@ -31,3 +31,29 @@ body {
left: 15%;
top: 40%;
}

/*pure css loader*/
.lds-dual-ring {
display: inline-block;
width: 80px;
height: 80px;
}
.lds-dual-ring:after {
content: ' ';
display: block;
width: 64px;
height: 64px;
margin: 8px;
border-radius: 50%;
border: 6px solid #ff3864;
border-color: #ff3864 transparent #ff3864 transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
20 changes: 9 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import React from 'react'
import './App.css'
import Upload from './components/upload'
import { messages } from './components/message'
import { SelfBuildingSquareSpinner } from 'react-epic-spinners'
import Results from './components/results'
import ClientTopNav from './components/ClientTopNav'
import { predict } from './helpers/helpers'

var loadImage = require('blueimp-load-image')

export default class App extends React.Component {
state = {
results: [],
loc: 'home',
}

handleFiles = (e) => {
this.setState({ results: [] })
handleFiles = async (file, url) => {
this.setState({ loc: 'results' })
loadImage(e.target.files[0], async (img) => {
this.setState({ results: await predict(img) })
const img = new Image()
img.src = url
this.setState({
results: await predict(img),
imgurl: url[0],
})
}

handleback = () => {
this.setState({ results: [], loc: 'home' })
}
Expand All @@ -42,6 +42,7 @@ export default class App extends React.Component {
<Results
handleback={this.handleback}
results={this.state.results}
img={this.state.imgurl}
/>
</div>
)
Expand All @@ -51,10 +52,7 @@ export default class App extends React.Component {
<div>
<ClientTopNav />
<div className="loading">
<SelfBuildingSquareSpinner
color="#EE964B"
size="140"
/>
<div class="lds-dual-ring"></div>
</div>
<h3 className="loading-msg">{messages[random]}</h3>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/ClientTopNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class ClientTopNav extends React.Component {
</a>
<h3 className="name">Not A Dog</h3>
</div>
{}
</nav>
)
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/results.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.btn-back {
margin-left: 2rem;
margin-top: 5rem;
background-color: #e07a5f;
}

.btn-back:hover {
background-color: #392f5a;
}
15 changes: 14 additions & 1 deletion src/components/results.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import Button from 'react-bootstrap/Button'
import './results.css'

export default class Results extends React.Component {
render() {
Expand All @@ -15,8 +16,20 @@ export default class Results extends React.Component {
})
return (
<div>
<div>
<img
src={this.props.img}
alt="test"
width="200"
height="300"
/>
</div>
<h2>{JSON.stringify(obj.className).replace(/['"]+/g, '')}</h2>
<Button variant="primary" onClick={this.props.handleback}>
<Button
variant="primary"
onClick={this.props.handleback}
className="btn-back"
>
Back
</Button>
</div>
Expand Down
10 changes: 6 additions & 4 deletions src/components/upload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from 'react'
import './upload.css'
import ImageUploader from 'react-images-upload'

export default class Upload extends React.Component {
render() {
return (
<div className="btn-upload">
<input
type="file"
className="upload"
accept="image/*"
<ImageUploader
withIcon={true}
buttonText="Choose image"
onChange={this.props.handleFiles}
imgExtension={['.jpg', '.png', '.jpeg']}
maxFileSize={5242880}
/>
</div>
)
Expand Down

0 comments on commit 7071275

Please sign in to comment.