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

Some widgets use hardcoded breakpoint names for their media queries #20833

Closed
judowalker opened this issue Oct 4, 2016 · 7 comments
Closed
Labels

Comments

@judowalker
Copy link

judowalker commented Oct 4, 2016

This issue is similar to #20548, however in my case I want to change the breakpoint names as follows:

$grid-breakpoints: (
  xxs: 0,
  xs: 544px,
  sm: 768px,
  md: 992px,
  lg: 1200px
);

This seems to work as far as generating the columns. However, some of the Bootstrap scss files call the media-breakpoint-* mixin with a breakpoint name that no longer matches my breakpoint names. For example, _carousel.scss calls @include media-breakpoint-up(sm) which results in 768px in my case instead of 544px. I would have to manually change it to @include media-breakpoint-up(xs) for it to be correct with my breakpoint names.

Since the number of breakpoints are the same, perhaps some type of mapping can be used to map the mixin argument to the grid-breakpoint (e.g. @include media-breakpoint-up(sm) maps to xs: 544px in $grid-breakpoints).

@cvrebert
Copy link
Collaborator

cvrebert commented Oct 5, 2016

Since the number of breakpoints are the same

But we can't rely on that in the general case.
No good, general solution comes to mind.

CC: @mdo

@cvrebert cvrebert changed the title v4: Custom Breakpoints Names (xxs, xs, sm, md, lg) Some widgets use hardcoded breakpoint names for their media queries Oct 5, 2016
@mdo
Copy link
Member

mdo commented Oct 5, 2016

Yeah I've struggled to think of a way to do this right... I don't know that there is one that scales well without adding too many complications to the source code. I'm open to more suggestions on how to make it work, but otherwise I think it might be outside our scope unfortunately.

@mdo mdo closed this as completed Oct 5, 2016
@judowalker
Copy link
Author

Could it work by passing an index instead of the hardcoded name like media-breakpoint-up(1) which refers to the second breakpoint in $grid-breakpoints?

@judowalker
Copy link
Author

@mdo @cvrebert I think I have a decent solution. The _variables.scss can include variables for the breakpoint names, something like:

$grid-breakpoint-xs: xs !default;
$grid-breakpoint-sm: sm !default;
$grid-breakpoint-md: md !default;
$grid-breakpoint-lg: lg !default;
$grid-breakpoint-xl: xl !default;

Then you can use the variable instead of the hard-coded name: media-breakpoint-up($grid-breakpoint-sm).
This would allow the developer to overwrite the breakpoint names:

$grid-breakpoint-xs: xxs;
$grid-breakpoint-sm: xs;
$grid-breakpoint-md: sm;
$grid-breakpoint-lg: md;
$grid-breakpoint-xl: lg;

@judowalker
Copy link
Author

@mdo @cvrebert could you take a look at my proposed solution?
#20833 (comment)

It scales well and doesn't add any complications.

@Andrew-Dyachenko
Copy link

Andrew-Dyachenko commented Aug 24, 2017

The same problemm:
2017-08-24 15-51-04
The code below working with bootstrap 4.0.0-alpha.6, but not working with bootstrap 4.0.0-beta
2017-08-24 15-59-08
The solution below not working with bootstrap 4.0.0-beta, but not checked in alpha
2017-08-24 16-00-11

@Andrew-Dyachenko
Copy link

Andrew-Dyachenko commented Aug 25, 2017

@mdo @judowalker I found the source of the problem. The fact is that in the file /node_modules/bootstrap/scss/_tables.scss the function call comes with a hard binding to the argument, which we re-recorded when the file was customized /node_modules/bootstrap/scss/_variables.scss via /node_modules/bootstrap/scss/_custom.scss. All that is required to FIX it is to do a relative binding in the argument of the function, or simply change argument "In my case from md to m"

_tables

I hope it will help to improve it

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

No branches or pull requests

4 participants