Skip to content

New page: color modules example #125

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

Merged
merged 13 commits into from
Mar 18, 2023
Merged

New page: color modules example #125

merged 13 commits into from
Mar 18, 2023

Conversation

estelle
Copy link
Member

@estelle estelle commented Mar 15, 2023

Example for new CSS color module page.

@estelle estelle requested a review from teoli2003 March 15, 2023 16:14
Copy link
Contributor

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

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

Made a first pass. We also need to run Prettify on this file; I'll do a last pass afterward (it is difficult to read like this).

Unless you know why, you should always use === instead of == and textContent instead of innerHTML if there is no HTML involve.

@estelle estelle requested a review from teoli2003 March 15, 2023 21:09
@estelle
Copy link
Member Author

estelle commented Mar 15, 2023

I added opacity * 1 to force it to a number so I could do opacity === 1. HTML form controls return strings, hence the == 1

@estelle
Copy link
Member Author

estelle commented Mar 16, 2023

@teoli2003 We went with

function hexOpacity(color, opacity)  {
  let char = "00";
  if (opacity > 0) {
    char = Math.floor(opacity * 255).toString(16);
  }
  return `${color}${char}`;
}

Is it also ok to go with the following way of declaring a function (the first line), or against our best practices guidelines?

const hexOpacity = (color, opacity) => {
  let char = "00";
  if (opacity > 0) {
    char = Math.floor(opacity * 255).toString(16);
  }
  return `${color}${char}`;
}

=== and () around tertiaries
Copy link
Contributor

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

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

There are a few last small changes, but I find this much easier to read already!

@teoli2003
Copy link
Contributor

@teoli2003 We went with

function hexOpacity(color, opacity)  {
  let char = "00";
  if (opacity > 0) {
    char = Math.floor(opacity * 255).toString(16);
  }
  return `${color}${char}`;
}

Is it also ok to go with the following way of declaring a function (the first line), or against our best practices guidelines?

const hexOpacity = (color, opacity) => {
  let char = "00";
  if (opacity > 0) {
    char = Math.floor(opacity * 255).toString(16);
  }
  return `${color}${char}`;
}

When possible, I prefer to have a function definition. I don't see what the longest syntax brings to readability.

(I'm not a fan of setting the else value before the if, but that's not against our rules and a matter of taste)

estelle and others added 2 commits March 17, 2023 12:12
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
@estelle estelle requested a review from teoli2003 March 17, 2023 19:13
Copy link
Contributor

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

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

👍

@teoli2003 teoli2003 merged commit 67ba416 into mdn:main Mar 18, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants