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

Adjust ratio for opacity #222

Merged
merged 23 commits into from
Feb 11, 2025
Merged

Adjust ratio for opacity #222

merged 23 commits into from
Feb 11, 2025

Conversation

jamesnw
Copy link
Contributor

@jamesnw jamesnw commented Dec 10, 2024

Description

When foreground opacity is changed, the ratio is based on the premultiplied color.
If the background opacity is changed, the ratio is based on both colors without any opacity.

Related Issue(s)

#91

Steps to test/reproduce

https://deploy-preview-222--oddcontrast.netlify.app/

Todo

  • Design pass on message in results section

Copy link

netlify bot commented Dec 10, 2024

Deploy Preview for oddcontrast ready!

Name Link
🔨 Latest commit 15b5251
🔍 Latest deploy log https://app.netlify.com/sites/oddcontrast/deploys/67aa517f287d0f0008e9acc0
😎 Deploy Preview https://deploy-preview-222--oddcontrast.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@mirisuzanne mirisuzanne 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. Might be nice to have a checkerboard under the sample area, for when background color is not opaque?

jamesnw and others added 2 commits December 11, 2024 16:37
@jamesnw
Copy link
Contributor Author

jamesnw commented Dec 11, 2024

looks good. Might be nice to have a checkerboard under the sample area, for when background color is not opaque?

@mirisuzanne Good idea. I added one, but is there a way to have a background color on a layer above an image? It looks like a color is only valid as the last value. I ended up using a linear-gradient to create a solid color, but there has to be a better way.

@jamesnw
Copy link
Contributor Author

jamesnw commented Dec 11, 2024

@mirisuzanne or @stacyk I'm assigning to you, as I think there's potentially some style cleanup to prevent a layout jump when the warning message is shown, and also since the icon doesn't feel spaced correctly.

image

* main:
  lint
  Bump the dev-minor group across 1 directory with 15 updates
  Bump jsdom from 25.0.1 to 26.0.0 in the dev-major group
  Bump the dev-minor group with 6 updates
  upgrade node and yarn
  Bump the dev-minor group with 6 updates
  Bump the dev-minor group with 7 updates
  Bump the dev-minor group with 12 updates
let displayRatio = $derived(Math.round((ratio + Number.EPSILON) * 100) / 100);
let pass = $derived(ratio >= RATIOS.AA.Normal);
let alphaWarning = $derived.by(() => {
if ($bg.alpha !== 1)
return 'Alpha is not considered when the background is not opaque.';
Copy link
Member

Choose a reason for hiding this comment

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

Could we link these two notes directly to the fuller description (expanding if necessary)?

If not that, we could consider adding the fuller explanation in a tooltip/dialog here instead of in the expandable "issues" section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think linking will be much easier once we're done with #223. I'm fine with moving it to a tooltip/dialog, but note we'd need to develop that pattern. I'll defer to @SondraE on what we should do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, would it make more sense for me to focus on cleaning up #223 in the meantime @jamesnw? That PR just needs style cleanup, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct- that would be great!

@dvdherron
Copy link
Contributor

@mirisuzanne or @stacyk I'm assigning to you, as I think there's potentially some style cleanup to prevent a layout jump when the warning message is shown, and also since the icon doesn't feel spaced correctly.
image

I think I've fixed the layout jumping issues (in d4dccb8) and cleaned up the warning message in (bf7d3eb)

@stacyk @SondraE Thoughts on how this is looking so far? Look at the warning message at the different break points and with passing and failing ratio.

@dvdherron dvdherron assigned SondraE and dvdherron and unassigned mirisuzanne Jan 24, 2025
@dvdherron dvdherron requested a review from SondraE January 24, 2025 16:11
Copy link
Contributor

@SondraE SondraE left a comment

Choose a reason for hiding this comment

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

@dvdherron I think this is going in a good direction!
There are a few breakpoints where the message seemed disconnected from the ratio and not aligned with the other content.

Screenshot 2025-01-24 at 4 24 52 PM Screenshot 2025-01-24 at 4 25 30 PM

@dvdherron
Copy link
Contributor

@SondraE I adjusted the spacing in some of those middle widths so that the warning isn't so far from the ratio.

passing ratio with warning:
image

image

failing with warning:
image

image

with no warning:
image

image

@jamesnw
Copy link
Contributor Author

jamesnw commented Feb 4, 2025

With the color issues move merged in, I added links from the warnings to the color section.

@dvdherron The warnings will need to be styled. I assume the DOM will need to be changed somehow- feel free to do it, or let me know if you want me to.
image

Because the issues are at the bottom of the page, the header won't be scrolled to the top of the page. I added a :has(:target) selector with a fairly heavy-handed highlight, which I think could be scaled back significantly.

image

jgerigmeyer and others added 4 commits February 5, 2025 14:45
* main:
  clean up animation
  cleanup
  add outline to swap button
  animate swap button
  change sr-only text for switch button
  reduce space around switch button
  lint
  initial style cleanup for color swap button
  Better handling of dragging
  Start styling switch button
  Add button and drag to swap colors
@dvdherron
Copy link
Contributor

With the color issues move merged in, I added links from the warnings to the color section.

@dvdherron The warnings will need to be styled. I assume the DOM will need to be changed somehow- feel free to do it, or let me know if you want me to.

Fixed the warnings in cf92e08
bild

Because the issues are at the bottom of the page, the header won't be scrolled to the top of the page. I added a :has(:target) selector with a fairly heavy-handed highlight, which I think could be scaled back significantly.

Changed this to where just the heading is highlighted. Too subtle?

bild

@dvdherron
Copy link
Contributor

A gif of the layout bouncing as the ratio changes

Accidentally changed the size of the fixed width column for the ratio number. Fixed in 607ea55

@dvdherron
Copy link
Contributor

@stacyk @SondraE @mirisuzanne I think this is ready for final review.

The biggest change was stacking the ratio number on top of the eventual warning on the narrowest screens. Oherwise it felt like the warning box grew really tall:

bild

bild

And now that the color issues are linked to at the bottom of the page, the heading of the respective list item is subtly highlighted after following the "learn more" link in the warning.

Is the color and the "diamond" too sublte?

bild

Copy link
Contributor

@SondraE SondraE left a comment

Choose a reason for hiding this comment

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

This is all looking really good to me. I really like the idea of highlighting the title of the section the user is taken to after clicking Learn More. I wonder if it would feel even more related to the warning if the text color was the same pink as the warning text color and the same icon was used.

@dvdherron
Copy link
Contributor

el even more related to the warning if the text color was the same pink as the warning text color and the same icon was used.

@SondraE Fixed in e129e61

image

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

this looks great. Just left a few notes on the code.

display: inline-flex;
grid-area: number;
justify-content: flex-start;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we want to remove this, and let it stretch to fill the space?

Copy link
Contributor

Choose a reason for hiding this comment

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

removed in 1044fb1

@@ -19,6 +41,15 @@
<span class="sr-only">The contrast ratio is</span>
Copy link
Member

Choose a reason for hiding this comment

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

I know it's not new here, but I don't think this is useful screen reader context. The heading directly before this says 'current ratio' already.

Copy link
Contributor

@dvdherron dvdherron Feb 10, 2025

Choose a reason for hiding this comment

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

Agreed. Removed in 1044fb1. On the topic, I wonder if (in another story) we should edit the click-to-copy buttons to say what exactly they are copying?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't know the best solution on those - but no harm oping an issue to explore it.

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

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

looks great!

Copy link
Member

@stacyk stacyk left a comment

Choose a reason for hiding this comment

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

Looks and works great!

@stacyk stacyk merged commit b58b5cd into main Feb 11, 2025
7 checks passed
@stacyk stacyk deleted the alpha branch February 11, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants