Skip to content

Conversation

browniebroke
Copy link
Contributor

@browniebroke browniebroke commented Sep 4, 2023


name: Pull request
about: Submit a pull request for this project
assignees: fabiocaccamo


Describe your changes
Add support for RGB and RGBA formats

Related issue
#84

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

@browniebroke browniebroke marked this pull request as ready for review September 4, 2023 14:24
Copy link
Owner

@fabiocaccamo fabiocaccamo left a comment

Choose a reason for hiding this comment

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

Thank you very much for this great PR!

fabiocaccamo
fabiocaccamo previously approved these changes Sep 4, 2023
@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.88% 🎉

Comparison is base (e6c1414) 87.16% compared to head (2b5fc03) 88.05%.

❗ Current head 2b5fc03 differs from pull request most recent head 0d8e4cb. Consider uploading reports for the commit 0d8e4cb to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   87.16%   88.05%   +0.88%     
==========================================
  Files           7        7              
  Lines         148      159      +11     
==========================================
+ Hits          129      140      +11     
  Misses         19       19              
Flag Coverage Δ
unittests 88.05% <100.00%> (+0.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
colorfield/fields.py 91.89% <100.00%> (ø)
colorfield/serializers.py 93.33% <100.00%> (+2.02%) ⬆️
colorfield/validators.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@browniebroke
Copy link
Contributor Author

I think I've addressed all your suggestions, let me know if I missed anything.

@fabiocaccamo fabiocaccamo merged commit 81970c5 into fabiocaccamo:main Sep 4, 2023
@fabiocaccamo
Copy link
Owner

@browniebroke you can upgrade to 0.10.0 version, thank you again for this great PR.

@browniebroke
Copy link
Contributor Author

Thanks for the quick release after the merge, much appreciated 🙏🏻

@browniebroke browniebroke deleted the feat/rgb-formats branch September 4, 2023 22:18
@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Sep 5, 2023

I realized just now that RGB and RGBA formats raise an error when the image_field option is used:
https://github.com/fabiocaccamo/django-colorfield#image_field

This happens because the color returned by get_image_background_color (https://github.com/fabiocaccamo/django-colorfield/blob/main/colorfield/utils.py#L4) is always in HEX / HEXA format.

@browniebroke
Copy link
Contributor Author

Right... Missed that one! I'll see if I can make a quick fix, otherwise we could fallback to disable image_field for RGB/RGBA

@fabiocaccamo
Copy link
Owner

If you can't do it, I will do, no problem.

It can be fixed quickly by passing the color format to get_image_background_color method to return a color formatted in the chosen format.

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