day-time-greet
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

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>

Package Sidebar

Install

npm i day-time-greet

Weekly Downloads

2

Version

1.0.6

License

ISC

Unpacked Size

4.57 kB

Total Files

10

Last publish

Collaborators

  • naymur_dev