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

Color field migration from RGBA #6784

Open
mynameisfreedom opened this issue Nov 9, 2024 · 6 comments
Open

Color field migration from RGBA #6784

mynameisfreedom opened this issue Nov 9, 2024 · 6 comments
Labels
needs: information ❓ Requires more information to proceed needs: replication 🔬 Requires a sample to reproduce the issue

Comments

@mynameisfreedom
Copy link

Hi team, as always your new features are great, and it is fantastic that the Color field is in the core.

Description

But I have one issue with migration from hananils/kirby-colors plugin to the new Color field. Migration to the Color field is smooth except for one thing: hananils/kirby-colors plugin used rgba color when alpha is set to true. So, at the moment it is not possible to migrate those to the Kirby Color field.

hananils/kirby-colors saved alpha: true fields in this format rgba(0,0,0,0.3) so when I migrate to new Color field there is an error for every field that used opacity. And because every Layout Builder section in my Layout Builder has a color opacity overlay option for the section background image, that field is used a lot. 🫣

Expected behavior

If you could either:

  • add a script to change rgba inputs into new rgb format (example: rgba(0,0,0,0.3) into rgb(0 0 0 /0.3)) on save
  • or add support for legacy rgba colors

hananils/kirby-colors still work, but I doubt that will be the case for too much longer.

Maybe this is a small thing, but it would help hundreds of websites migrate smoothly to the new Color field.

Thank you in advance. 🙏

@distantnative
Copy link
Member

I thought this would already work. Have you the alpha: true option set? https://getkirby.com/docs/reference/panel/fields/color#alpha

@mynameisfreedom
Copy link
Author

mynameisfreedom commented Nov 9, 2024

Yes, I have alpha: true option set but it still gives me an error during saving in the panel.

Maybe your script don't support rgba(0,0,0,0.3) but support rgba(0, 0, 0, 0.3). I will see to test this.

@mynameisfreedom
Copy link
Author

Hmm, now in my test everything went smoothly... It migrated the color properly. And a few hours ago it gave me an error on every try.

You can feely close this, I will go for further migration.

@mynameisfreedom
Copy link
Author

mynameisfreedom commented Nov 9, 2024

Ah, on further migration I do get an error. Please leave this open, I need to explore more on why this is happening

Screenshot 11-09-2024 15 03 42

@distantnative distantnative added the needs: information ❓ Requires more information to proceed label Nov 9, 2024
@mynameisfreedom
Copy link
Author

mynameisfreedom commented Nov 18, 2024

Sorry for the delay. I think I found what is making an error.

The new Kirby color field only supports one format at a time (hex or RGB or HSL), but old Kirby colors plugin supported all formats at once.

screenshot-localhost-2024 11 18-20_15_12

For the same field in the Layout section on one page admins often used hex colors if the color is not transparent and RGB if the color is transparent. In that case, Kirby's color field drops an error for a color format it doesn't support. So, to make the migration, the admin would need to go from field to field and manually change color to get the supported format.

I reverted to the old Kirby colors plugin fields all fields with alpha: true, for the time being.

Could you do something about this?
Can you make a new Kirby Color field, for example: although it has format: hex and the old field value is RGB, don't report error, but convert the RGB value to hex? Or just don't throw an error?

@distantnative
Copy link
Member

@mynameisfreedom I can't reproduce this still:

In the blueprint I have

hexFormat:
  type: color
  format: hex
  alpha: true

In the content file:

HexFormat: rgba(230, 70, 30, 0.7)

Panel loads like this:
Screenshot 2024-12-07 at 19 30 36
(working with the RGBA value even though the storing format is set to HEX)

If I focus the input now and click outside again, it'll convert it to the equivalent HEX code:
Screenshot 2024-12-07 at 19 31 23

@distantnative distantnative added the needs: replication 🔬 Requires a sample to reproduce the issue label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: information ❓ Requires more information to proceed needs: replication 🔬 Requires a sample to reproduce the issue
Projects
None yet
Development

No branches or pull requests

2 participants