Skip to content

Instantly share code, notes, and snippets.

View allindeveloper's full-sized avatar
🏠
Working from home

Uchendu Precious allindeveloper

🏠
Working from home
View GitHub Profile
{
"name": "open-json-api",
"version": "1.0.0",
"description": "A Life Rest Api using Json-Server, and Hosted on Heroku",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"json-server": "^0.8.21",
import Timer from "./components/Timer";
import './App.css';
export {
Timer
};
import React from "react";
import Clock from './Clock';
import Input from './Input';
import Button from './Button';
class Timer extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0,
running: false,
import React from 'react';
class Input extends React.Component {
onSubmit(event) {
event.preventDefault();
const strSeconds = this.refs.seconds.value;
if(strSeconds.match(/[0-9]/)) {
this.refs.seconds.value = '';
this.props.onSetCountdown(parseInt(strSeconds, 10));
}
@import url('https://fonts.googleapis.com/css?family=Ubuntu:400,700');
* {
box-sizing: border-box;
}
body {
margin: 0;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#211a4c', endColorstr='#8200ff',GradientType=1 );
height: 100vh;
import React from 'react';
class Clock extends React.Component {
format(time) {
let seconds = time % 60;
let minutes = Math.floor(time / 60);
minutes = minutes.toString().length === 1 ? "0" + minutes : minutes;
seconds = seconds.toString().length === 1 ? "0" + seconds : seconds;
return minutes + ':' + seconds;
}
import React from 'react';
class Button extends React.Component {
render() {
return (
<button onClick={this.props.onClickHandler}>{this.props.label}</button>
);
}
}
export default Button;
import React from "react";
import {Timer} from "../lib";
class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<Timer
import React from "react";
import ReactDOM from "react-dom";
import App from "./examples/App";
ReactDOM.render(<App />, document.getElementById("root"));