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

default.css overrides the theme style

Open delinhabit opened this issue 13 years ago • 10 comments

Hello,

When I switch the bootstrap theme, the navbar is always the same (default.css overrides it). What's the point of using bootstrap themes if we cannot fully integrate any? Is there a reason for this? Should we "fix" default.css so it only touches non-theme styles so we can easily switch theme and get the expected behavior?

Thanks!

delinhabit avatar Apr 03 '13 05:04 delinhabit

you are talking about to docs? why should we? design decision. it's an api. not a css framework ;-) reopen if you feel it's worth discussing.

minddust avatar Apr 03 '13 09:04 minddust

Hello,

No I was not talking about the docs. I was talking about the Browseable API. If you follow the docs (http://django-rest-framework.org/topics/browsable-api.html#customizing), you can see that if we switch the theme by overriding the bootstrap_theme block we can easily integrate any bootrap theme with the Browseable API. But that's not exactly the case, because default.css overrides a lot of style attributes each theme is bringing.

My opinion is that we either should not include support for changing themes in the framework, or we should do it properly.

Thanks!

delinhabit avatar Apr 03 '13 09:04 delinhabit

Hi @delinhabit, yeah that's valid. Most likely this has just been missed because most of us work from the default style. Any chance you could sling up a screenshot to give an idea of what/how much stuff is broken if you switch the default style? Any PR's addressing this but still keeping the default style looking the same would be appreciated. PRs should probably include before/after screenshots to make them easy to review.

lovelydinosaur avatar Apr 03 '13 09:04 lovelydinosaur

Hello,

I can't say that there is a lot of stuff broken, but there are definitely some design issues. Basically the navbar as provided by the theme should look like this one: navbar

But in the Browseable API it's looking like this: api

What I wanted to point out is that we should rely, for the Browseable API template, on what bootstrap provides, so when we switch the theme we get everything working smoothly from the design point of view. This might require a lot of reworking of the API template and I'm willing to share some results when I'm done with my custom template. On the other hand, I'm not an experienced design guy so maybe there are others who have some ideas for these issue.

Thanks!

delinhabit avatar Apr 03 '13 10:04 delinhabit

Maybe we should provide in the framework only the content of the API pages and a default layout HTML, and let the API developers provide their own layout? That's what I'm basically doing right now. unfortunately I'll have to copy paste the template code from the rest_framework/base.html in order to include the Browseable API functionality in my layout.

Any thoughts?

delinhabit avatar Apr 03 '13 10:04 delinhabit

What does the template look like that gives you the above screenshot?

Are you just missing the {% block bootstrap_navbar_variant %}{% endblock %} noted here?

I think the layout stuff shouldn't be overridden by default, but we may need to move some elements such as the gridline background into the bootstrap_theme block so that they become overridden if you use a new theme.

lovelydinosaur avatar Apr 04 '13 10:04 lovelydinosaur

I was using the {% block bootstrap_navbar_variant %}{% endblock %} block to set the navbar style to navbar-inner and also the bootstrap_theme block to change the theme. I guess the theme colors where not kicking-in due to these kind of style declarations.

I agree with you on the special styles, like the background grid. But there also might be some elements that require special styling for the Browseable API, like the POST/PUT/PATCH forms or the pre modules. These indeed should be styled within the stock rest framework CSS (similar to what default.css does), but that should not touch the style provided by the theme (colors, text size, e.t.c.).

Thoughts?

delinhabit avatar Apr 04 '13 11:04 delinhabit

I think that any thematic styling such as those navbar colorings should probably go in bootstrap-tweaks.css, which should be moved to inside the bootstrap_theme block. Any positional styling should stay in default.css. Should be able to get things to a point where the themes then swap out nicely and do what you'd expect.

lovelydinosaur avatar Apr 04 '13 11:04 lovelydinosaur

Marked for attention in DjangoCon sprints.

  • Check the existing visual style when using a bootswatch theme.
  • Make any required template changes to ensure it plays nicely with new themes.

lovelydinosaur avatar May 17 '13 15:05 lovelydinosaur

Fixed by #855

lovelydinosaur avatar May 18 '13 13:05 lovelydinosaur