Skip to content

Commit

Permalink
Merge branch 'hacknug-feature/backgroundSizes' into 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 12, 2018
2 parents ec804ca + 290bafd commit 77e350c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
20 changes: 20 additions & 0 deletions __tests__/fixtures/tailwind-output.css
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,10 @@ button,
background-repeat: repeat-y;
}

.bg-auto {
background-size: auto;
}

.bg-cover {
background-size: cover;
}
Expand Down Expand Up @@ -5182,6 +5186,10 @@ button,
background-repeat: repeat-y;
}

.sm\:bg-auto {
background-size: auto;
}

.sm\:bg-cover {
background-size: cover;
}
Expand Down Expand Up @@ -9062,6 +9070,10 @@ button,
background-repeat: repeat-y;
}

.md\:bg-auto {
background-size: auto;
}

.md\:bg-cover {
background-size: cover;
}
Expand Down Expand Up @@ -12942,6 +12954,10 @@ button,
background-repeat: repeat-y;
}

.lg\:bg-auto {
background-size: auto;
}

.lg\:bg-cover {
background-size: cover;
}
Expand Down Expand Up @@ -16822,6 +16838,10 @@ button,
background-repeat: repeat-y;
}

.xl\:bg-auto {
background-size: auto;
}

.xl\:bg-cover {
background-size: cover;
}
Expand Down
20 changes: 20 additions & 0 deletions defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,26 @@ module.exports = {
backgroundColors: colors,


/*
|-----------------------------------------------------------------------------
| Background sizes https://tailwindcss.com/docs/background-size
|-----------------------------------------------------------------------------
|
| Here is where you define your background sizes. We provide some common
| values that are useful in most projects, but feel free to add other sizes
| that are specific to your project here as well.
|
| Class name: .bg-{size}
|
*/

backgroundSize: {
'auto': 'auto',
'cover': 'cover',
'contain': 'contain',
},


/*
|-----------------------------------------------------------------------------
| Border widths https://tailwindcss.com/docs/border-width
Expand Down
16 changes: 7 additions & 9 deletions src/generators/backgroundSize.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import defineClasses from '../util/defineClasses'
import _ from 'lodash'
import defineClass from '../util/defineClass'

export default function() {
return defineClasses({
'bg-cover': {
'background-size': 'cover',
},
'bg-contain': {
'background-size': 'contain',
},
export default function({ backgroundSize }) {
return _.map(backgroundSize, (size, className) => {
return defineClass(`bg-${className}`, {
'background-size': size,
})
})
}

0 comments on commit 77e350c

Please sign in to comment.