@fuzzco/smart-columns
v1.0.1
Published
Columns using display: grid and CSS vars.
Downloads
9
Readme
Make columns that flow like this:
item one item four
item two item five
item three
with CSS like this:
.your-list {
display: grid;
grid-template-rows: repeat(var(--row-count), auto);
grid-auto-flow: column;
}
Install
NPM
npm install smart-columns
In your JS:
import smartColumns from 'smart-columns' smartColumns()
Script include
- In your HTML:
<script src="//unpkg.com/@fuzzco/smart-columns"></script> <script type="text/javascript"> smartColumns() </script>
Options
smartColumns({
// number of columns. default 2
columns: 2,
// CSS selector. default 'ol, ul'
selector: 'ol, ul'
})
smartColumns
sets a var called --row-count
on each element it finds with the given selector
. Run smartColumns
again whenever the content changes to recalculate.
Todo
- Update when content changes - some kind of watcher?