Code Monkey home page Code Monkey logo

Comments (27)

seyhunak avatar seyhunak commented on May 18, 2024

Did you tested with 2.0's variables?
http://twitter.github.com/bootstrap/less.html#variables

from twitter-bootstrap-rails.

raphaelcosta avatar raphaelcosta commented on May 18, 2024

I fount where is my mistake, generator use require twitter/bootstrap in application.js and not bootstrap, so this file has never been readed by asset pipeline.

But @gridColumns variable didn't worked for me.

from twitter-bootstrap-rails.

seyhunak avatar seyhunak commented on May 18, 2024

Some changes and fixes applied, can you try again with updating gem.

from twitter-bootstrap-rails.

raphaelcosta avatar raphaelcosta commented on May 18, 2024

I updated and used this in bootstrap_override:

// import twitter bootstrap variables and mixins
@import "twitter/bootstrap";

// Your custom stylesheets goes here (override Less here)
@gridColumns:         24;
@gridGutterWidth:   20px;
@gridColumnWidth:   21px; 
@basefont:          20px;
@baseline:          18px;

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

I can confirm that, with the latest git master of this gem, overriding Bootstrap's less variables is extremely not obvious.

the installed application.css looks like this:

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require twitter/bootstrap
 *= require twitter/bootstrap_responsive
 *= require_tree .
*/

Sprockets processes each require individually, and it's (theoretically) satisfied by any type of preprocessor and could be in any language. There's no variable sharing or anything like that among them.

Twitter bootstrap (vanilla, from vendor) is processed, with its default variables, in lines 2 and 3 above.

Line 4 will require the whole tree, which should pull in bootstrap_override.css.less, which looks like this:

// import twitter bootstrap variables and mixins
@import "twitter/bootstrap_base";

// Your custom stylesheets goes here (override Less here)

Unfortunately, even if you set the right variables there, it's too little too late - it'll only be consumed by bootstrap_base (which internally only has variables and mixins). This is almost a NO-OP since the actual bootstrap widgets were not rebuilt, and are served verbatim with their default variables earlier.

What raphaelcosta did above is going doen the right path - you want the same LESS file to require both the whole twitter/bootstrap framework AND your custom variables.

Unfortunately, without further modifications, that means that the whole packege will actually load twitter/bootstrap twice - once directly from application.css using the default variables, and again from within bootstrap_override.css.less using the custom variables - both chunks will be in the output, and its only by virtue of same CSS rules overriding ealier ones that the browser picks up on the later ones.

I think, going forward, application.css should NOT require twitter/bootstrap, since this leaves 0 room for overrides. Instead it should always just require_tree or explicitly require bootstrap_overrides (to be renamed bootstrap_and_overrides for clarity).

Then, that file, which is a single LESS invocation from sprockets, should require the full twitter/bootstrap and allow for overrides there.

from twitter-bootstrap-rails.

datl avatar datl commented on May 18, 2024

I should have documented my patches better. The idea behind that bootstrap_override is just to give you variables and mixins you may use to re-style elements. The defaults can't be override atm.

There are efforts to bring that feature in, but the approach is far from being robust. I actually came up with something that may work, will post back later when I get home.

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

With my suggestion above:

  1. Don't require twitter/bootstrap from application.css
  2. Require it from within bootstrap_override.less.css

All less default variables are nicely overrideable, AND you get to inherit mixins for styling your own elements

(though the purpose of bootstrap_override changes in that case, that's why I recommend changing it to bootstrap_and_overrides)

from twitter-bootstrap-rails.

seyhunak avatar seyhunak commented on May 18, 2024

@minaguib Can you please fork and issue a pull to me with your suggestions? I'll test it. If everything overrideable I'll merge with master.

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

Sure thing, but I'd like to hear from @datl some more - since this change will revert some of his work.

from twitter-bootstrap-rails.

datl avatar datl commented on May 18, 2024

Sounds good, just go ahead and submit your pull request please.
One thing I'd add though. Many people (like me) just use bootstrap as a drop-in scaffold replacement and won't be overriding variables. Some would just delete the generated LESS file as they are confident having the full bootstrap stylesheet loaded with the call in application.css. So it would be nice to have the override? option in install generator for ppl to choose, or at least let them know that they can require twitter/bootstrap in application.css and delete generated file if overriding is not desired.

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

@seyhunak Done - See #98

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

@datl I thought about your comment above, but I implemented what I think is a simpler solution.

application.css always requires bootstrap_and_overrides - the generator/installer sets it up that way, end of story.

We already rely on Less to compile bootstrap - we're just moving that invocation 1 file away.

For both types of users, it "just works".

For users who actually want to tinker in Less-land, they can open that file and add their changes there. This can be done after-the-fact, and the install process remains the same for everyone.

I don't think it's worth worrying about "what if the user deletes 'require bootstrap_and_overrides'" from application.css any more than worrying about them deleting 'require jquery' - they're responsible for managing their manifest, and the installer sets them up on the right track initially.

from twitter-bootstrap-rails.

seyhunak avatar seyhunak commented on May 18, 2024

@minaguib .Your pull merged, thanks. New version of gem will be released soon.

from twitter-bootstrap-rails.

datl avatar datl commented on May 18, 2024

@minaguib Agree w/ you that it would be more straightforward to keep the installation process the same to everyone. So instead of giving one more install option, I would suggest having a comment block in the less file saying that they can delete that file and include bootstrap in application.css if they dont wish to override stuff.

And one problem with the pull request, you are compiling both bootstrap and bootstrap_responsive in the same less file, which brings back issue #87. We would want to have those compiled separately.

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

@datl I'm not familiar enough with the responsive stuff, but, can we solve that by adding a comment in bootstrap_and_overrides ?

For example:

// Choose one of the following:
@import "twitter/bootstrap/bootstrap"; 
// or:
//@import "twitter/bootstrap/responsive"; 

from twitter-bootstrap-rails.

datl avatar datl commented on May 18, 2024

Nope. I believe we need bootstrap in order to have bootstrap_responsive fully functioned. Also, many people are gonna need both of those in their projects anyway, because responsive stylesheet is only for devices with small screen.

We can either put ''@import twitter/bootstrap/responsive'' into a separated less file or delete variables and mixins import lines in bootstrap/responsive.less.

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

Ok I think I completely understand the responsive behavior and chain now.

I think this would be the ideal scenario:

application.css:

*
*= require_tree
*
* OR EXPLICITLY:
*
*= require bootstrap
*  If you want responsive support:
*= require bootstrap_responsive

bootstrap.css.less:

// Don't modify this file - it provides a single Less compilation unit for bootstrap
// Edit bootstrap_overrides.css.less for your own changes
@import "twitter/bootstrap/bootstrap";
@import "bootstrap_overrides"

bootstrap_responsive.css.less:

// Don't modify this file - it provides a single Less compilation unit for bootstrap/responsive
// Edit bootstrap_overrides.css.less for your own changes
@import "twitter/bootstrap/responsive";
@import "bootstrap_overrides"

bootstrap_overrides.css.less:

// If you'd like to override bootstrap's own variables or use its mixins
// This is the place to do it.  Note that this will be consumed by regular
// bootstrap as well as bootstrap_overrides
//
// Example:
// @linkColor: #ffoooo;

Unfortunately it's taking half a step back (in the right direction, IMO), and will cause a bit more confusion to existing users of the gem, who are already struggling a bit with the change we pushed above... :(

To address your solutions above:

  • put ''@import twitter/bootstrap/responsive'' into a separated less file
    That will fix #87, but will be unable to consume the user's overrides set in bootstrap_and_overrides.css
  • delete variables and mixins import lines in bootstrap/responsive.less
    That would work, but it's kinda icky as we'll be modifying the vendor's files - I'm not totally against it though (we already need to modify their files for asset URLs for example)

Thoughts everyone ?

from twitter-bootstrap-rails.

raphaelcosta avatar raphaelcosta commented on May 18, 2024

This is already implemented in verson 2.0.1.0 ?

from twitter-bootstrap-rails.

mrrooijen avatar mrrooijen commented on May 18, 2024

I'm a bit confused about this issue.

@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";

@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');

@linkColor:       #ff0000;
@gridColumns:     12;
@gridColumnWidth: 80px;
@gridGutterWidth: 0px;
@gridRowWidth:    (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));

This is what I have in my bootstrap.css.less file which I //= require bootstrap from my application.css.sass file.

The only variable in the above snippet that properly overrides is the @linkColor variable. The grid variables do not change.

I'm using the latest commit from the git repository. Is there any way to alter the grid variables with the current implementation?

Thanks

from twitter-bootstrap-rails.

minaguib avatar minaguib commented on May 18, 2024

@meskyanichi I'll experiment and get back to you

from twitter-bootstrap-rails.

mrrooijen avatar mrrooijen commented on May 18, 2024

I noticed that when I comment out the @import "twitter/bootstrap/responsive"; it does pick up my changes.

from twitter-bootstrap-rails.

daniely avatar daniely commented on May 18, 2024

I have the same problem as @meskyanichi and the workaround of commenting out @import "twitter/bootstrap/responsive"; works for me as well.

from twitter-bootstrap-rails.

raphaelcosta avatar raphaelcosta commented on May 18, 2024

this workaround worked for me too, but not in all variables, for example gridColumns didn't worked was I expected

from twitter-bootstrap-rails.

iotriado avatar iotriado commented on May 18, 2024

that is happens because the twitter/bootstrap/responsive load the default variables of bootstrap. If you have a look in native twiter bootstrap code at less / responsive.less (https://github.com/twitter/bootstrap/blob/master/less/responsive.less) file you will notice that at line 21 it loads the variabes every time

from twitter-bootstrap-rails.

iotriado avatar iotriado commented on May 18, 2024

Searching more on this I realize that the error is in
responsive-1200px-min.less

from twitter-bootstrap-rails.

camsong avatar camsong commented on May 18, 2024

@daniely i need respective, how could i walk around if i don't not commenting out @import "twitter/bootstrap/responsive";

@iotriado, bootstrap also load the variabels (https://github.com/twitter/bootstrap/blob/master/less/bootstrap.less#L15), but why only responsive have bugs?

@seyhunak need your help, thanks.

from twitter-bootstrap-rails.

bronson avatar bronson commented on May 18, 2024

I had an undefined variable error. Restarting the server didn't fix it but rm -rf tmp/cache did. Not sure where the bug is but, in case anyone else ends up here looking for solution, give that a shot.

from twitter-bootstrap-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.