Skip to content

Commit

Permalink
update package name
Browse files Browse the repository at this point in the history
  • Loading branch information
M A Alim committed May 25, 2023
1 parent 863bdd3 commit e7b3cbd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# react-awesome-clock
# react-simple-clock

This repository contains simple analog clock to be used in React applications. You can either use the live clock or set
your given time to see a stationary clock.
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My React Component</title>
<title>React Simple Clock</title>
</head>
<body>
<div id="root"></div>
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-awesome-clock",
"name": "react-simple-clock",
"version": "1.0.0",
"description": "A react component to display clock",
"license": "MIT",
Expand All @@ -12,12 +12,12 @@
"dist",
"README.md"
],
"main": "./dist/react-awesome-clock.umd.js",
"module": "./dist/react-awesome-clock.es.js",
"main": "./dist/react-simple-clock.umd.js",
"module": "./dist/react-simple-clock.es.js",
"exports": {
".": {
"import": "./dist/react-awesome-clock.es.js",
"require": "./dist/react-awesome-clock.umd.js"
"import": "./dist/react-simple-clock.es.js",
"require": "./dist/react-simple-clock.umd.js"
}
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Clock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const Clock = (props) => {
))}
<div className="rac-hand-wrapper" style={{ width: size, height: size/2 }}>
<div className="rac-mid-point" style={{ height: size/20, width: size/20, transform: `translateY(${size/40}px)` }}></div>
{live && <Hand height={4*size/10} handID="rac-second-hand" angle={second*6} />}
<Hand height={3*size/10} handID="rac-minute-hand" angle={minute*6+second/10} />
<Hand height={size/5} handID="rac-hour-hand" angle={hour*30+minute/2} />
{live && <Hand height={4*size/10} angle={second*6} />}
<Hand height={3*size/10} angle={minute*6+second/10} />
<Hand height={size/5} angle={hour*30+minute/2} />
</div>
</div>
)
Expand Down
19 changes: 11 additions & 8 deletions src/lib/components/Hand.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React, { useEffect } from "react"
import React, { useEffect, useRef } from "react"
import PropTypes from "prop-types"

const Hand = ({ height, width = 5, handID, angle }) => {
const Hand = ({ height, width = 5, angle }) => {
const handRef = useRef()

useEffect(() => {
(document.getElementById(handID)).style.transform = `rotate(${angle}deg)`
try {
handRef.current.style.transform = `rotate(${angle}deg)`
} catch (e) {
console.error(e)
}
}, [angle])

return (
<div style={{ height, width }} id={handID} className="rac-clock-hand">

</div>
<div ref={handRef} style={{ height, width }} className="rac-clock-hand"></div>
)
}

Hand.propTypes = {
height: PropTypes.number,
width: PropTypes.number,
angle: PropTypes.number,
handID: PropTypes.string
angle: PropTypes.number
}

export default Hand
4 changes: 2 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default defineConfig({
build: {
lib: {
entry: path.resolve(__dirname, 'src/lib/index.jsx'),
name: 'react-awesome-clock',
fileName: (format) => `react-awesome-clock.${format}.js`
name: 'react-simple-clock',
fileName: (format) => `react-simple-clock.${format}.js`
},
rollupOptions: {
external: ['react', 'react-dom'],
Expand Down

0 comments on commit e7b3cbd

Please sign in to comment.