content icon indicating copy to clipboard operation
content copied to clipboard

[CSS] Implement trigonometric functions and constants

Open Rumyra opened this issue 3 years ago • 20 comments

Acceptance Criteria

  • [x] The listed features are documented sufficiently on MDN
  • [ ] BCD is updated
  • [ ] Interactive example and data repos are updated if appropriate
  • [ ] The content has been reviewed as needed

For folks helping with Firefox related documentation

  • [ ] Set bugs to dev-doc-complete
  • [ ] Add entry to Firefox release notes if feature is enabled in release or
  • [x] Add entry to Firefox experimental features page if feature is not yet enabled in release

Features to document

Implement trigonometric functions and constants https://drafts.csswg.org/css-values-4/#trig-funcs

Related Gecko bugs

https://bugzilla.mozilla.org/show_bug.cgi?id=1774589

Issues and PRs

  • [ ] Compat data: https://github.com/mdn/browser-compat-data/pull/17505
  • [x] MDN/content
  • [x] Exp. feat. table: https://github.com/mdn/content/pull/20654

Rumyra avatar Aug 22 '22 10:08 Rumyra

The functions to be added to mdn/content:

  • [x] sin(), cos() (already existed when starting task)
  • [x] tan() done in https://github.com/mdn/content/pull/19145#event-7327861514
  • [ ] asin() acos() atan() atan2()

see Ramiy's comment below for the status of PRs

bsmth avatar Sep 06 '22 08:09 bsmth

Hi, I've already started documenting all the trig functions.

mdn/content:

  • CSS sin() - https://github.com/mdn/content/pull/19016
  • CSS cos() - https://github.com/mdn/content/pull/19119
  • CSS tan() - https://github.com/mdn/content/pull/19145
  • CSS asin() - https://github.com/mdn/content/pull/20383
  • CSS acos() - https://github.com/mdn/content/pull/20420
  • CSS atan() - https://github.com/mdn/content/pull/20492
  • CSS atan2() - https://github.com/mdn/content/pull/20592

mdn/browser-compat-data:

  • CSS sin() - https://github.com/mdn/browser-compat-data/pull/17170
  • CSS cos() - https://github.com/mdn/browser-compat-data/pull/17205
  • CSS tan() - https://github.com/mdn/browser-compat-data/pull/17206
  • CSS asin() - https://github.com/mdn/browser-compat-data/pull/17207
  • CSS acos() - https://github.com/mdn/browser-compat-data/pull/17218
  • CSS atan() - https://github.com/mdn/browser-compat-data/pull/17220
  • CSS atan2() - https://github.com/mdn/browser-compat-data/pull/17221

mdn/data:

  • CSS Syntaxes - https://github.com/mdn/data/pull/592

ramiy avatar Sep 06 '22 09:09 ramiy

Hi @Rumyra ,

Since Firefox 103, those functions are behind the layout.css.trig.enabled flag.

We need to make sure they will ship in Firefox 105 (not Nightly).

Please read the comments at https://github.com/mdn/browser-compat-data/pull/17505

ramiy avatar Sep 06 '22 09:09 ramiy

Hi @ramiy that's great, thanks a lot for your contribution. Do you already have a branch for the outstanding functions? I think we could probably get them all to land in a single PR, what do you think?

bsmth avatar Sep 06 '22 09:09 bsmth

Hi @ramiy that's great, thanks a lot for your contribution. Do you already have a branch for the outstanding functions? I think we could probably get them all to land in a single PR, what do you think?

No, they are not ready yet.

ramiy avatar Sep 06 '22 10:09 ramiy

OK, thanks. Would you like to collaborate on a fork? I can open a draft PR to compare changes if that's convenient. Let me know how you would like to proceed.

bsmth avatar Sep 06 '22 11:09 bsmth

Hi @ramiy - these are to be shipped in 105 - see the afore mentioned bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1774589

Hence why the issue is open, as the content team works on updates monthly. As these are for 105 we're looking to get them complete by the end of next week. If you need @bsmth support to do this please let us know - thanks!

Rumyra avatar Sep 06 '22 13:09 Rumyra

They are not enabled by default in 105, but behind a flag. https://searchfox.org/mozilla-beta/source/modules/libpref/init/StaticPrefList.yaml#7633-7638

https://bugzilla.mozilla.org/show_bug.cgi?id=1787070 will enable them.

evilpie avatar Sep 07 '22 08:09 evilpie

Thanks @evilpie that's really helpful.

@ramiy if you still need our support let us know. We can also do the relevant bcd updates when they are released to stable if that helps

Rumyra avatar Sep 07 '22 14:09 Rumyra

As I see it now, the only outstanding changes are BCD updates. I'm holding off from adding the dev-doc-complete label on Bugzilla until then.

I'm also skipping interactive examples for the moment because the mdn/content pages already have nice-looking examples.

bsmth avatar Sep 13 '22 12:09 bsmth

@Rumyra @bsmth

How should we document the trigonometric constants ( e | pi | infinity | -infinity | NaN ) ?

ramiy avatar Sep 14 '22 13:09 ramiy

Shall we put them under numbers -> https://developer.mozilla.org/en-US/docs/Web/CSS/number

Note: While not technically numbers, these keywords act as numeric values, similar to e and pi. Thus to get an infinite length, for example, requires an expression like calc(infinity * 1px).

bsmth avatar Sep 14 '22 13:09 bsmth

See the Calc Syntax section in the spec.

<calc-constant> = e | pi | infinity | -infinity | NaN

Should we create a new CSS data type ? Even is the answer is "no", eventually we will have to create this new type.

ramiy avatar Sep 14 '22 14:09 ramiy

Should we create a new CSS data type ?

I think we can skip that for now and add a "Numeric Constants" subsection to numbers for the moment, what do you think? We might indeed have to add a dedicated page in future. One thing to inform that decision: the spec lists these constants under math expressions not under numeric data types.

bsmth avatar Sep 14 '22 14:09 bsmth

Why am I hesitating?

Because infinity/-infinity is not just a <number>, it can also be a <dimension> which can specify distances (<length>), durations (<time>), frequencies (<frequency>), resolutions (<resolution>), and other quantities.

I prefer to create new data types for <calc-sum>, <calc-product>, <calc-value> and <calc-constant>.

ramiy avatar Sep 14 '22 15:09 ramiy

OK, I see your point. How about we mention e | pi | infinity | -infinity | NaN on the values and units page under numeric constants as they're still not types, as such, but referred to in the spec as "keywords" under math expressions.

I'm curious where <calc-sum> etc. would fit in the our docs. Note that we have the following: https://developer.mozilla.org/en-US/docs/Web/CSS/calc

bsmth avatar Sep 15 '22 12:09 bsmth

@ramiy I think we should limit the scope of these changes for the moment. Let's just add some basic notes about the constants (one or two paras) as a sibling or child of numeric types either on the values or types page. We need to have a longer think about where it makes sense to have <calc-constant> and friends documented. 🙌🏻

bsmth avatar Sep 15 '22 12:09 bsmth

@ramiy -> If you would like to make bigger changes (i.e. adding pages), could you please fill out a content suggestion issue so we can plan for it? Thank you! :)

bsmth avatar Sep 15 '22 14:09 bsmth

I'm curious where <calc-sum> etc. would fit in the our docs. Note that we have the following: https://developer.mozilla.org/en-US/docs/Web/CSS/calc

See the calc syntax. The spec talks about calc-sum & friends too. I thin they should be documented in MDN.

Some of the content currently documented in calc() will be moved to <calc-sum>, <calc-product>, <calc-value> and <calc-constant>.

ramiy avatar Sep 15 '22 18:09 ramiy

Yes, I think this makes sense. Could you please fill out a content suggestion issue so that we can track this? Thanks a lot

bsmth avatar Sep 19 '22 08:09 bsmth

@bsmth How is this one going? I was just doing a sweep of 105 items that still have dev-doc-needed and it includes these two:

Mostly just checking that 1682444 is part of this so we don't need another release issue to be created?

hamishwillee avatar Oct 13 '22 23:10 hamishwillee

Hi @hamishwillee thanks for checking. I think you're right in including this one into this ticket:

Although https://github.com/mdn/content/commit/16824442b614603c35ec545f28978a2658ea828c looks unrelated, did you mean to link to this?

bsmth avatar Oct 14 '22 08:10 bsmth

Although https://github.com/mdn/content/commit/16824442b614603c35ec545f28978a2658ea828c looks unrelated, did you mean to link to this?

Whoops. No. . Should we add a note to the calc one that it is addressed by this issue?

hamishwillee avatar Oct 14 '22 10:10 hamishwillee

Should we add a note to the calc one that it is addressed by this issue?

Good idea, just added a comment to the bug 👍🏻

bsmth avatar Oct 14 '22 10:10 bsmth

Thanks! I think its a generally good idea to cross link so that anyone in the team can tell that a bugzilla bug is already being addressed in some way. We're not so bad at that in more recent times.

hamishwillee avatar Oct 16 '22 22:10 hamishwillee