1.0.7 β€’ Published 1 year ago

@ixnode/simple-clock v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@ixnode/simple-clock

Release npm.io npm version TypeScript MIT License

A simple, customizable, and responsive clock component for React.

πŸš€ Features

  • Customizable size and color
  • Supports both digital and analog clocks
  • Displays date, time zone and milliseconds
  • Configurable 12-hour and 24-hour formats
  • Lightweight and built with TypeScript
  • Build on top with storybook

πŸ“¦ Installation

npm install @ixnode/simple-clock

or

yarn add @ixnode/simple-clock

πŸ”§ Usage

Basic Usage

Basic clock.

import React from 'react';
import { Clock } from '@ixnode/simple-clock';
import '@ixnode/simple-clock/dist/styles.css';

const App = () => (
    <Clock size="large" color="blue" showDate={true} showBorder={true} showTimeZone={true} />
);

export default App;

More complex usage

Analog clock.

import React from 'react';
import { Clock } from '@ixnode/simple-clock';
import '@ixnode/simple-clock/dist/styles.css';

const App = () => (
    <Clock color={'default'} size={'small'} isAnalog={true} timeZone={"Europe/Berlin"} locale={"de-DE"} />
);

export default App;

πŸ”§ Props

PropTypeDefaultDescription
color'default'\|'red'\|'green'\|'blue''default'Sets the color of the clock.
size'small'\|'medium'\|'large''medium'Sets the size of the clock.
showBorderbooleanfalseWhether to show a border around the clock.
use24HourFormatbooleantrueUse 24-hour format (true) or AM/PM (false).
showTenthsbooleanfalseShow tenth of a second?
isAnalogbooleanfalseShow an analog clock?
showDatebooleanfalseShow date?
showTimeZonebooleanfalseShould a timezone be displayed?
timeZoneType'short'\|'long''short'Which type of timezone should be displayed?
localestring'en-US'Which locale should be displayed?
timeZonestring'UTC'Which time zone should be displayed?

Common locales (locale)

timeZone is used with the Intl.DateTimeFormat API:

LocaleDescription
en-USEnglish (United States)
en-GBEnglish (United Kingdom)
de-DEGerman (Germany)
es-ESSpanish (Spain)
fr-FRFrench (France)
it-ITItalian (Italy)
nl-NLDutch (Netherlands)
pl-PLPolish (Poland)
pt-BRPortuguese (Brazil)
ru-RURussian (Russia)
sv-SESwedish (Sweden)
zh-CNChinese (Simplified, China)
zh-TWChinese (Traditional, Taiwan)

Common Time Zone Formats and Examples (timeZone)

timeZone is used with the Intl.DateTimeFormat API:

1. Common Time Zone Strings (IANA-TZ Format)

These strings are based on the IANA Time Zone Database, which defines time zones used worldwide:

Time ZoneDescription
UTCCoordinated Universal Time
America/New_YorkEastern Standard Time (EST)
Europe/BerlinCentral European Time (CET)
Asia/TokyoJapan Standard Time (JST)
Australia/SydneyAustralian Eastern Time (AET)
Africa/CairoEast Africa Time (EAT)
Pacific/AucklandNew Zealand Standard Time (NZST)

2. Short Time Zone Formats (Offset-based)

These formats use the offset from UTC in hours and minutes. Examples:

Time ZoneDescription
GMTGreenwich Mean Time
+02:00Two hours ahead of UTC
-05:00Five hours behind UTC

3. Abbreviated Time Zone Codes

Note: These are not supported by the Intl API and are not standardized. However, many abbreviations are commonly used in practice, such as:

AbbreviationDescription
PSTPacific Standard Time (UTC-8)
CETCentral European Time (UTC+1)
ISTIndian Standard Time (UTC+5:30)

πŸ›  Development

Building the Project

To build the project locally:

npm run build

Running Storybook

View and develop components in isolation:

npm run storybook

Open: http://localhost:6006/

Storybook

πŸ“¦ Publishing to npm

Build the project

npm run build

Verify the build

node dist/index.js

Bump the version

Update the version in the package.json, e.g., from 1.0.0 to 1.0.1, to create a new release:

npm version patch

Alternatively:

  • Use npm version minor for new features.
  • Use npm version major for breaking changes.

Publish the package

npm publish --access public

Verify the publication

Check the package on npm: https://www.npmjs.com/package/@ixnode/simple-clock.

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

Authors

🌟 Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve this project.

🀝 Acknowledgments

Special thanks to the open-source community for providing amazing tools like React, TypeScript, and Storybook.

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.0

1 year ago