quantecon-book-theme icon indicating copy to clipboard operation
quantecon-book-theme copied to clipboard

๐Ÿ‘Œ IMPROVE: RHS TOC sticky when scrolling option

Open DrDrij opened this issue 3 years ago โ€ข 24 comments

Fixes https://github.com/QuantEcon/quantecon-book-theme/issues/133

  • [x] Add config option to make the in-page-TOC in the right column sticky (stays in view when scrolling)
  • [x] Highlight respective TOC items when scrolling

The page TOC will now highlight as the user scrolls.

A config option is required to activate the sticky feature and highlighting functionality. This defaults to False where the page TOC is not sticky.

sphinx:
  config:
    html_theme_options:
      sticky_contents: true

https://user-images.githubusercontent.com/5886045/122872398-bf5a5480-d373-11eb-83df-e286ca4ba482.mov

DrDrij avatar Jun 06 '21 01:06 DrDrij

nice work @DrDrij -- it would be good to get the preview building with the updated RHS toc. Is that possible?

mmcky avatar Jun 06 '21 09:06 mmcky

Codecov Report

Merging #144 (a75930f) into master (976718a) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #144   +/-   ##
=======================================
  Coverage   71.12%   71.12%           
=======================================
  Files           2        2           
  Lines         239      239           
=======================================
  Hits          170      170           
  Misses         69       69           
Flag Coverage ฮ”
pytests 71.12% <รธ> (รธ)

Flags with carried forward coverage won't be shown. Click here to find out more.

:mega: Weโ€™re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Jun 11 '21 01:06 codecov[bot]

@DrDrij is the outstanding checkbox still in work?

mmcky avatar Jun 18 '21 03:06 mmcky

re: option name perhaps we need to specify rhs perhaps.

The main toc is persistent_toc: true

So perhaps we need to differentiate these toc objects a bit more clearly. Maybe LHS == TOC and RHS == CONTENTS

mmcky avatar Jun 22 '21 06:06 mmcky

@DrDrij what do you think re: comments / names?

mmcky avatar Jul 20 '21 02:07 mmcky

@DrDrij do you think you would have some time in the next two weeks to see if we can close this?

mmcky avatar Sep 07 '21 04:09 mmcky

@mmcky Great idea. Changed the parameter to sticky_contents: true from sticky_toc: true. Shall I create a PR on the myst sites to add the parameter? programming, python, advanced, datascience, julia? I suppose we only need to add it if we want sticky as true (default false).

I think that covers it for this PR :)

DrDrij avatar Sep 09 '21 04:09 DrDrij

@DrDrij thanks for this. I am wondering if we should make this default: true so that we don't have to change config. We can then turn it off it isn't what we want. Then the preview here will also show this in action and we can ask @jstac what he thinks.

  • [x] fix merge conflicts

mmcky avatar Sep 16 '21 04:09 mmcky

@AakashGfude would you have time to fix up this merge conflict?

mmcky avatar Apr 29 '22 03:04 mmcky

@mmcky have fixed merge conflicts. Had to add some changes to pre-commit-config.yaml and setup.py for the CI to run. Have added in this PR itself, if it's ready to merge. Else will create a new PR.

AakashGfude avatar May 05 '22 10:05 AakashGfude

@AakashGfude what is the difference between

sticky_toc = False
persistent_sidebar = False

mmcky avatar May 06 '22 01:05 mmcky

@AakashGfude what is the difference between

sticky_toc = False
persistent_sidebar = False

@mmcky persistent_sidebar is for left toc, which is for the whole project. sticky_toc is for right hand toc, concerning only the current page. More info about persistent_sidebar is in this PR: https://github.com/QuantEcon/quantecon-book-theme/pull/143

AakashGfude avatar May 12 '22 05:05 AakashGfude

@AakashGfude It would be great if we can change sticky_toc: true to sticky_contents: true

mmcky avatar May 15 '22 03:05 mmcky

@AakashGfude It would be great if we can change sticky_toc: true to sticky_contents: true

@mmcky true, contents do sound like contents of the page. I will change it.sticky_rhs_toc can also be one option

AakashGfude avatar Jun 16 '22 01:06 AakashGfude

I think sticky_contents will be fine.

mmcky avatar Jun 27 '22 01:06 mmcky

@AakashGfude can you please resolve these conflicts after #186 is merged.

mmcky avatar Mar 13 '23 00:03 mmcky

@mmcky this is ready to be reviewed and merged.

AakashGfude avatar May 01 '23 09:05 AakashGfude

@AakashGfude the latest netlify doesn't seem to show the "sticky" rhs toc?

mmcky avatar May 03 '23 05:05 mmcky

@AakashGfude let's revert 0acf72c and I will update the quantecon-book-theme branch on lecture-python-programming.

https://github.com/QuantEcon/lecture-python-programming.myst

mmcky avatar May 04 '23 00:05 mmcky

@AakashGfude I just pushed c8fd78a

mmcky avatar May 04 '23 00:05 mmcky

@AakashGfude once you get the tests and merge conflict sorted -- then please ping me for review. Thanks.

mmcky avatar May 04 '23 00:05 mmcky

@AakashGfude this looks sticky now ๐Ÿ‘

What do you think? I suspect @jstac will prefer the non-sticky version but it is nice that our theme can support this option.

mmcky avatar May 05 '23 02:05 mmcky

@jstac this PR enables the RHS within page contents to stay visible in the margin

https://64546294cce6883938fb185c--hungry-lovelace-7d0512.netlify.app/python_by_example.html

Let me know your thoughts on this? I am in two minds - I like the clean view of it just being at the top (i.e. not sticky) but it can be handy to navigated within the page with it available all the time.

mmcky avatar May 05 '23 02:05 mmcky

Thanks @mmcky. This looks good now. Yes, I think by default we should keep it non-sticky. Good to have the option.

AakashGfude avatar May 05 '23 15:05 AakashGfude