aio: add h1 title to floating table of contents#16959
Conversation
a6c01b3 to
a4fecef
Compare
|
I rebased, fixed the conflict, and broke up the big commit into smaller ones to make the refactoring more easy to follow. |
a4fecef to
c496a15
Compare
|
The angular.io preview for a4fecef8b11eed8fac517db6217e35ff98459042 is available here. |
|
The angular.io preview for c496a150dd97f445293115489c98ead3ab94b2df is available here. |
gkalpak
left a comment
There was a problem hiding this comment.
A few nit-picks. Nothing blocking.
Loved the refactorings ❤️
There was a problem hiding this comment.
Nah! It's a pyramid of beauty!
There was a problem hiding this comment.
Just to be clear: I like it 😃
There was a problem hiding this comment.
I wonder if we need the element specifiers at all. Why not just .toc-heading, .toc-list .h1 { ... }?
There was a problem hiding this comment.
That is probably correct. I was just sort of following the convention there already.
There was a problem hiding this comment.
But I think that Stef will change some of this anyway
There was a problem hiding this comment.
Not directly related to this PR, but I noticed this value is invalid and causes the style to be ignored. It should be 0.3s (the s is currently missing).
There was a problem hiding this comment.
I'll sneak that in.
There was a problem hiding this comment.
24px feels too much. margin: 10px 0 looks better imo 😃
There was a problem hiding this comment.
I think this is due to change in Stef's PR.
There was a problem hiding this comment.
Nit: this.tocList.filter(item => item.level !== 'h1').length is slightly more readable 😳
There was a problem hiding this comment.
but slower and uses more memory :-P
There was a problem hiding this comment.
I know, I know 😞 But Igor said to opt for readability over performance 😛
There was a problem hiding this comment.
It might make sense to avoid this ngIf, by separating the h1 element from the rest (in the component).
There was a problem hiding this comment.
I thought about that but it just moves the complexity somewhere else.
Not displaying the h1 IMO is a visual choice, hence the responsibility of the template.
There was a problem hiding this comment.
The decision about dislaying it or not will still be in the template. But the template won't have to "extract" it from the tocList (which sounds rather "business-logic-y").
I don't feel at all strognly about it, though.
There was a problem hiding this comment.
I think that then you would need complexity in both the component class (to extract the h1) and then in the template (where it would need to duplicate the li element for the h1).
There was a problem hiding this comment.
Actually also it become even more complex when you then try to get the activeIndex to line up. This way, it just works :-)
|
@gkalpak Pushed a bunch of fixes from your feedback, some of which will be squashed. PTAL |
|
The angular.io preview for 4bb3bc7a39b01e5365ffc18b5db862db184cdabb is available here. |
There was a problem hiding this comment.
There are more missing whitespaces here.
There was a problem hiding this comment.
return array.filter(fn).length is more readable 😛
This makes the styling less fragile to changes in the HTML
We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes, which, in turn, are caused by the rendering that happened due to a ChangeDetection. Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular.
4bb3bc7 to
c9f93b9
Compare
There seems to have been a bad rebase of angular#16228 on top of angular#16959, which affected ToC styles from both PRs. This commit restores the horizontal line under `.h1` elements and the vertical blue bar on the left-hand side of the ToC (with the circle running along the bar to indicate the active section). Fixes angular#17098
There seems to have been a bad rebase of #16228 on top of #16959, which affected ToC styles from both PRs. This commit restores the horizontal line under `.h1` elements and the vertical blue bar on the left-hand side of the ToC (with the circle running along the bar to indicate the active section). Fixes #17098
* refactor(aio): use explicit CSS class for TOC container This makes the styling less fragile to changes in the HTML * fix(aio): schedule TocComponent.activeIndex updates via AsapScheduler We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes, which, in turn, are caused by the rendering that happened due to a ChangeDetection. Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular. * refactor(aio): do not instantiate floating ToC if not displayed * feat(aio): display the h1 at the top of the floating TOC Closes angular#16900 * refactor(aio): combine the TOC booleans flags into a "type" state * refactor(aio): remove unnecessary `hostElement` property * fix(aio): ensure that transition works on TOC * fix(aio): use strict equality in ToC template
There seems to have been a bad rebase of angular#16228 on top of angular#16959, which affected ToC styles from both PRs. This commit restores the horizontal line under `.h1` elements and the vertical blue bar on the left-hand side of the ToC (with the circle running along the bar to indicate the active section). Fixes angular#17098
* refactor(aio): use explicit CSS class for TOC container This makes the styling less fragile to changes in the HTML * fix(aio): schedule TocComponent.activeIndex updates via AsapScheduler We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes, which, in turn, are caused by the rendering that happened due to a ChangeDetection. Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular. * refactor(aio): do not instantiate floating ToC if not displayed * feat(aio): display the h1 at the top of the floating TOC Closes angular#16900 * refactor(aio): combine the TOC booleans flags into a "type" state * refactor(aio): remove unnecessary `hostElement` property * fix(aio): ensure that transition works on TOC * fix(aio): use strict equality in ToC template
There seems to have been a bad rebase of angular#16228 on top of angular#16959, which affected ToC styles from both PRs. This commit restores the horizontal line under `.h1` elements and the vertical blue bar on the left-hand side of the ToC (with the circle running along the bar to indicate the active section). Fixes angular#17098
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #16900