Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a Reset button #12

Merged

Conversation

kodbilenadam
Copy link
Contributor

Summary

The reset button allows users to reset all settings to their default values. When the button is clicked, all settings are reset to their default values.

Related to the: Introduce a Reset button

Bugs

When a user clicks the Reset button values of the settings get reset but the radio buttons are not updated. I tried some things but couldn't figure out the unspagetti way to do it.

…alues

The reset button allows users to reset all settings to their default values. When the button is clicked, all settings are reset to their default values.
@vercel
Copy link

vercel bot commented May 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
screenshot ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2023 1:20pm

Copy link
Collaborator

@iamhectorsosa iamhectorsosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @kodbilenadam ! Thanks for opening this PR. Here are a couple of things that I'd like to point out:

Reset Button

To best fit the existing UI, we have two options:

  1. We either create a small icon button and place it at the top of the settings, or
  2. We create a regular button and place it the ActionsPanel component above the other two existing buttons.

For either of these we should expand the Button primitive to add a variant that would adjust to this change. For the first option, I would either create a ghost variant for the first option and add the hover modifier later:

<Button variant="ghost" className="hover:bg-red-800/90" onClick={()=>resetSettings()} />

For the second option, I would create a destructive variant and add it in the Actions Panel, as an actions button:

<ActtionButton variant="destructive" onClick={()=>resetSettings()} />

Here are some guidelines for styling the button with TailwindCSS: https://play.tailwindcss.com/Rxj6yclXQS

If you do not feel comfortable using this framework and variant props, I can help you out.

Reset Settings

You are passing arbitrary values in this function, in config/defaults you can find the default values that are used by the state reducer. I would add these ones instead. It will be easier to maintain and understand what happens when clicking this button.

The huge huge thing to figure out in this PR is the onload value for: insetColor and isDark value because these are dynamically generated depending on the image.

This is important because when we click on the button, I would expect to get what I started with and these values are calculated in utils/color and applied in the callback in ClipboardImage component.

Maybe we can store them in a ref and use them when the reset button is applied? Wdyt? I'm open for ideas here. If this results challenging we can take it in a separate issue and address here only the UI and using the default default values as declared in config/defaults.

@iamhectorsosa
Copy link
Collaborator

RE: Icons

We are using Lucide for this project. Here's the Reset Icon reference in the Tailwind Play -> https://lucide.dev/icon/rotate-ccw

@kodbilenadam
Copy link
Contributor Author

Hey! Thank you for checking out PR! Here are my ideas on the things you mentioned:

If you do not feel comfortable using this framework and variant props, I can help you out.

I am using shacdn/ui in my projects too but I would gladly accept and help with tailwind and UI. I have added the default button to start on this issue and get feedback overtime. For button choice the first option a small button looks better with next to Settings text.

Reset Settings

You are passing arbitrary values in this function, in config/defaults you can find the default values that are used by the state reducer. I would add these ones instead. It will be easier to maintain and understand what happens when clicking this button.

I will make the necessary changes and update the code. I agree with you on this one.

The huge huge thing to figure out in this PR is the onload value for: insetColor and isDark value because these are dynamically generated depending on the image.

This is important because when we click on the button, I would expect to get what I started with and these values are calculated in utils/color and applied in the callback in ClipboardImage component.

Maybe we can store them in a ref and use them when the reset button is applied? Wdyt? I'm open for ideas here. If this results challenging we can take it in a separate issue and address here only the UI and using the default default values as declared in config/defaults.

Storing in ref and using them as a default value for reset button instead getting from config/defaults is a nice idea. But also we could only reset the values except insetDolor and isDark. This would be the painless way to implement but since there is an issue for implementing last 10 images from clipboard #13 we gonna end up storing those values somewhere.

I think creating another issue for storing those values will be much cleaner process. Let me change the default values and adding reset button with Settings text. Let's check deployed product and if we satisfy with result merge it to main close this issue and start implementing the storing values.

Let me know your thoughts. @ekqt

@kodbilenadam
Copy link
Contributor Author

RE: Resetting Radio Button does not make in unchecked.

If user clicks Reset button if the Radio button is checked on Auto . It resets the setAspectRatio value back to 16:9 but the Auto radio button is stays checked. Couldn't find a way to implement this one properly. What are your thoughts on this one?

@iamhectorsosa
Copy link
Collaborator

iamhectorsosa commented May 17, 2023

@kodbilenadam I think creating another issue for storing those values will be much cleaner process.

Agreed

@iamhectorsosa
Copy link
Collaborator

@kodbilenadam RE: Resetting Radio Button does not make in unchecked.

Not sure about that one from the top of my head but sounds like I must've left this as a uncontrolled input. Maybe ditching defaultValue for value instead and grabbing this from the settings.aspectRatio?

…ttings object

The handleReset function has been refactored to use the defaultSettings object instead of hardcoding the default values. This improves maintainability and reduces the risk of errors when changing the default values. The value of the aspectRatio radio group is now set to the value of the settings.aspectRatio state variable to ensure that the correct value is selected when resetting the settings.
The default value of insetPadding has been changed from 0 to 1 to provide a better visual experience. The previous value of 0 caused the image to be too close to the border, which made it difficult to see. The new value of 1 provides a small amount of padding, which makes the image more visible and easier to work with.
This commit reorders the imports to follow the convention of having external libraries first, then internal modules. It also adds a new ghost variant to the buttonVariants constant.
…n icon

The Settings UI layout has been improved by adding a title and a reset button icon. The title is now centered and the reset button is now an icon instead of text. This improves the overall look and feel of the Settings component.
@kodbilenadam
Copy link
Contributor Author

I think with this commit we are ready to go live. What do you think? @ekqt

Copy link
Collaborator

@iamhectorsosa iamhectorsosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost, almost there! Great work, @kodbilenadam

src/components/ui/Button.tsx Outdated Show resolved Hide resolved
src/config/defaults.ts Outdated Show resolved Hide resolved
src/components/Settings.tsx Outdated Show resolved Hide resolved
src/components/Settings.tsx Outdated Show resolved Hide resolved
The default value of insetPadding has been changed from 1 to 0 to remove the unnecessary padding around the image.
The ghost button style has been updated to have a slate background color and white text color. The hover effect has also been updated to have a red background color with 90% opacity. This change improves the visibility of the ghost button and makes it more consistent with the design system.
The insetPadding value was not being reset to the default value when the reset button was clicked. This fix sets the default value to 2, which is the desired value.
The hover effect and margin on the reset button were removed to simplify the button's appearance and make it consistent with the other buttons in the component.
Copy link
Collaborator

@iamhectorsosa iamhectorsosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@iamhectorsosa iamhectorsosa merged commit c960bb6 into webscopeio:main May 17, 2023
@kodbilenadam
Copy link
Contributor Author

Looks great!

This was fun! Thank you for the constructive feedbacks. 😄

@kodbilenadam kodbilenadam deleted the add-reset-button-to-settings branch May 17, 2023 13:39
@kodbilenadam kodbilenadam restored the add-reset-button-to-settings branch May 17, 2023 13:39
@iamhectorsosa
Copy link
Collaborator

@kodbilenadam great work! I'm planning on getting us a domain so we can make this project look a bit more official. Loving the ideas and the collaboration! Huge thanks! Make sure to recommend folks this web app whenever you see unframed screenshots haha Getting stars on GH will help us get traction. 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants