Skip to content

Commit 9dc51a8

Browse files
author
Florian Bouvot
committed
Add order utility
1 parent 0d93dc8 commit 9dc51a8

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

defaultConfig.stub.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
flex: ['responsive'],
2929
flexGrow: ['responsive'],
3030
flexShrink: ['responsive'],
31+
order: ['responsive'],
3132
float: ['responsive'],
3233
fontFamily: ['responsive'],
3334
fontWeight: ['responsive', 'hover', 'focus'],

defaultTheme.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,10 @@ module.exports = function() {
322322
'0': 0,
323323
default: 1,
324324
},
325+
order: {
326+
first: -1,
327+
last: 1,
328+
none: 0
329+
},
325330
}
326331
}

src/corePlugins.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import alignContent from './plugins/alignContent'
2222
import flex from './plugins/flex'
2323
import flexGrow from './plugins/flexGrow'
2424
import flexShrink from './plugins/flexShrink'
25+
import order from './plugins/order'
2526
import float from './plugins/float'
2627
import fontFamily from './plugins/fontFamily'
2728
import fontWeight from './plugins/fontWeight'

src/plugins/order.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import _ from 'lodash'
2+
3+
export default function({ values, variants }) {
4+
return function({ addUtilities, e }) {
5+
addUtilities(
6+
_.fromPairs(
7+
_.map(values, (value, modifier) => {
8+
const className = modifier === 'default' ? 'order' : `order-${modifier}`
9+
return [
10+
`.${e(className)}`,
11+
{
12+
'order': value,
13+
},
14+
]
15+
})
16+
),
17+
variants
18+
)
19+
}
20+
}

0 commit comments

Comments
 (0)