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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Adjust ratio for opacity #222

wants to merge 5 commits into from

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 bdf6fc1
🔍 Latest deploy log https://app.netlify.com/sites/oddcontrast/deploys/67895b847358230008dd1798
😎 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?

src/lib/components/ratio/index.svelte Outdated Show resolved Hide resolved
@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
if ($bg.alpha !== 1)
return 'Alpha is not considered when the background is not opaque.';
if ($fg.alpha !== 1)
return 'This ratio is our best estimate with transparency.';
Copy link
Member

Choose a reason for hiding this comment

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

"with transparency" seems a bit vague to me if users haven't read the full description. Maybe "given the specified foreground alpha value" or something?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants