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

% unit is missing #553

Open
kof opened this issue Feb 9, 2022 · 4 comments
Open

% unit is missing #553

kof opened this issue Feb 9, 2022 · 4 comments
Assignees
Labels
idle Issues and pull requests with no activity for three months.

Comments

@kof
Copy link

kof commented Feb 9, 2022

I am a bit surprised % is not in the units json, maybe I am not aware of some differentiation? Feel free to close if that's the case

@teoli2003 teoli2003 self-assigned this Feb 9, 2022
@teoli2003
Copy link
Contributor

We can add it, but which categories should we put it in?

"%": {
  "groups": [
    "CSS Units",
    "CSS Lengths"
  ],
  "status": "standard"
}

Any more?

@lahmatiy
Copy link
Contributor

A percent sign (%) is not a unit since doesn't represent a quantity itself but always relative to another quantity. Also a number with a unit produces a <dimension>, at the same time % produces its own type – <percentage>. And a "unit" should be an identifier, but % is not an identifier.
See dimension and percentage definitions for more details.

Btw, percentage is not limited to a length but can be used for any quantity, the spec defines the following productions:

  • <length-percentage>
  • <frequency-percentage>
  • <angle-percentage>
  • <time-percentage>

And in syntaxes.json you also can find <number-percentage>.

@kof
Copy link
Author

kof commented Feb 13, 2022

This is getting even more confusing since houdini api calls it a percent and calls it a unit value

CSSStyleValue.parse('width', '10%') // CSSUnitValue {value: 10, unit: 'percent'}

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Jan 4, 2023
@tabatkins
Copy link

We don't call a % a "unit" largely for historical reasons, but it effectively is. The Typed OM API does call it one for simplicity; otherwise I'd need to invent a new class for it that is otherwise exactly identical to the one for unit values. Note that Typed OM also calls "number" a unit, for the same reason, even tho plain numbers are definitely distinct from unit values.

All of this is to say, whether you categorize % as a "unit" or not is largely a matter of what makes the must sense for your particular case. That's no hard and fast answer.

@github-actions github-actions bot removed the idle Issues and pull requests with no activity for three months. label Jan 5, 2023
@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle Issues and pull requests with no activity for three months.
Projects
None yet
Development

No branches or pull requests

4 participants