Skip to content

Commit 77e350c

Browse files
committed
Merge branch 'hacknug-feature/backgroundSizes' into 0.5
2 parents ec804ca + 290bafd commit 77e350c

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

__tests__/fixtures/tailwind-output.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,10 @@ button,
12951295
background-repeat: repeat-y;
12961296
}
12971297

1298+
.bg-auto {
1299+
background-size: auto;
1300+
}
1301+
12981302
.bg-cover {
12991303
background-size: cover;
13001304
}
@@ -5182,6 +5186,10 @@ button,
51825186
background-repeat: repeat-y;
51835187
}
51845188

5189+
.sm\:bg-auto {
5190+
background-size: auto;
5191+
}
5192+
51855193
.sm\:bg-cover {
51865194
background-size: cover;
51875195
}
@@ -9062,6 +9070,10 @@ button,
90629070
background-repeat: repeat-y;
90639071
}
90649072

9073+
.md\:bg-auto {
9074+
background-size: auto;
9075+
}
9076+
90659077
.md\:bg-cover {
90669078
background-size: cover;
90679079
}
@@ -12942,6 +12954,10 @@ button,
1294212954
background-repeat: repeat-y;
1294312955
}
1294412956

12957+
.lg\:bg-auto {
12958+
background-size: auto;
12959+
}
12960+
1294512961
.lg\:bg-cover {
1294612962
background-size: cover;
1294712963
}
@@ -16822,6 +16838,10 @@ button,
1682216838
background-repeat: repeat-y;
1682316839
}
1682416840

16841+
.xl\:bg-auto {
16842+
background-size: auto;
16843+
}
16844+
1682516845
.xl\:bg-cover {
1682616846
background-size: cover;
1682716847
}

defaultConfig.stub.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,26 @@ module.exports = {
360360
backgroundColors: colors,
361361

362362

363+
/*
364+
|-----------------------------------------------------------------------------
365+
| Background sizes https://tailwindcss.com/docs/background-size
366+
|-----------------------------------------------------------------------------
367+
|
368+
| Here is where you define your background sizes. We provide some common
369+
| values that are useful in most projects, but feel free to add other sizes
370+
| that are specific to your project here as well.
371+
|
372+
| Class name: .bg-{size}
373+
|
374+
*/
375+
376+
backgroundSize: {
377+
'auto': 'auto',
378+
'cover': 'cover',
379+
'contain': 'contain',
380+
},
381+
382+
363383
/*
364384
|-----------------------------------------------------------------------------
365385
| Border widths https://tailwindcss.com/docs/border-width

src/generators/backgroundSize.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import defineClasses from '../util/defineClasses'
1+
import _ from 'lodash'
2+
import defineClass from '../util/defineClass'
23

3-
export default function() {
4-
return defineClasses({
5-
'bg-cover': {
6-
'background-size': 'cover',
7-
},
8-
'bg-contain': {
9-
'background-size': 'contain',
10-
},
4+
export default function({ backgroundSize }) {
5+
return _.map(backgroundSize, (size, className) => {
6+
return defineClass(`bg-${className}`, {
7+
'background-size': size,
8+
})
119
})
1210
}

0 commit comments

Comments
 (0)