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

MAINT: Drop jQuery and use Bootstrap 5 #1029

Merged
merged 23 commits into from
Nov 22, 2022
Merged

Conversation

12rambau
Copy link
Collaborator

@12rambau 12rambau commented Oct 20, 2022

Fix #953, Fix #764

for bootstrap I've followed the instructions from: https://getbootstrap.com/docs/5.0/migration/

which lead to the following changes:

  • include bootstrap 5.1 to packages
  • update to popperjs/core (popper v2)
  • change all occurences of left (res l) by start(res. s) and right (res. r) by end (res. e)
  • check all the brekpoints as they changed how they work
  • update all toggle like data-* by data-bs-*

and for jquery: https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/#network-requests-with-get-or-ajax

which lead to the following changes:

  • create a function to mimic jquery .ready()
  • replace $.ajax, $.getJSONand $.get by the generic fetch
  • replace jquery selectors and manipulators ($().each etc...)
  • drop jquery everywhere

It's a sensitive change as I'm modifying pretty much every js of theme so I tagged most of the regular maintainers. Let me know what you think and your suggestions. Also note that the package-lock.json ended up being a lot modified, if you know a way to cherry-pick the changes I'm happy to change it.

@drammock
Copy link
Collaborator

drammock commented Oct 20, 2022

I know this is WIP, just a reminder that we will need to get these $(...) too:

$(window).on("activate.bs.scrollspy", function () {

$(addModeListener);
$(scrollToActive);
$(addTOCInteractivity);
$(setupSearchButtons);
$(initRTDObserver);

$.get("{{ theme_announcement }}", success=(data)=>{
$("#header-announcement").html(`<div class="bd-header-announcement__content">${data}</div>`);

@12rambau
Copy link
Collaborator Author

I know this is WIP, just a reminder that we will need to get these $(...) too:

Yep I'm working on it, I just want to check first if the bootstrap breaking changes are all tackled. @drammock do you know a way to edit package-lock.json but only the edited dependencies? like in https://github.com/pydata/pydata-sphinx-theme/pull/868/files. Currently, I run npm install --package-lock-only but it rewrites everything.

@drammock
Copy link
Collaborator

do you know a way to edit package-lock.json but only the edited dependencies?

I think with #868 it worked that way because FontAwesome doesn't have any dependencies. AFAIK npm update package_name will always update that package's dependencies too; there is no equivalent to pip install --no-deps package_name (or if there is, I don't know about it)

@12rambau 12rambau marked this pull request as ready for review October 20, 2022 18:46
Copy link
Collaborator

@drammock drammock left a comment

Choose a reason for hiding this comment

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

I love that package-lock.json has gone from 21k lines to 9k lines. I noticed a few problems, see below.

@choldgraf
Copy link
Collaborator

I took a pass through the preview docs, and they seem to look good to me. Scrolling behavior works and things seem to be formatted properly. Anything else that @12rambau wants to do here or are you ready for final review + merge? My feel is we should:

  • cut a release before merging this one
  • include an announcement banner saying that we updated to Bootstrap 5 and removed JQuery, so downstream authors should be aware of those changes.
  • to do this quickly so it doesn't become out of date

@drammock
Copy link
Collaborator

  • cut a release before merging this one
  • include an announcement banner saying that we updated to Bootstrap 5 and removed JQuery, so downstream authors should be aware of those changes.
  • to do this quickly so it doesn't become out of date

SGTM!

@12rambau
Copy link
Collaborator Author

what type of banner are you thinking about? Using the header banner or adding a warning admonition on the landing page ?

@choldgraf
Copy link
Collaborator

I was thinking header banner - what do you think? I'm happy with whatever path you think is best

@12rambau
Copy link
Collaborator Author

I was thinking, maybe that's a good reason to finish the PR on loud banners #759 ?

@choldgraf
Copy link
Collaborator

I agree that loud banners would be quite useful! Though I won't have any time to finish it any time soon. I am happy to review PRs if you or others want to take it over and get it over the finish line.

@12rambau
Copy link
Collaborator Author

Now that 0.12 is out should we commit this one to master ?

@choldgraf
Copy link
Collaborator

If you think that this is ready to go, then I suggest we merge it quickly and iterate from there. One suggestion: could you provide a short summary of the changes that you needed to make in this PR, as a "mini guide" to downstream authors who might need to make the same changes in their themes?

@12rambau
Copy link
Collaborator Author

@choldgraf done (I'll may need some proofreading though).
I think this page should be advertised in the loud banner i.e. in a follow-up PR.

Copy link
Collaborator

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

OK looks good to me - I've cleaned up the language a little bit, so I think we should merge this and then see if any bugs or questions pop up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update to bootstrap 5 Remove dependence on JQuery or explicitly include it in the theme
3 participants