Skip to content

aio: add h1 title to floating table of contents#16959

Merged
chuckjaz merged 8 commits into
angular:masterfrom
petebacondarwin:aio-toc-floating-title
May 24, 2017
Merged

aio: add h1 title to floating table of contents#16959
chuckjaz merged 8 commits into
angular:masterfrom
petebacondarwin:aio-toc-floating-title

Conversation

@petebacondarwin

Copy link
Copy Markdown
Contributor

Closes #16900

@petebacondarwin petebacondarwin added comp: aio action: review The PR is still awaiting reviews from at least one requested reviewer labels May 23, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

English !!

@petebacondarwin petebacondarwin force-pushed the aio-toc-floating-title branch from a6c01b3 to a4fecef Compare May 24, 2017 08:00
@petebacondarwin

Copy link
Copy Markdown
Contributor Author

I rebased, fixed the conflict, and broke up the big commit into smaller ones to make the refactoring more easy to follow.

@petebacondarwin petebacondarwin force-pushed the aio-toc-floating-title branch from a4fecef to c496a15 Compare May 24, 2017 08:09
@mary-poppins

Copy link
Copy Markdown

The angular.io preview for a4fecef8b11eed8fac517db6217e35ff98459042 is available here.

@mary-poppins

Copy link
Copy Markdown

The angular.io preview for c496a150dd97f445293115489c98ead3ab94b2df is available here.

@gkalpak gkalpak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few nit-picks. Nothing blocking.
Loved the refactorings ❤️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No whitespace after |? 😞

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😱

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OOC, why != vs !==?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

typo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ternary operator hell 😁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah! It's a pyramid of beauty!

@gkalpak gkalpak May 24, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to be clear: I like it 😃

Comment thread aio/src/styles/2-modules/_toc.scss Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we need the element specifiers at all. Why not just .toc-heading, .toc-list .h1 { ... }?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is probably correct. I was just sort of following the convention there already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But I think that Stef will change some of this anyway

Comment thread aio/src/styles/2-modules/_toc.scss Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll sneak that in.

Comment thread aio/src/styles/2-modules/_toc.scss Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

24px feels too much. margin: 10px 0 looks better imo 😃

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is due to change in Stef's PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this.tocList.filter(item => item.level !== 'h1').length is slightly more readable 😳

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but slower and uses more memory :-P

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know, I know 😞 But Igor said to opt for readability over performance 😛

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might make sense to avoid this ngIf, by separating the h1 element from the rest (in the component).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

¯\_(ツ)_/¯

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually also it become even more complex when you then try to get the activeIndex to line up. This way, it just works :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No test for H3 😟

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

😱

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@gkalpak Pushed a bunch of fixes from your feedback, some of which will be squashed. PTAL

@mary-poppins

Copy link
Copy Markdown

The angular.io preview for 4bb3bc7a39b01e5365ffc18b5db862db184cdabb is available here.

@gkalpak gkalpak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still LGTM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's one more here 😛

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are more missing whitespaces here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.
@petebacondarwin petebacondarwin force-pushed the aio-toc-floating-title branch from 4bb3bc7 to c9f93b9 Compare May 24, 2017 17:51
@mary-poppins

Copy link
Copy Markdown

The angular.io preview for c9f93b9 is available here.

@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 24, 2017
@chuckjaz chuckjaz merged commit 966eb2f into angular:master May 24, 2017
@petebacondarwin petebacondarwin deleted the aio-toc-floating-title branch May 25, 2017 10:05
gkalpak added a commit to gkalpak/angular that referenced this pull request May 30, 2017
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
vicb pushed a commit that referenced this pull request May 30, 2017
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
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
* 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
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
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
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
* 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
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
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
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aio: replace "contents" with h1 text in floating right TOC

5 participants