Dun-sin / Code-Magic

Code Generator - Easily Generate CSS and Tailwind code based on your choice and input
https://code-magic.vercel.app
MIT License
380 stars 202 forks source link

[BUG] Null CSS Properties Copied When Generating Code Without Changes #486

Closed Bismay5467 closed 11 months ago

Bismay5467 commented 11 months ago

Description

Some CSS properties are copied with null values when using the "get CSS code" option under the "copy code" dropdown menu, even if no changes were made to the UI. This can clutter the user's main CSS file and cause confusion. I would suggest checking for null conditions, similar to what's done in convertInputRangeStylesToTailwind before including these properties.

For example :


      input[type='range']::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        background-color: ;
        height: ;
        width: ;
        margin-top: -3.2px;
        border-radius: ;
      }

      input[type='range']::-moz-range-thumb {
        border: none;
        background-color: ;
        height: ;
        width: ;
        border-radius: ;
      }

This is a portion of the css code generated for input range. When the background color, height, or width of the thumb remains unchanged, these properties are included in the generated code with a null value.

Additional information

To fix this Issue, don't allow the user to copy anything until the the essential fields are filled, the fields that needs a check aren't essential

πŸ₯¦ Browser

Google Chrome

πŸ‘€ Have you checked if this issue has been raised before?

🏒 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

github-actions[bot] commented 11 months ago

It's great having you contribute to this project by creating an issue

Make sure you are assigned to this before you work on it and you read the Contributing.md file, Thank you! Welcome to the community :nerd_face:

Dun-sin commented 11 months ago

a better solution is to not let the users copy a code if the necessary fields aren't filled

Bismay5467 commented 11 months ago

We might consider making certain fields optional to provide users with greater flexibility when designing a custom UI. We could then perform null checks exclusively for these optional fields to determine whether they should be included when generating the CSS code.

For instance, in the input range generator, we could designate the background color fields for the thumb and track as optional, allowing users more control over their designs.

Does this make sense?

Dun-sin commented 11 months ago

We might consider making certain fields optional to provide users with greater flexibility when designing a custom UI. We could then perform null checks exclusively for these optional fields to determine whether they should be included when generating the CSS code.

For instance, in the input range generator, we could designate the background color fields for the thumb and track as optional, allowing users more control over their designs.

Does this make sense?

No, no it doesn'tπŸ˜† anyway I won't be assigning you this. You already got one

Bismay5467 commented 11 months ago

@Dun-sin I have submitted a PR for the other issue that was assigned to me. If no more changes is required in that PR, you may assign this issue to this. I would be glad to submit a PR.

Dun-sin commented 11 months ago

@Dun-sin I have submitted a PR for the other issue that was assigned to me. If no more changes is required in that PR, you may assign this issue to this. I would be glad to submit a PR.

I don't want to you to work in this, will let someone else have itπŸ‘ŒπŸ½

Vaibhav91one commented 11 months ago

I would like to work on this issue. @Dun-sin

Dun-sin commented 11 months ago

I would like to work on this issue. @Dun-sin

Sure, thanks for wanting to contribute, make sure you follow the rules πŸ‘‰πŸ½hereπŸ‘ˆπŸ½, else your PR will not be accepted and will be closed. Good Luck.

Vaibhav91one commented 11 months ago

@Dun-sin As we discussed on discord. I have solved the issue by using default values. These default values are from the style.css file only. here is the code. Should I make a PR now?

image

Dun-sin commented 11 months ago

@Dun-sin As we discussed on discord. I have solved the issue by using default values. These default values are from the style.css file only. here is the code. Should I make a PR now?

image

i don't remember this conversation on discord, can you tag me where we talked about this?

Vaibhav91one commented 11 months ago

@Dun-sin As we discussed on discord. I have solved the issue by using default values. These default values are from the style.css file only. here is the code. Should I make a PR now? image

i don't remember this conversation on discord, can you tag me where we talked about this?

Tagged.

Vaibhav91one commented 11 months ago

Sorry, but I won't be able to work on this issue. Working on other issues. @Dun-sin

Bismay5467 commented 11 months ago

@Dun-sin If you'd like I wanna give it a shot!

Dun-sin commented 11 months ago

@Dun-sin If you'd like I wanna give it a shot!

OK, you already know the guidelines of the project, make sure to follow them

Bismay5467 commented 11 months ago

@Dun-sin I need a clarification before I can start working on this issue. If there is no value aviable for a particular field will I provide a default value as mentioned by @Vaibhav91one in one of his previous comment or will I simply not include the field if its value is null?

Dun-sin commented 11 months ago

@Dun-sin I need a clarification before I can start working on this issue. If there is no value aviable for a particular field will I provide a default value as mentioned by @Vaibhav91one in one of his previous comment or will I simply not include the field if its value is null?

don't copy anything, simply do a return and inform the user that it won't be copied like when there's no data and user is trying to open the results page (this applies to all generators that have the input and getting results in the same place except radius)

Dun-sin commented 11 months ago

:tada: This issue has been resolved in version 2.70.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: