@kitsuyui/react-clock
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@kitsuyui/react-clock

npm version

Simple clock React component.

Demo

Storybook: https://react-playground.docs.kitsuyui.com/storybook/

Installation

npm

npm install @kitsuyui/react-clock

yarn

yarn add @kitsuyui/react-clock

pnpm

pnpm add @kitsuyui/react-clock

Usage

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

Readme

Keywords

none

Package Sidebar

Install

npm i @kitsuyui/react-clock

Weekly Downloads

52

Version

0.2.0

License

MIT

Unpacked Size

140 kB

Total Files

65

Last publish

Collaborators

  • kitsuyui