Skip to content

Commit

Permalink
Add column utilities (#5457)
Browse files Browse the repository at this point in the history
Co-Authored-By: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-Authored-By: Cody <codytooker@gmail.com>
  • Loading branch information
3 people authored Sep 9, 2021
1 parent 688357f commit 12fa78b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ export let appearance = ({ addUtilities }) => {
})
}

export let columns = createUtilityPlugin('columns', [['columns', ['columns']]])

export let gridAutoColumns = createUtilityPlugin('gridAutoColumns', [
['auto-cols', ['gridAutoColumns']],
])
Expand Down
28 changes: 28 additions & 0 deletions stubs/defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ module.exports = {
pink: colors.pink,
rose: colors.rose,
}),
columns: {
auto: 'auto',
1: '1',
2: '2',
3: '3',
4: '4',
5: '5',
6: '6',
7: '7',
8: '8',
9: '9',
10: '10',
11: '11',
12: '12',
'3xs': '16rem',
'2xs': '18rem',
xs: '20rem',
sm: '24rem',
md: '28rem',
lg: '32rem',
xl: '36rem',
'2xl': '42rem',
'3xl': '48rem',
'4xl': '56rem',
'5xl': '64rem',
'6xl': '72rem',
'7xl': '80rem',
},
spacing: {
px: '1px',
0: '0px',
Expand Down
6 changes: 6 additions & 0 deletions tests/arbitrary-values.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@
--tw-skew-y: 3px;
transform: var(--tw-transform);
}
.columns-\[20\] {
columns: 20;
}
.columns-\[var\(--columns\)\] {
columns: var(--columns);
}
.grid-cols-\[200px\2c repeat\(auto-fill\2c minmax\(15\%\2c 100px\)\)\2c 300px\] {
grid-template-columns: 200px repeat(auto-fill, minmax(15%, 100px)) 300px;
}
Expand Down
1 change: 1 addition & 0 deletions tests/arbitrary-values.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<div class="max-h-[var(--height)]"></div>
<div class="space-x-[20cm]"></div>
<div class="space-x-[calc(20%-1cm)]"></div>
<div class="columns-[20] columns-[var(--columns)]"></div>
<div class="grid-cols-[200px,repeat(auto-fill,minmax(15%,100px)),300px]"></div>
<div class="lg:grid-cols-[200px,repeat(auto-fill,minmax(15%,100px)),300px]"></div>
<div class="grid-rows-[200px,repeat(auto-fill,minmax(15%,100px)),300px]"></div>
Expand Down
6 changes: 6 additions & 0 deletions tests/basic-usage.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@
.appearance-none {
appearance: none;
}
.columns-1 {
columns: 1;
}
.columns-md {
columns: 28rem;
}
.auto-cols-min {
grid-auto-columns: min-content;
}
Expand Down
1 change: 1 addition & 0 deletions tests/basic-usage.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<div class="font-medium"></div>
<div class="gap-x-2 gap-y-3 gap-4"></div>
<div class="from-red-300 via-purple-200 to-blue-400"></div>
<div class="columns-1 columns-md"></div>
<div class="auto-cols-min"></div>
<div class="grid-flow-row"></div>
<div class="auto-rows-max"></div>
Expand Down

0 comments on commit 12fa78b

Please sign in to comment.