django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

Bootstrap v5

Open smithdc1 opened this issue 4 years ago • 38 comments

Fixes #7327

This is a WIP patch to upgrade the templates to Bootstrap v5. I've tried to chunk the commits up to help review, this will change as this will quite a number of files and lines of code.

I feel like I've made good progress so far. Only major issue I've found so far is tooltips on the dropdown button. The solution on bootstrap 4 (which I've used here) no longer works on bootstrap 5. Another alpha release is due of bootstrap 5 shortly, if it is not fixed in that I can try approaching the issue tracker.

To do (there is much more than this, but here are things I've changed but need to go back and look at):

  • [ ] Fix tooltip on split dropdown button
  • [x] Change the js file to the bundled version (can then drop link to popper.js)

smithdc1 avatar Jul 12 '20 21:07 smithdc1

Hi @smithdc1. Thanks for this! Super start.

carltongibson avatar Jul 14 '20 08:07 carltongibson

Thanks 😄

It's coming along well, currently wrangling with the collapse menu in the docs.

Got my eye on the upcoming releases, seems like they made good progress on alpha 2 in the last few days. I can already see some breaking changes in the next release but they should be incremental changes to the current changes. (e.g. rename of sr-only)

smithdc1 avatar Jul 14 '20 17:07 smithdc1

So I'm fairly pleased with where I've got this to. It's a bit of a waiting game now to see the new releases come out and see if there are any more breaking changes, and to see if the drop-down tool-tip gets fixed. Can also review the remaining css in bootstrap-tweaks and default to see if any further rationalisation can take place here.

One question I do have is for the filter form. The filter form looks a bit odd, it looks like a template from django-filter, what's going on here? (I think I know where this is headed... 😄 )

smithdc1 avatar Jul 15 '20 20:07 smithdc1

One question I do have is for the filter form. The filter form looks a bit odd, it looks like a template from django-filter, what's going on here? (I think I know where this is headed... 😄 )

Chuckle. 😀

Erm... the form is generated by django-filter but is it rendered with crispy forms? (A while since I looked in here...) If you throw up a few links to exact places I'm sure I can get the relevant grey-cells lined up again. 😝

carltongibson avatar Jul 15 '20 20:07 carltongibson

Ok - let's leave it some time and I'll dig deeper at some point in the coming months. There is going to be plenty of time before Bootstrap 5 reaches a stable release.

There may be a crispy-bootstrap-5 template pack by then (template work is done, I need to find the effort to put it into a package, write docs, setup c/i etc)

smithdc1 avatar Jul 15 '20 20:07 smithdc1

Note (to self really).

#30170 on bootstrap 5 changes feedback messages. Html layout and CSS classes will need to be changed.

Currently this ticket is on the inbox for v5 alpha 2.

smithdc1 avatar Jul 30 '20 18:07 smithdc1

Looking forward to this!

joshjung avatar Sep 10 '20 16:09 joshjung

Looking forward to this!

Thanks -- It's coming but bootstrap 5 development itself is steadily paced. For your need I'm not sure I have a good answer, maybe you could have your own fork with this work, noting it is un-reviewed (but if you're in the market to have a look 😉 ) I'm not sure an alpha version is better than an old one from a security perspective 🤷 .

smithdc1 avatar Sep 10 '20 19:09 smithdc1

Bootstrap5 beta 1 is now out. I'll be looking to test my memory by revisiting this soon :tm:.

smithdc1 avatar Dec 07 '20 20:12 smithdc1

Hi all,

So I think this is ready for review. I've left the commit history to show how I achieved this in smaller steps, but I'm not sure if they could be better presented to make the review easier. I am not used to writing such big patches, I also apologise for the size, but I'm not sure there is much I can do. Any guidance would be appreciated.

I'm not sure anyone here is going to have the capacity to review this any time soon (is any one else finding 2021 harder than 2020?). I was wondering if it could be worth trying to widen the net of potential reviewers of this with a post on Twitter? I fully expect this to be far from perfect and even if it's a partial review here and there it would get us closer to the finish line. (I'm very unsure, but I am trying to think of ways of making progress in a sustainable way).

smithdc1 avatar Apr 27 '21 18:04 smithdc1

@smithdc1 big thumbs up on this, I'm very keen on using BS5 in DRF. Hopefully this will get reviewed and merged soon. You're doing just great with 2021.

jscaux avatar May 29 '21 06:05 jscaux

@jscaux if you were to install this locally and look for issues, that would be a helpful step. 👍

carltongibson avatar May 29 '21 06:05 carltongibson

@carltongibson will do; currently busy with moving a separate big stack to BS5. Since DRF is part of the backend, it's a road I have to go down anyway.

jscaux avatar May 29 '21 06:05 jscaux

@carltongibson I've managed to install this locally and run a very basic setup without issues. The bootstrap version could be bumped up to 5.0.1.

jscaux avatar May 30 '21 04:05 jscaux

Ok, thanks for the feedback @jscaux. Let us know if you hit other issues.

carltongibson avatar May 30 '21 06:05 carltongibson

bootstrap 5.1.x released recently.

auvipy avatar Oct 07 '21 10:10 auvipy

Has this been abandoned? DRF could really improve with bs5 :(

lucasdavid avatar Nov 24 '21 21:11 lucasdavid

Okay, so I've been reviewing this. I've made one fix to the templates. Also I think it's worth comparing the two versions here...

Existing Browsable API

Screenshot 2021-12-10 at 16 07 38 Screenshot 2021-12-10 at 16 07 48 Screenshot 2021-12-10 at 16 07 55

Updated Browsable API

Screenshot 2021-12-10 at 16 09 53 Screenshot 2021-12-10 at 16 09 47 Screenshot 2021-12-10 at 16 09 40

Existing Admin Renderer

Screenshot 2021-12-10 at 16 06 52 Screenshot 2021-12-10 at 16 06 57 Screenshot 2021-12-10 at 16 07 10

Updated Admin Renderer

Screenshot 2021-12-10 at 16 10 09 Screenshot 2021-12-10 at 16 10 14 Screenshot 2021-12-10 at 16 10 22

Personally I'm finding the styling changes a bit jarring here, but perhaps that's because I'm used to the existing versions?

It'd be nice to update, and this is a fantastic bit of work getting us there, but it's a shame that the style looks a bit off to me after the update.

Any thoughts, folks?

tomchristie avatar Dec 10 '21 16:12 tomchristie

Maybe it looks a bit off because the new buttons are a little lighter and brighter, while DRF's components (e.g. navbar) are darker and opaque. I always though there was quite a change in tone from bootstrap v3 to v5.

lucasdavid avatar Dec 11 '21 00:12 lucasdavid

So I think the obvious things that need fixing are...

  • The button sizes after this change are significantly bigger, and they don't fit the layout so well.
  • The changed + and x icons for the create/delete buttons are just a bit blergh.
  • The brighter palette perhaps doesn't suit the rest of the interface style quite as well, but I don't think that's a massive problem.

tomchristie avatar Dec 11 '21 09:12 tomchristie

Breadcrumbs are quite different too. Was that intentional? I think .bg-light .rounded classes could be added here.

lucasdavid avatar Dec 11 '21 12:12 lucasdavid

I left a comment

I think anywhere there is .sr-only that has to be removed and the v5 class used.

ghost avatar Feb 12 '22 19:02 ghost

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 18:04 stale[bot]

as this is staled, should we try a smaller incremental version with bootstrap v4 instead?

auvipy avatar Mar 01 '23 15:03 auvipy

as this is staled, should we try a smaller incremental version with bootstrap v4 instead?

or maybe we should have our own CSS like django-admin 👀

baseplate-admin avatar Apr 02 '23 15:04 baseplate-admin

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 10 '23 18:06 stale[bot]

we can revamp it with newer https://blog.getbootstrap.com/2023/05/30/bootstrap-5-3-0/ which has new colors and many improvements.

auvipy avatar Jun 13 '23 04:06 auvipy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 17 '23 00:09 stale[bot]

Hi, can this be rebased?

baseplate-admin avatar Nov 07 '23 03:11 baseplate-admin

Hi, @smithdc1

I want to help you finish this PR. I have extensive experience with Django templates and Bootstrap 5 (I just did a similar migration on a client from v3 to v5.3).

I plan to pull your branch, update this to Bootstrap v5.3, and keep going page by page, ensuring everything works seamlessly. In the best scenario, we would do this incrementally, keeping the existing Bootstrap v3 stylesheets, js, and jQuery in use while we're updating each piece, but as this is an open-source library, I don't think we could do this.

Are you available for a quick async talk on the IRC channel, or do you prefer to discuss the next steps here?

luanfonceca avatar Dec 14 '23 11:12 luanfonceca