@kitsuyui/react-clock
v0.2.0
Published
A react component to display a clock.
Readme
@kitsuyui/react-clock
Simple clock React component.
Demo
Storybook: https://react-playground.docs.kitsuyui.com/storybook/
Installation
npm
npm install @kitsuyui/react-clockyarn
yarn add @kitsuyui/react-clockpnpm
pnpm add @kitsuyui/react-clockUsage
import {
ClockContextProvider,
DateContext,
AnalogClock,
DigitalClock,
} from '@kitsuyui/react-clock'
const Clock = () => {
return (
<ClockContextProvider>
<DateContext.Consumer>
{(date: Date) => (
<>
<AnalogClock timezone="Asia/Tokyo" date={date} />
<DigitalClock timezone="America/New_York" date={date} />
</>
)}
</DateContext.Consumer>
</ClockContextProvider>
)
}ClockContainer is a component that provides DateContext. Clocks are pure components that do not depend on DateContext directly. Just pass the date and timezone as props. So you can define your own Timer component by same interface.
License
MIT
