Skip to content

Commit

Permalink
Merge pull request tailwindlabs#676 from hacknug/feature/customize-ob…
Browse files Browse the repository at this point in the history
…jectPosition

Allow users to customize objectPostions
  • Loading branch information
adamwathan authored Feb 21, 2019
2 parents 33c91e1 + 1bddb25 commit 9a5e0ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
11 changes: 11 additions & 0 deletions defaultTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ module.exports = function() {
padding: theme => theme.spacing,
margin: theme => ({ auto: 'auto', ...theme.spacing }),
negativeMargin: theme => theme.spacing,
objectPosition: {
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',
},
boxShadow: {
default: '0 2px 4px 0 rgba(0,0,0,0.10)',
md: '0 4px 8px 0 rgba(0,0,0,0.12), 0 2px 4px 0 rgba(0,0,0,0.08)',
Expand Down
30 changes: 15 additions & 15 deletions src/plugins/objectPosition.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export default function({ variants }) {
return function({ addUtilities }) {
addUtilities(
{
'.object-bottom': { 'object-position': 'bottom' },
'.object-center': { 'object-position': 'center' },
'.object-left': { 'object-position': 'left' },
'.object-left-bottom': { 'object-position': 'left bottom' },
'.object-left-top': { 'object-position': 'left top' },
'.object-right': { 'object-position': 'right' },
'.object-right-bottom': { 'object-position': 'right bottom' },
'.object-right-top': { 'object-position': 'right top' },
'.object-top': { 'object-position': 'top' },
},
variants
import _ from 'lodash'

export default function({ values, variants }) {
return function({ addUtilities, e }) {
const utilities = _.fromPairs(
_.map(values, (value, modifier) => {
return [
`.${e(`object-${modifier}`)}`,
{
'object-position': value,
},
]
})
)

addUtilities(utilities, variants)
}
}

0 comments on commit 9a5e0ea

Please sign in to comment.