Package Exports
- day-time-greet
- day-time-greet/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (day-time-greet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Welcome to day-time-greet
A simple and easy-to-use library for greeting users with appropriate messages for 'good morning,' 'good evening,' and 'good night' based on the time of day
useTime Hook
A custom React hook to get a greeting message based on the time of day.
Installation
npm install day-time-greet
example for react.js
import React from "react";
import { useTime } from "day-time-greet";
function App() {
const { time } = useTime();
console.log(time); // Good morning, Good afternoon, or Good evening
return (
<div>
<h1>{time}</h1>
</div>
);
}
export default App;
example for vanilla js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vanilla JavaScript Example</title>
</head>
<body>
<div id="time-display"></div>
<script src="./path/to/day-time-greet.js"></script>
<script>
function updateTime() {
const { time } = useTime();
console.log(time); // Good morning, Good afternoon, or Good evening
document.getElementById("time-display").innerText = time;
}
// Call updateTime function periodically to update the time display
setInterval(updateTime, 1000);
</script>
</body>
</html>