Comments (11)
@iRyanBell maybe these videos will help you think mobile first.
video
book
I'm totally on board with a mobile-first mindset for cascading styles by additive viewport width.
My complaint here was largely around the naming convention of up(Md)
meaning "greater than the 'md' width definition", while down(Md)
translates non-symmetrically to "less than next higher definition after 'md'" -- I get the logic behind this model, seeing breakpoints as ranges, but I would prefer a more precise interpretation.
from styled-breakpoints.
@iRyanBell, good time. Thanks for using style-breakpoints. All of the above problems only arise because you ignore the mobile first approach. The existing api is enough to cover all your needs.
from styled-breakpoints.
Can you elaborate more on the mobile first approach?
It's not quite clear to me why
up('md')
is relative to md (up from md). Anddown('md')
performs down from lg.
Mobile first - from smallest to largest.
Desktop first - from largest to smallest.
from styled-breakpoints.
@iRyanBell "Desktop first" has many drawbacks. If following the "mobile first" principle you add the functionality you need, then in "desktop first" you need to hide what you already have and you constantly have to write display: none;
from styled-breakpoints.
@iRyanBell maybe these videos will help you think mobile first.
video
book
from styled-breakpoints.
Can you elaborate more on the mobile first approach?
It's not quite clear to me why up('md')
is relative to md (up from md). And down('md')
performs down from lg.
from styled-breakpoints.
@iRyanBell if you have any difficulties with solving existing problems, please send a link with an example code to codesandbox / stackblitz. I will gladly help you.
from styled-breakpoints.
@iRyanBell if you have any difficulties with solving existing problems, please send a link with an example code to codesandbox / stackblitz. I will gladly help you.
How would you ideally query down from sm
(ie. a width no greater than a max value of 576px), given the breakpoints definition of:
{
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
}
from styled-breakpoints.
@iRyanBell take a look at this example.
from styled-breakpoints.
@iRyanBell take a look at this example.
Ah, I see what you mean now by the mobile first approach! That works, just using up
which references the supplied breakpoint rather than trying to use down
which picks a different breakpoint value.
So, from this perspective, you can't write a media query < sm (or your lowest breakpoint) with down
as a sort of "it's a feature, not a bug" mentality. Closing as resolved. Although, I still like the idea of a down by referenced breakpoint rather than the next-higher breakpoint by index.
from styled-breakpoints.
@iRyanBell, I understand you, but I didn’t come up with the names for these functions myself. The styled-breakpoints API completely copies the media query api from bootstrap (145k stars). So we can say with complete confidence that this is the standard for the industry. Yes, English is not my first language, but bootstrap was invented in San Francisco. For some reason, I have no doubts about the correctness of the name.)) Thanks again for your interest.)) Perhaps, to fix the problem with down, you need to add another breakpoint
xs: '0px',
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
}
similar to Zurb Foundation media queries.
Then your problem will be solved. Hmm ... Perhaps this is a great reason to think.
from styled-breakpoints.
Related Issues (20)
- next: replace `createTheme` with `createStyledBreakpointsTheme`
- next: add strict types for functions for `theme`
- bug(up): `0px` cannot be assigned as minimum breakpoint
- revert to v11.1.2
- feat(down): add validation for last breakpoint HOT 2
- refactor(core): validation
- refactor(core): need to rewrite using the object composition approach
- fix(down): passing the last breakpoint should not throw an exception
- fix(between): remove incorrect validation for the minimum value
- fix(only): remove incorrect validation for the minimum breakpoint
- refactor(core): need to remove remove `Object.entries` in `throwIfInvalidBreakpoints` function
- ci(gh-actions): add alpha & beta branches to the release.yml
- next: rewrite breakpoints HOT 1
- next: remove functions up, down, between, only from external api
- Customizing breakpoints throws undefined error HOT 1
- docs: Need to reorganize the documentation structure
- docs: remove legacy types
- docs: add latest version
- Cannot find module 'styled-breakpoints/use-media-query' HOT 3
- How to configure breaking points for multiple themes? HOT 1
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 styled-breakpoints.