Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
grid-template-utils
Advanced tools
Yarn:
$ yarn add grid-template-utils
npm:
$ npm install --save grid-template-utils
Include with a module bundler like rollup or webpack:
// using ES6 modules
import { parse, combine, getSizeAtTrack } from 'grid-template-utils'
// using CommonJS modules
var utils = require('grid-template-utils')
The UMD build is also available on unpkg:
<script src="https://unpkg.com/grid-template-utils/dist/grid-template-utils.js"></script>
You can find the library on window.GridTemplateUtils
.
import { parse, combine, getSizeAtTrack } from 'grid-template-utils'
> parse('1fr 10px 1fr')
[
{
value: '1fr',
type: 'fr',
numeric: 1,
},
{
value: '10px',
type: 'px',
numeric: 10,
},
{
value: '1fr',
type: 'fr',
numeric: 1,
},
]
> combine('1fr 10px 1fr', [,{ value: '20px' }])
'1fr 20px 1fr'
> getSizeAtTrack(1, parse('10px 10px 10px'))
20
> getSizeAtTrack(1, parse('10px 10px 10px'), 20)
40
Track { value: string, type: 'fr' | 'px' | '%' | 'auto', numeric: number }
Object describing CSS values for a single track in a grid template.
parse(rule: string) => Track[]
Parses a grid-template-rows
or grid-template-columns
CSS rule to
an array of Track
objects with value
, type
and numeric
keys.
combine(rule: string, tracks: Track[]) => string
Updates a CSS rule with values from an array of Track
objects. The array can be sparse,
only included indices will be updated. If Track.value
is specified,
that string value will be used directly. If not, Track.numeric
and Track.type
are
joined before interpolation.
getSizeAtTrack(index: number, tracks: Track[], gap?: number = 0, end?: boolean = false) => number
Returns the pixel size measured from the start of the grid layout up to the track
specified by index
. Each Track.numeric
value should be a px
value
(for example, as returned by parse(getComputedStyle())
).
Optional argument gap
is the pixel size of grid-gap
. Optional agrument end
is a flag that determines whether to measure up to the start or end of the track.
Defaults to false
(measure to the start of the track).
Copyright (c) 2018 Nathan Cahill
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Utility functions for working with grid templates
The npm package grid-template-utils receives a total of 6 weekly downloads. As such, grid-template-utils popularity was classified as not popular.
We found that grid-template-utils 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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.