Skip to content

Commit c99f516

Browse files
committed
Added examples in docs
1 parent 164dfea commit c99f516

File tree

7 files changed

+2257
-2
lines changed

7 files changed

+2257
-2
lines changed

docs/api.mdx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: API
3+
route: /api
4+
---
5+
6+
# API
7+
8+
| Name | Type | Description |
9+
| ------------- | ------------- | ------------- |
10+
| children | object (required) | Define your react component here |
11+
| start | number (required) | A start value for the timer |
12+
| end | function (required) | A function which determines the end for the timer |
13+
| interval | number | An interval value for the timer. Default is 1 second |
14+
| onTick | function (required) | A callback function where the next computed value is determined |
15+
| onEnd | function | A callback function which executes when the timer stops executing |
16+
---

docs/index.html

-1
This file was deleted.

docs/introduction.mdx

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Introduction
3+
route: /
4+
---
5+
6+
# Introduction
7+
8+
> A minimalistic yet customizable timer component!

docs/playground.mdx

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: Playground
3+
route: /playground
4+
---
5+
6+
# Playground
7+
8+
import { Playground } from 'docz'
9+
import ReactTimer from '../src/index'
10+
11+
## Incremental timer
12+
13+
<Playground>
14+
<ReactTimer
15+
start={0}
16+
end={(value) => value === 30}
17+
onEnd={(value) => console.log('ENDED WITH VALUE', value)}
18+
onTick={(value) => value + 1}
19+
>
20+
{(time) => <div>{time}</div>}
21+
</ReactTimer>
22+
</Playground>
23+
24+
## Decremental timer
25+
26+
<Playground>
27+
<ReactTimer
28+
start={30}
29+
end={(value) => value < 25}
30+
onEnd={(value) => console.log('ENDED WITH VALUE', value)}
31+
onTick={(value) => value - 1}
32+
>
33+
{(time) => <div>{time}</div>}
34+
</ReactTimer>
35+
</Playground>
36+
37+
## Infinite timer
38+
39+
<Playground>
40+
<ReactTimer
41+
start={0}
42+
end={() => false}
43+
onEnd={(value) => console.log('ENDED WITH VALUE', value)}
44+
onTick={(value) => value + 1}
45+
>
46+
{(time) => <div>{time}</div>}
47+
</ReactTimer>
48+
</Playground>
49+
50+
## Basic Clock
51+
52+
<Playground>
53+
<ReactTimer
54+
start={0}
55+
end={() => false}
56+
onEnd={(value) => console.log('ENDED WITH VALUE', value)}
57+
onTick={(value) => value + 1}
58+
>
59+
{() => (new Date()).toString()}
60+
</ReactTimer>
61+
</Playground>

doczrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
base: '/react-timer/',
3+
title: 'React Timer',
4+
hashRouter: true,
5+
ignore: ['readme.md'],
6+
src: './docs'
7+
}

0 commit comments

Comments
 (0)