Skip to content

Commit 85ea38b

Browse files
committed
Add ability to configure background position utilities
1 parent ba86cb3 commit 85ea38b

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
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-positions
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
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +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-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' },
4+
export default function({ backgroundPosition }) {
5+
return _.map(backgroundPosition, (position, className) => {
6+
return defineClass(`bg-${className}`, {
7+
'background-position': position,
8+
})
149
})
1510
}

0 commit comments

Comments
 (0)