-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added options to describe vendor prefixing values/properties and upda…
…ted components
- Loading branch information
rofrischmann
committed
Jun 5, 2015
1 parent
90e01df
commit f91545d
Showing
18 changed files
with
220 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/node_modules/ | ||
/test/bundle.js | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var React = require('react'); | ||
var Layout = require('../core/layout'); | ||
var objectAssign = require('object-assign'); | ||
|
||
var Box = React.createClass({ | ||
render: function () { | ||
var props = this.props; | ||
var vendor = Layout.getVendorPrefix(); | ||
var vendorStyles = {}; | ||
var flex = (props.inline ? 'inline-flex' : 'flex'); | ||
var flexDir = (props.reverse ? '-reverse' : ''); | ||
var flexOrient = (props.column ? 'column' : 'row'); | ||
|
||
vendorStyles['display'] = (vendor == 'Webkit' ? '-webkit-' + flex : (vendor == 'ms' ? '-ms-' + flex + 'box' : flex)) | ||
vendorStyles['flexDirection'] = flexOrient + flexDir; | ||
|
||
props.wrap && (vendorStyles['wrap'] = 'wrap'); | ||
props.wrapReverse && (vendorStyles['wrap'] = 'wrapReverse'); | ||
|
||
var properties = ['justifyContent', 'alignItems', 'alignContent', 'flexFlow']; | ||
|
||
properties.forEach(function(item){ | ||
props[item] && (vendorStyles[item] = props[item]); | ||
}); | ||
|
||
var styles = Layout.generateStyles(vendorStyles); | ||
if (props.style){ | ||
styles = objectAssign(styles, props.style); | ||
} | ||
return <div {...props} style={styles}>{props.children}</div>; | ||
} | ||
}); | ||
|
||
module.exports = Box; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var React = require('react'); | ||
var Layout = require('../core/layout'); | ||
var objectAssign = require('object-assign'); | ||
|
||
var Item = React.createClass({ | ||
render: function () { | ||
var props = this.props; | ||
var vendorStyles = {}; | ||
props.flex && (vendorStyles['flex'] = (props.flex ? props.flex : '0 1 auto')); | ||
|
||
var properties = ['flexBasis', 'flexGrow', 'flexShrink', 'order', 'alignSelf']; | ||
|
||
properties.forEach(function (item){ | ||
props[item] && (vendorStyles[item] = props[item]); | ||
}); | ||
|
||
var styles = Layout.generateStyles(vendorStyles); | ||
if (props.style){ | ||
styles = objectAssign(styles, props.style); | ||
} | ||
return <div {...props} style={styles}>{props.children}</div>; | ||
} | ||
}); | ||
|
||
module.exports = Item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var React = require('react'); | ||
var Layout = require('../core/layout'); | ||
var objectAssign = require('object-assign'); | ||
|
||
var Page = React.createClass({ | ||
render: function () { | ||
var props = this.props; | ||
|
||
var styles ={ | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
position: 'absolute' | ||
}; | ||
|
||
if (props.style){ | ||
styles = objectAssign(styles, props.style); | ||
} | ||
return <div {...props} style={styles}>{props.children}</div>; | ||
} | ||
}); | ||
|
||
module.exports = Page; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
property: { | ||
'alignSelf': 'flexItemAlign', | ||
'alignItems': 'flexAlign', | ||
'alignContent': 'flexLinePack', | ||
'justifyContent': 'flexPack', | ||
}, | ||
value: { | ||
'space-between': 'justify', | ||
'space-around': 'distribute', | ||
'flex-start': 'start', | ||
'flex-end': 'end' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var options = require('./options'); | ||
var equivalent = require('./equivalent'); | ||
|
||
var Layout = { | ||
caplitalizeString: function(string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
}, | ||
getEquivalent: function(string, type) { | ||
return equivalent[type][string]; | ||
}, | ||
getVendorPrefix: function() { | ||
var userAgent = navigator.userAgent.toLowerCase(); | ||
var vendorPrefixes = { | ||
firefox: 'Moz', | ||
chrome: 'Webkit', | ||
safari: 'Webkit', | ||
opera: 'O', | ||
msie: 'ms' | ||
}; | ||
var browserMatch = userAgent.match('opera') || userAgent.match('msie') || userAgent.match('firefox') || userAgent.match("safari|chrome"); | ||
return vendorPrefixes[browserMatch[0]]; | ||
}, | ||
getVendorStyle: function(vendor, style, equivalent) { | ||
return vendor + this.caplitalizeString(equivalent > -1 ? this.getEquivalent(style, 'property') : style); | ||
}, | ||
generateStyles: function(styles) { | ||
var vendor = this.getVendorPrefix(); | ||
var opts = options[vendor.toLowerCase()]; | ||
|
||
var style; | ||
for (style in styles) { | ||
if (opts.prefix.indexOf(style) > -1) { | ||
var value = styles[style]; | ||
styles[this.getVendorStyle(vendor, style, opts.equivalent.property.indexOf(style))] = (opts.equivalent.value.indexOf(value) > -1 ? this.getEquivalent(value, 'value') : value) | ||
} | ||
} | ||
return styles; | ||
}, | ||
createStylesheet : function(styles){ | ||
var i; | ||
for (i in styles){ | ||
styles[i] = this.generateStyles(styles[i]); | ||
} | ||
return styles; | ||
} | ||
}; | ||
|
||
module.exports = Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
'webkit': { | ||
prefix: ['alignContent', 'alignItems', 'alignSelf', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexFlow', 'flexShrink', 'flexWrap', 'justifyContent', 'order'], | ||
equivalent: { | ||
value: [], | ||
property: [] | ||
} | ||
}, | ||
'ms': { | ||
prefix: ['alignItems', 'alignSelf', 'alignContent', 'flex', 'flexBasis', 'flexDirection', 'flexGrow', 'flexFlow', 'flexShrink', 'flexWrap', 'justifyContent', 'order'], | ||
equivalent: { | ||
value: ['flex-end', 'flex-start', 'space-between', 'space-around'], | ||
property: ['alignContent', 'alignItems', 'alignSelf', 'justifyContent'] | ||
} | ||
}, | ||
'moz': { | ||
prefix: [], | ||
equivalent: { | ||
value: [], | ||
property: [] | ||
} | ||
}, | ||
'o': { | ||
prefix: [], | ||
equivalent: { | ||
value: [], | ||
porperty: [] | ||
} | ||
} | ||
} |
Oops, something went wrong.