0.1.1 • Published 8 years ago
meta-clock v0.1.1
Meta-Clock
A clock component for React.
Install
$ npm install --save meta-clockUse
import Clock from 'meta-clock';
const MyComponent = () => (
<div>
...
<Clock ... />
...
</div>
);See demo/components/styled-clock.jsx for example.
Props
Primitive props
hour:number; required; Hour of the clockminute:number; required; Minute of the clockhighlightHour:number; optional; Highlighted hour of the clockhighlightMinute:number; optional; Highlighted minute of the clockis24Hours:boolean; optional; Set totrueto render a 24-hours clocksize:number; required; The size of the clock in pixel
Function props
The following event handler functions all receive the same parameter payload:
type EventHandlerPayload = {
layer: number,
division: number,
}onClick:(payload: EventHandlerPayload) => voidonMouseOver:(payload: EventHandlerPayload) => voidonMouseEnter:(payload: EventHandlerPayload) => voidonMouseLeave:(payload: EventHandlerPayload) => void
... where layer: 0 is for hours and layer: 1 is for minutes; and division is indexed value of the slice of the clock face (i.e. {layer: 0, division: 6} is hour 6; and {layer: 1, division: 14} is minute 15).
The following render functions allows one to override certain aspect of the rendering of the clock face:
renderExtrasmarkerRadiusrenderMarkerarmLengthrenderArm
Run demo locally
$ nvm use
$ npm install
$ npm run dev... then open http://localhost:8000.