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

Fix rendering of the Number type #256

Merged
merged 7 commits into from
Nov 15, 2023
Merged

Fix rendering of the Number type #256

merged 7 commits into from
Nov 15, 2023

Conversation

ddssff
Copy link
Contributor

@ddssff ddssff commented Nov 11, 2023

Do not use the the Show instance of Clay.Property.Number for rendering. Instead add an instance of Pretty that uses the showFixed function of the underlying Fixed value. Adds a test case to spec/Clay/MediaSpec.hs that demonstrates the resulting output of the keyframes function.

rendering.  Instead add an instance of Pretty that uses the showFixed
function of the underlying Fixed value.  Adds a test case to
spec/Clay/MediaSpec.hs that demonstrates the resulting output of the
keyframes function.
@turion
Copy link
Collaborator

turion commented Nov 11, 2023

Ah, I wasn't aware the rendering of Number is broken. Can you give an example of what went wrong?

@ddssff
Copy link
Contributor Author

ddssff commented Nov 12, 2023

Without fix:

Number {unNumber = 0.00000}% {visibility:visible;}

With fix:

0% {visibility:visible;}

It is assuming the automatically derived Show instance is a renderer, the way the show instance for Double is. In my opinion, it is better to use the Pretty printer for this.

@ddssff
Copy link
Contributor Author

ddssff commented Nov 12, 2023

But you could just replace the call to show with showFixed True . unNumber

@turion
Copy link
Collaborator

turion commented Nov 13, 2023

I think even better would be to use fromText $ cssNumberText p. I definitely wouldn't want to incur an extra dependency for this.

@ddssff
Copy link
Contributor Author

ddssff commented Nov 13, 2023

Whatever works!

@ddssff
Copy link
Contributor Author

ddssff commented Nov 13, 2023

Ok, pretty dependency removed.

Copy link
Collaborator

@turion turion left a comment

Choose a reason for hiding this comment

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

There are some warnings about redundant imports that should be fixed, otherwise looking great!

spec/Clay/MediaSpec.hs Outdated Show resolved Hide resolved
spec/Clay/MediaSpec.hs Outdated Show resolved Hide resolved
spec/Clay/MediaSpec.hs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@ddssff ddssff left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Contributor Author

@ddssff ddssff left a comment

Choose a reason for hiding this comment

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

👍 Not sure how these reviews are supposed to work.

@ddssff
Copy link
Contributor Author

ddssff commented Nov 15, 2023

Warnings fixed.

@turion turion merged commit 6994e9f into sebastiaanvisser:master Nov 15, 2023
7 checks passed
@turion
Copy link
Collaborator

turion commented Nov 15, 2023

Thanks a lot!

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