
Security News
Rust RFC Proposes a Security Tab on crates.io for RustSec Advisories
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.
@humblebee/styled-components-breakpoint
Advanced tools
Utility functions for creating breakpoints in styled-components.
This library provides utility functions for dealing with media queries, to make them reusable and easier to read. It can be used as an alternative to SASS/LESS mixins.
More on mixins and Styled Components in this article.
yarn install @humblebee/styled-components-breakpoint
# or
npm install @humblebee/styled-components-breakpoint
The default export of styled-components-breakpoint is a function that accepts a config object of breakpoints. This will return an object with three main utility methods/mixins: up (min-width), down (max-width) and only (a range between two media queries), all described in detail below.
import styledBreakpoint from '@humblebee/styled-components-breakpoint';
// Creates an object with breakpoint utility methods.
export const breakpoint = styledBreakpoint({
xxs: 0,
xs: 320,
s: 576,
m: 768,
l: 992,
xl: 1200,
});
breakpoint.up('m')
// Will return a media query with a min-width of 768
// @media only screen and (min-width: 768px)
breakpoint.down('m')
// Will return a media query with a max-width of 768
// @media only screen and (max-width: 768px)
breakpoint.only('m')
// Will return a range media query between "m" and the next upper breakpoint "l"
// @media only screen and (min-width: 768px) and (max-width: 1200px)
breakpoint.only('m', 'xl')
// Will return a range media query between "m" and the breakpoint passed as the second argument, "xl"
// @media only screen and (min-width: 768px) and (max-width: 1200px)
There is also a shorthand for mobile first media queries (min-width). Calling breakpoint.m is the same as breakpoint.up('m').
breakpoint.m
// Will return a media query with a min-width of 768
// @media only screen and (min-width: 768px)
In the following example we create a styled button component.
This is the folder structure we'll be working with.
.
+--components
| +--Button.js
+--themes
| +--mixins.js
themes/mixins.js
import styledBreakpoint from '@humblebee/styled-components-breakpoint';
// Create an instance of styled-components-breakpoint and pass it an object of breakpoints.
export const breakpoint = styledBreakpoint({
xs: 320,
s: 576,
m: 768,
l: 992,
xl: 1200,
});
components/Button.js
// Styled Components
import styled from 'styled-components';
// Our breakpoint instance/mixin
import { breakpoint } from '../../theme/mixins';
const Button = styled.button`
background: white;
font-size: 18px;
${breakpoint.down('s')}`
font-size: 12px;
`
${breakpoint.m}`
background: palevioletred;
`
`
});
The first mixin breakpoint.down('s'), will give the styled button component a font size of 12px, at a breakpoint bellow "s", i.e. max-width(320px).
The second mixin breakpoint.m, uses the short hand version of breakpoint.up.('m'), and will give the button a background of palevioletred, at a breakpoint above "m", i.e. min-width(768).
Happy coding!
/ The bees at Humblebee đ
FAQs
Utility functions for creating breakpoints in styled-components.
We found that @humblebee/styled-components-breakpoint demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.

Security News
/Research
Socket found a Rust typosquat (finch-rust) that loads sha-rust to steal credentials, using impersonation and an unpinned dependency to auto-deliver updates.

Research
/Security Fundamentals
A pair of typosquatted Go packages posing as Googleâs UUID library quietly turn helper functions into encrypted exfiltration channels to a paste site, putting developer and CI data at risk.