Skip to content

Commit 634e0b1

Browse files
committed
Rename to ‘grid-automin` allow different units
1 parent 05f5c77 commit 634e0b1

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ In `plugins/css-grid/index.js` you'll find an example of a plugin that adds new
1111
It exposes four configuration options:
1212

1313
- `grids`, for specifying all of the grid sizes you'd like to generate
14-
- `colwidth` for applying min width for the auto-grid
1514
- `gaps`, for specifying the gap sizes you'd like to generate
15+
- `autoMinWidths` for specifying min width to columns using auto-fit and minmax
1616
- `variants`, for specifying which variants to generate
1717

1818
```js
@@ -23,12 +23,16 @@ module.exports = {
2323
// ...
2424
require('tailwindcss-grid')({
2525
grids: [2, 3, 5, 6, 8, 10, 12],
26-
colwidth: [5, 10, 15, 20], // in REM
2726
gaps: {
2827
0: '0',
2928
4: '1rem',
3029
8: '2rem',
3130
},
31+
autoMinWidths: {
32+
'16': '4rem',
33+
'24': '6rem',
34+
'300px': '300px'
35+
},
3236
variants: ['responsive'],
3337
}),
3438
],
@@ -41,11 +45,12 @@ The plugin generates the following sets of classes:
4145

4246
- `.grid`, for setting `display: grid` on an element
4347
- `.grid-columns-{size}`, for specifying the number of columns in the grid
44-
- `.auto-grid-{size}`, for specifying the minimum width of the columns generated with auto-grid
45-
- `.grid-gap-{size}`, for specifying the size of the gap between columns/rows
4648
- `.col-span-{columns}`, for specifying how wide a cell should be
49+
- `.grid-gap-{size}`, for specifying the size of the gap between columns/rows
50+
- `.grid-automin-{size}`, for applying the minimum width of the columns using auto-fit and minmax (the max is 1fr)
4751
- `.col-start-{line}` and `.col-end-{line}`, for specifying a cell's start and end points explicitly (useful for reordering cells or leaving gaps)
4852
- `.row-span-{columns}`, for specifying how tall a cell should be
4953
- `.row-start-{line}` and `.row-end-{line}`, for specifying a cell's start and end points explicitly (useful for reordering cells or leaving gaps)
54+
- `.grid-dense` applies `grid-auto-flow: dense`
5055

5156
It's not really practical to expose all of the power of CSS Grid through utilities, but this plugin is a good example of using CSS Grid to replace a cell-only float or Flexbox grid.

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
const _ = require('lodash')
22

3-
module.exports = function ({ grids = _.range(1, 12), gaps = {}, colwidth = {}, variants = ['responsive']}) {
3+
module.exports = function ({
4+
grids = _.range(1, 12),
5+
gaps = {},
6+
autoMinWidths = {},
7+
variants = ['responsive']
8+
}) {
49
return function ({ e, addUtilities }) {
510
addUtilities([
611
{ '.grid': { display: 'grid' } },
@@ -13,10 +18,10 @@ module.exports = function ({ grids = _.range(1, 12), gaps = {}, colwidth = {}, v
1318
gridTemplateColumns: `repeat(${columns}, 1fr)`,
1419
}
1520
})),
16-
...colwidth.map(gridwidth => ({
17-
[`.auto-grid-${gridwidth}`]: {
18-
gridTemplateColumns: `repeat(auto-fit, minmax(${gridwidth}rem, 1fr))`,
19-
}
21+
..._.map(autoMinWidths, (size, name) => ({
22+
[`.${e(`grid-automin-${name}`)}`]: {
23+
gridTemplateColumns: `repeat(auto-fit, minmax(${size}, 1fr))`
24+
},
2025
})),
2126
..._.range(1, _.max(grids) + 1).map(span => ({
2227
[`.col-span-${span}`]: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tailwindcss-grid",
3-
"version": "1.0.2",
3+
"version": "1.0.4",
44
"description": "CSS grid plugin for tailwindcss framework",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)