Skip to content

Commit 407d849

Browse files
committed
Merge branch 'benface-issue/608'
2 parents 8aabccb + f69e02c commit 407d849

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

defaultConfig.stub.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,33 @@ module.exports = {
367367
backgroundColors: colors,
368368

369369

370+
/*
371+
|-----------------------------------------------------------------------------
372+
| Background positions https://tailwindcss.com/docs/background-position
373+
|-----------------------------------------------------------------------------
374+
|
375+
| Here is where you define your background positions. We provide some
376+
| common values that are useful in most projects, but feel free to add
377+
| other positions that are specific to your project here as well.
378+
|
379+
| Class name: .bg-{position}
380+
| CSS property: background-position
381+
|
382+
*/
383+
384+
backgroundPosition: {
385+
'bottom': 'bottom',
386+
'center': 'center',
387+
'left': 'left',
388+
'left-bottom': 'left bottom',
389+
'left-top': 'left top',
390+
'right': 'right',
391+
'right-bottom': 'right bottom',
392+
'right-top': 'right top',
393+
'top': 'top',
394+
},
395+
396+
370397
/*
371398
|-----------------------------------------------------------------------------
372399
| Background sizes https://tailwindcss.com/docs/background-size

src/plugins/backgroundPosition.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
import _ from 'lodash'
2+
13
export default function() {
2-
return function({ addUtilities, config }) {
3-
addUtilities(
4-
{
5-
'.bg-bottom': { 'background-position': 'bottom' },
6-
'.bg-center': { 'background-position': 'center' },
7-
'.bg-left': { 'background-position': 'left' },
8-
'.bg-left-bottom': { 'background-position': 'left bottom' },
9-
'.bg-left-top': { 'background-position': 'left top' },
10-
'.bg-right': { 'background-position': 'right' },
11-
'.bg-right-bottom': { 'background-position': 'right bottom' },
12-
'.bg-right-top': { 'background-position': 'right top' },
13-
'.bg-top': { 'background-position': 'top' },
14-
},
15-
config('modules.backgroundPosition')
4+
return function({ addUtilities, config, e }) {
5+
const utilities = _.fromPairs(
6+
_.map(config('backgroundPosition'), (value, modifier) => {
7+
return [
8+
`.${e(`bg-${modifier}`)}`,
9+
{
10+
'background-position': value,
11+
},
12+
]
13+
})
1614
)
15+
16+
addUtilities(utilities, config('modules.backgroundPosition'))
1717
}
1818
}

0 commit comments

Comments
 (0)