Comments (15)
Hi @Dotmagic, I'm not an expert... but I made some experiments about this.
You can overwrite mdc breakpoints map declaration (of course, using sass).
Breakpoints map is assigned to $mdc-layout-grid-breakpoints
variable on file packages/mdc-layout-grid/_variables.scss
with !default
flag. So this assignment will only take effect if it's not declared yet.
To use custom breakpoints you may declare your custom $mdc-layout-grid-breakpointsthis
map before @import
ing the mdc stylesheet. In this way mixins will use your declaration instead de default one.
Take a look at the packages/mdc-layout-grid/_variables.scss
and you'll find:
$mdc-layout-grid-breakpoints: (
desktop: 840px,
tablet: 480px,
phone: 0px
) !default;
If you want use a bootstrap like breakpoints, just declare $mdc-layout-grid-breakpoints
before the @import 'material-components-web/material-components-web'
or @import '@material/mdc-layout-grid'
$mdc-layout-grid-breakpoints: (
largedesktop: 1200px,
desktop: 992px,
tablet: 768px,
largephone: 576px,
phone: 0px
);
@import 'material-components-web/material-components-web';
@media (min-width: mdc-layout-grid-breakpoint-min(desktop)) { //992px
...
}
from material-components-web.
Direct classes to hide things aren't exactly the style for MCW. Perhaps the grid will have them, but there are still other places where these helpers are useful. Which is why we want a component to provide these internally via Sass to be easily re-used everywhere in a MCW project.
Providing hidden-xs
type classes "like Bootstrap" is not a focus point for the library. MCW is not trying to be a framework to do everything for developers. That's a "utility only" type class which doesn't fit with what is trying to be provided.
The goal isn't to be a framework and do a lot of little functions for developers. It's simply to provide the Material Design Specification's components to the web in a re-usable way. That's it. Anything that is beyond that goes beyond the scope of what the project is trying to achieve.
from material-components-web.
@Garbee But If i take a look at https://material.io/guidelines/layout/responsive-ui.html#responsive-ui-breakpoints there's much more. It just can't be enough to build a UI for large screens and the largest breakpoint ist 840px. Imagine someone likes to build a app for a TV, nowadays 42-55" screens with 4K become quite common. And using device names.... its just a bad idea
from material-components-web.
We implemented our own version of this for mdc-layout-grid
specifically, based on other suggestions in this issue and others:
@use "sass:map";
@use "@material/layout-grid/mdc-layout-grid";
@use "@material/layout-grid/variables" as grid-variables;
@use "@material/layout-grid/mixins" as grid-mixins;
@each $size in map.keys(grid-variables.$columns) {
@include grid-mixins.media-query_($size) {
.mdc-layout-grid__cell--span-0-#{$size} {
display: none;
}
}
}
You can then use:
mdc-layout-grid__cell-span-0-phone
mdc-layout-grid__cell-span-0-tablet
mdc-layout-grid__cell-span-0-desktop
from material-components-web.
Any update on this? Very important for material-components-web to be a viable library.
from material-components-web.
What's the core team up to in the contributing guide explains how to see what is being worked on in more detail. In this case, the pivotal issue is assigned to the early-January 2018 sprint. So it isn't even being looked at until around the time this sprint will start unless it gets moved up.
If someone from the community wants to jump in and work on this sooner then they are more then welcome to. All you need to do is follow the contributing guide on building components.
Thank you.
from material-components-web.
What do you exactly mean with "SASS/style helpers for responsive breakpoints" ?
Why a global library instead a suggested mdc-layout-grid__cell--phone-hide
or like the bootstrap hidden-xs
?
from material-components-web.
I well know MCW isn't trying to be a framework, if I would a framework I would know where to look, but, since in guidelines there isn't the concept of hide, for example, grid cells on breakpoints, so what kind of SASS/style library are you thinking ?
I don't understand in what other places you could get benefit hiding things: any other component should be, by guidelines, into a (layout) grid.
Moreover, hide things in a web page it's never a great solution in complex layouts, because components still remain into DOM though hidden; so my opinion is that a "simple & quick" useful way could be allow/demand layout grid to do the job.
from material-components-web.
A way to re-use breakpoints across components without redefining the breakpoints in each one. Such as by using custom media queries. This way all packages are uniformly using the same breakpoints and as things are updated keeping consistent between packages is much easier.
It isn't necessarily to only hide/show things (although css hidden is just fine in most cases when needed) but simply to set breakpoints needed for different component actions.
from material-components-web.
Instead hidden-??
utility, I miss more breakpoints for mdc-layout-grid
The problem with custom media query to hide/show some element we can solve importing layout-grid/_mixins.scss
to reuse the existing mdc breakpoints (of course, using sass).
@import 'node_modules/@material/layout-grid/variables';
@import 'node_modules/@material/layout-grid/mixins';
@media (min-width: mdc-layout-grid-breakpoint-min(desktop)) {
...
}
But I think that existing three breakpoints are few, particularly in relation to desktop
. 12-columns is ok, but 840px for desktop I think it's small. For example: I would like different columns qty/spans above 1200px.
Best,
Pablo
from material-components-web.
@pablobender I'm using mdc-layout-grid-breakpoint-min
too. But just 3 breakpoints isn't enough. Tablet starts already at 480px, I'm doing anything wrong?
from material-components-web.
@pablobender Thanks. In the meantime I've found out just the same, its a configurable sass map.
However. I still dislike the default names for breakpoints! We've learned its bad practice to create media queries for DEVICES. I always tried to build websites for various screen sizes supporting all kind of input devices. I think this is the preferred approach. Of course, it's still possible to build such a site with material, but it would be much more nice to have breakpoint names like: xsmall, small, medium, large, xlarge
from material-components-web.
The names come directly from the material design specification. Hence why they are used. It allows someone to look at the implementation compared the spec and easily see changes.
from material-components-web.
The 3 breakpoints completely suffice for a grid system, since it only needs to set the number of columns.
(The number of columns only have 3 variants, viz 4, 8 and 12. )
For fine tuning though, we definitely need all the breakpoints in the spec.
from material-components-web.
While @adamsproul's solution works, are there any updates on this? It's 2023
from material-components-web.
Related Issues (20)
- Angular Material Tabs with sticky first tab
- The getting started guide: issues HOT 1
- [mdc-icon-button] unable to import core-styles mixin of icon-button as shown in documentation
- Unpkg: Source map for minified JS missing HOT 1
- MDCTopAppBar buttons ripple effect broken since 12.0.0 HOT 2
- Hi, I can't make a frame for the drawer, it's a problem
- Symmetric API for the Angular Material Icon Button HOT 1
- [MDCTextField] Trailing icons do not appear HOT 1
- the problem in running the program HOT 1
- [mdc-chip] css not applied to mdc-evolution-chip elements HOT 3
- Is there anyway we can force the dropdown select to always show below?
- [Chips] Filter chips not showing svg tick HOT 1
- `setAutovalidate()`/`getAutovalidate` name mismatch in readme
- Vertical mat-slider
- [mdc-theme] Contradicting advice on purpose of `$secondary`
- [Snackbar] screenreader leaves out "button" when reading message and action
- Tag for the version 14.1.0 is missing
- The release 14.1.0 isn't published on npmjs HOT 1
- Tone should work with css-variables
- [ALL] NPM packages are missing file extensions in ES6 exports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-components-web.