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.
Low config layout components for React.
View the storybook demo at https://yearofthedan.github.io/layabout/
Issues and contributions are welcome. Specifics on how and the guiding philosophy are under CONTRIBUTING.md.
This is very much in alpha, so expect the api to shift a lot.
Lays out children according to a defined grid structure
Prop | Description | Options | Default |
---|---|---|---|
container | Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div ) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). | generates a div |
widths | An array of column widths | String values will be mapped directly to css so feel free to use things like minmax(). If an integer is given it will be mapped as an fr unit. | ['auto'] |
heights | An array of row heights | String values will be mapped directly to css so feel free to use things like minmax(). If an integer is given it will be mapped as an fr unit. | ['auto'] |
columnGap | The gap or gutter between each column | A string property to be mapped directly as css (eg.4px ) | none |
rowGap | The gap or gutter between each row | A string property to be mapped directly as css (eg.4px ) | none |
style | Style properties to be applied to the container. This particularly supports use cases where you're combining layout components. | A style object | none |
layout | A template expressing the entries in the grid. See below for some advice on use | A multiline string where each line represents one row in the grid and each line contains the list of elements at each column position. Use the child component name, or a . to denote an empty cell. If a component is named multiple times it means that the component takes up multiple cells. | Empty layout, meaning the children will flow into the provided column and row structure defined by the widths and heights props |
Any other props are passed through to the container.
Hey! Some things to think about with the layout prop The magic of Grid is in the binding between the template as described in the layout prop and the children.
If you have multiple same named elements - lets us div as an example - as children there's no way to define different div sections in the template since you should just write 'div'. To avoid this you should wrap them in a uniquely named component (nb. this is more semantic anyway). Alternatively, you can just not use the template prop, in which case the elements will just flow across the rows and columns.
fromComponents
for safetyThe renderer will try to connect the display name of the element to the token in the layout string.
A few things can interfere here, particularly minimisation steps in your build which may mean that the child elements display name is no longer the same as what you wrote in the template.
To get around this you can import and use fromComponents
and refer to the components in the template directly. This will map any provided components to their actual display name at run time.
import {fromComponents} from 'layabout';
<Grid
widths={[1, 4, 1]}
heights={['100px', 'minmax(100px, 200px)', '100px', 'auto', '50px']}
layout={fromComponents`
${MenuHeader} ${MenuHeader} ${MenuHeader}
. ${LogoSection} .
. ${Search} .
. . .
${Footer} ${Footer} ${Footer}
`}
container={Page}
>
<MenuHeader />
<LogoSection />
<Search />
<Footer />
</Grid>
Lays out its children one by one according to a set of relative sizes. Overflow continues onto the new row/column, following the same template.
Prop | Description | Options | Default |
---|---|---|---|
sizes | Set of relative weights for the amount of space available to children on a row | An array of numbers for the row | Children will share available space equally |
container | Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div ) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). | generates a div |
alignCrossAxis | How to align content on the cross axis | start ,middle , end | middle |
style | Style properties to be applied to the container. This particularly supports use cases where you're combining layout components. | A style object | none |
<FlexRow
sizes={[2, 4, 4]} container={Article}>
<section />
<section />
<section />
</FlexRow>
In the example above the sections would have spacing of 2/10ths, 4/10ths, and 4/10ths of the total available width.
Lays out children within the space available. Any remaining spacing is allocated according to the spacing prop.
Prop | Description | Options | Default |
---|---|---|---|
spacing | How to allocate remaining space | between , around , start , middle , end | between |
container | Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div ) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). | generates a div |
alignCrossAxis | How to align content on the cross axis | start , middle , end | middle |
style | Style properties to be applied to the container. This particularly supports use cases where you're combining layout components. | A style object | none |
<SpacedRow spacing="between" container={MyCustomContainer}>
<section />
<section />
<section />
</SpacedRow>
FAQs
Simple layout components for React
The npm package layabout receives a total of 2 weekly downloads. As such, layabout popularity was classified as not popular.
We found that layabout demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.