abhijeetnishal / URLShortener

URL Shortener Deployed Link 👇🏻
https://urlsrtner.vercel.app
MIT License
37 stars 58 forks source link

Toggle Button for Light/Dark added #108

Closed Prashant-2024 closed 6 months ago

Prashant-2024 commented 6 months ago

Issue No. #54 Toggle Button added for Light and Dark mode of application.

vercel[bot] commented 6 months ago

@Prashant-2024 is attempting to deploy a commit to the Abhijeet's projects Team on Vercel.

A member of the Team first needs to authorize it.

abhijeetnishal commented 6 months ago

Hey @Prashant-2024, there are couple of issue in this PR:

  1. Component should be in TypeScript not JS and file should be in .tsx format for component.
  2. In the current project, we already using "next-themes" so we can implement Light/dark mode feature directly using this.
  3. The switch between light and dark mode is just button not a toggle one, use toggle button.
  4. The toggle button is present in Navbar not in page so that users can switch in any component
  5. The button should be visible, currently it's not visible size is small as it's not a toggle button.

Try to understand the project first before contributing so that you can easily understand.

abhijeetnishal commented 6 months ago

You can implement using next-themes like this:

"use client";
import { useTheme } from "next-themes";

export default function ThemeToggle() {
  const { systemTheme, theme, setTheme } = useTheme();
  const currentTheme = theme === "system" ? systemTheme : theme;

  const toggleTheme = () => {
    const newTheme = currentTheme === "dark" ? "light" : "dark";
    setTheme(newTheme);
  };

  return (
    <button
      onClick={toggleTheme}
      className="p-2 bg-gray-200 dark:bg-gray-800 rounded"
    >
      {theme === "light" ? "🌞" : "🌜"}
    </button>
  );
}

See this is easy to implement, that's why i am saying first understand the project. Currently we can implement using this later it can be done using state management library.

Prashant-2024 commented 6 months ago

I'm sorry for causing this inconvenience, I missed the part where I had to implement it with typescript, it's still new to me and am currently learning it. I did understood the feature and that's why asked to assign it to me. The delay was caused because I had exams in between. I will the correct the implementation ASAP, and share it with you.

abhijeetnishal commented 6 months ago

No problem @Prashant-2024, open source and gssoc is for learning.

abhijeetnishal commented 6 months ago

Hey @Prashant-2024, are you done with the changes?

Prashant-2024 commented 6 months ago

Yes, I am close to it. I will share them by today evening. I know i have taken long time and causing delay, for this changes. I am currently travelling and don't have access to laptop. I will share them ASAP

Prashant-2024 commented 6 months ago

Below are the changes:

Dark Mode:

image

Light Mode:

image

@abhijeetnishal Request to look into it and let me know