Dun-sin / Code-Magic

Code Generator - Easily Generate CSS and Tailwind code based on your choice and input

Home Page:https://code-magic.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Bismay5467 opened this issue Β· comments

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?

  • I checked and didn't find a similar issue

🏒 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

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 πŸ€“

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

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?

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

@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 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πŸ‘ŒπŸ½

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

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.

@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 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?

@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.

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

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

@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

@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 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)

πŸŽ‰ This issue has been resolved in version 2.70.1 πŸŽ‰

The release is available on GitHub release

Your semantic-release bot πŸ“¦πŸš€