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-mix function #408

Merged
merged 7 commits into from
Feb 5, 2024
Merged

Conversation

lubegasimon
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Jan 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
styled-ppx ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2024 7:57pm

@lubegasimon lubegasimon marked this pull request as draft January 22, 2024 08:32
@lubegasimon lubegasimon force-pushed the support-color-mix-function branch from 6376716 to 5f58488 Compare January 22, 2024 08:37
@lubegasimon lubegasimon force-pushed the support-color-mix-function branch from e98c793 to d7ac7ad Compare January 24, 2024 08:38
@lubegasimon lubegasimon force-pushed the support-color-mix-function branch 2 times, most recently from 13f6e19 to 5ed734d Compare January 28, 2024 12:53
@lubegasimon lubegasimon marked this pull request as ready for review January 28, 2024 12:57
@lubegasimon lubegasimon changed the title color-mix function types color-mix function Jan 28, 2024
[%expr [%css "background-color: color-mix(in srgb-linear, white, red)"]],
[%expr
CssJs.backgroundColor(
`colorMix2((
Copy link
Owner

Choose a reason for hiding this comment

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

I know I proposed colorMix2/colorMix4, but in reality what makes a bit more sense is to keep colorMix as a single arity but then the first argument of the variant is in1/in2/`in3, does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean more or less like this?

 `colorMix((
     `in1(`in_, `srgb),
       (CssJs.white, `percent(10.)),
       (CssJs.red, `percent(90.)),
 ))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if that's the case, method<> sounds better as it portrays the name of the argument

Copy link
Owner

Choose a reason for hiding this comment

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

More like:

 `colorMix((
     `in1(`srgb),
       (CssJs.white, `percent(10.)),
       (CssJs.red, `percent(90.)),
 ))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@lubegasimon lubegasimon force-pushed the support-color-mix-function branch from 26135b6 to 467f391 Compare February 5, 2024 13:30
@@ -4006,6 +4110,8 @@ let parse_declarations = (~loc: Location.t, property, value) => {
| Error(_) =>
switch (render_to_expr(~loc, property, value)) {
| Ok(value) => Ok(value)
| exception (InvalidValue(v)) =>
Error(`Invalid_value(value ++ ". " ++ v))
Copy link
Owner

Choose a reason for hiding this comment

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

Why the . is necessary?

Copy link
Owner

Choose a reason for hiding this comment

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

and I don't see the \Invalid_value` error handled anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The . separates the property value from the error message. Which is rendered like this

Error: Property 'background-color' has an invalid value: 'color-mix(srgb,
       white 0%, red 0%). Both percentages can not be 0!'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm! The error message appears inside quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're calling Invalid_value here.

Copy link
Owner

Choose a reason for hiding this comment

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

Happy to keep it as it is 👍🏼

@@ -24,6 +24,8 @@ let (let.ok) = Result.bind;
/* TODO: Add payload on those exceptions */
exception Unsupported_feature;

exception InvalidValue(string);
Copy link
Owner

Choose a reason for hiding this comment

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

Let's keep all exceptions with the same casing

s/InvalidValue/Invalid_value

" 'in' && [<rectangular-color-space> | <polar-color-space> <hue-interpolation-method>?] "
]
and function_color_mix = [%value.rec
// TODO: Use <extended-percentage>
Copy link
Owner

Choose a reason for hiding this comment

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

is this todo in the scope of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm!
Let's do it in another PR, what's your take?

@davesnx davesnx merged commit 88e63e5 into davesnx:main Feb 5, 2024
7 checks passed
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