Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@ghostgroup/grid-styled
Advanced tools
Responsive React grid system built with styled-components
npm i @ghostgroup/grid-styled
import React from 'react'
import { Flex, Box } from 'grid-styled'
const App = () => (
<Flex>
<Box width={1/2} px={2}>
Half width
</Box>
<Box width={1/2} px={2}>
Half width
</Box>
</Flex>
)
// Different widths at different breakpoints
<Box
width={[
1/2,
1/3,
1/4,
1/6
]}
/>
// Fixed pixel width
<Box width={256} />
// CSS value width
<Box width='40em' />
// Padding
<Box p={2} />
// Padding top
<Box pt={2} />
// Padding bottom
<Box pb={2} />
// Padding left
<Box pl={2} />
// Padding right
<Box pr={2} />
// x-axis padding (left and right)
<Box px={2} />
// y-axis padding (top and bottom)
<Box py={2} />
// Margin
<Box m={2} />
// Margin top
<Box mt={2} />
// Margin bottom
<Box mb={2} />
// Margin left
<Box ml={2} />
// Margin right
<Box mr={2} />
// x-axis margin (left and right)
<Box mx={2} />
// y-axis margin (top and bottom)
<Box my={2} />
// margin auto
<Box m='auto' />
// negative margins
<Box mx={-2} />
// Display inline-block grid
import { InlineBox } from 'grid-styled'
<div>
<InlineBox width={1/2}>Half</InlineBox>
<InlineBox width={1/2}>Half</InlineBox>
</div>
// Display grid of items
import { Grid } from 'grid-styled'
<div>
<Grid gridColumns={[2, 4, 6]} gridGaps={[5, 5, 10]}>
// grid items
</Grid>
</div>
<Box />
The Box component handles width, margin and padding.
width
(number|string|array)Sets width, where numbers 0-1
are percentage values, larger numbers are pixel values, and strings are raw CSS values with units.
Pass an array to set different widths at different breakpoints for
responsive styles.
Both margin and padding props accept numbers, strings, and arrays as values.
Using a number from 0-4
will reference a step on the spacing scale.
Larger numbers are converted to pixel values.
Negative Numbers can be used to set negative margins and compensate for grid gutters.
Strings are passed directly for other valid CSS values.
Use array values to set different margin or padding values per breakpoint for responsive styles.
Margin and padding props follow a shorthand syntax for specifying direction.
m
: marginmt
: margin-topmr
: margin-rightmb
: margin-bottomml
: margin-leftmx
: margin-left and margin-rightmy
: margin-top and margin-bottomp
: paddingpt
: padding-toppr
: padding-rightpb
: padding-bottompl
: padding-leftpx
: padding-left and padding-rightpy
: padding-top and padding-bottomflex
(string|array)Sets the flex
property.
<Box flex='1 1 auto' />
order
(number|string|array)Sets the order
property.
<Box order={2} />
is
(Component|string)Sets the underlying HTML element.
<Box is='section' />
<Flex />
The Flex component extends the Box component and sets display flex. It also includes the following props:
alignItems
(string|array) sets align-items
justifyContent
(string|array) sets justify-content
flexDirection
(string|array) sets flex-direction
flexWrap
(boolean|array) sets flex-wrap: wrap
column
(boolean) shortcut for flex-direction: column
<Grid />
The Grid component is a container that can be used to style a set of children into a grid with css-grid. It sets display grid and includes the following props:
gridColumns
(string|array) sets number of columns using grid-template-columns
gridGaps
(string|array) sets grid-gap
Most props accept arrays as values for mobile-first responsive styles, where the first value is for all breakpoints, then each value after is for a min-width media query from that breakpoint and up. The Box component uses styled-system for these props.
// 100% below the smallest breakpoint,
// 50% from the next breakpoint and up,
// and 25% from the next breakpoint and up
<Box w={[ 1, 1/2, 1/4 ]} />
// responsive margin
<Box m={[ 1, 2, 3, 4 ]} />
// responsive padding
<Box p={[ 1, 2, 3, 4 ]} />
Using styled-components, you can customize any of the grid-styled components' styles.
// Example
import styled from 'styled-components'
import { Flex } from 'grid-styled'
const InlineFlex = styled(Flex)`
display: inline-flex;
`
// Example
import styled from 'styled-components'
import { Box } from 'grid-styled'
const Container = styled(Box)`
max-width: 1024px;
margin-left: auto;
margin-right: auto;
`
Components can also be extended with React. This example creates components for a grid with set gutters where the columns expand to fill in the space.
// Example
import React from 'react'
import { Flex, Box } from 'grid-styled'
const Row = props => (
<Flex
{...props}
mx={-3}
/>
)
const Column = props => (
<Box
{...props}
px={3}
flex='1 1 auto'
/>
)
Grid Styled uses smart defaults, but to customize the values,
use styled-components’ ThemeProvider
component.
import React from 'react'
import { ThemeProvider } from 'styled-components'
const App = () => (
<ThemeProvider
theme={{
space: [ 0, 6, 12, 18, 24 ],
breakpoints: [ 32, 48, 64 ]
}}>
<div>
<Grid>Grid with custom spacing scale and breakpoints</Grid>
</div>
</ThemeProvider>
)
The Grid component uses a mobile-first responsive approach,
where any value set works from that breakpoint and wider.
Breakpoints are hard-coded to the following min-widths: 40em
, 52em
, 64em
.
To customize, provide an array of numbers that will be converted to ems.
Grid Styled components' margin and padding props use a 4 step spacing scale to help keep things aligned and keep layouts consistent.
The default scale is based on an 8px/powers-of-two grid: [ 0, 8, 16, 32, 64 ]
,
which helps keep spacing consistent and elements aligned even when nesting components.
FAQs
Responsive React grid system built with styled-components
The npm package @ghostgroup/grid-styled receives a total of 0 weekly downloads. As such, @ghostgroup/grid-styled popularity was classified as not popular.
We found that @ghostgroup/grid-styled demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 62 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.