1.0.6 • Published 2 months ago

day-time-greet v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

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>
1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago