Skip to content

Commit

Permalink
Merge branch 'benface-issue/608'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Feb 7, 2019
2 parents 8aabccb + f69e02c commit 407d849
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
27 changes: 27 additions & 0 deletions defaultConfig.stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,33 @@ module.exports = {
backgroundColors: colors,


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

backgroundPosition: {
'bottom': 'bottom',
'center': 'center',
'left': 'left',
'left-bottom': 'left bottom',
'left-top': 'left top',
'right': 'right',
'right-bottom': 'right bottom',
'right-top': 'right top',
'top': 'top',
},


/*
|-----------------------------------------------------------------------------
| Background sizes https://tailwindcss.com/docs/background-size
Expand Down
28 changes: 14 additions & 14 deletions src/plugins/backgroundPosition.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import _ from 'lodash'

export default function() {
return function({ addUtilities, config }) {
addUtilities(
{
'.bg-bottom': { 'background-position': 'bottom' },
'.bg-center': { 'background-position': 'center' },
'.bg-left': { 'background-position': 'left' },
'.bg-left-bottom': { 'background-position': 'left bottom' },
'.bg-left-top': { 'background-position': 'left top' },
'.bg-right': { 'background-position': 'right' },
'.bg-right-bottom': { 'background-position': 'right bottom' },
'.bg-right-top': { 'background-position': 'right top' },
'.bg-top': { 'background-position': 'top' },
},
config('modules.backgroundPosition')
return function({ addUtilities, config, e }) {
const utilities = _.fromPairs(
_.map(config('backgroundPosition'), (value, modifier) => {
return [
`.${e(`bg-${modifier}`)}`,
{
'background-position': value,
},
]
})
)

addUtilities(utilities, config('modules.backgroundPosition'))
}
}

0 comments on commit 407d849

Please sign in to comment.