mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-24 23:25:40 +00:00
Separate modules for StyleSheet and related side-effects
This commit is contained in:
@@ -49,7 +49,7 @@ module.exports = {
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
dead_code: true,
|
||||
drop_console: true,
|
||||
drop_console: false,
|
||||
screw_ie8: true,
|
||||
warnings: false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2016-present, Nicolas Gallagher.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @providesModule StyleSheet
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
import flattenStyle from './flattenStyle';
|
||||
import getHairlineWidth from './getHairlineWidth';
|
||||
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
|
||||
|
||||
const absoluteFillObject = {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0
|
||||
};
|
||||
const absoluteFill = ReactNativePropRegistry.register(absoluteFillObject);
|
||||
|
||||
const StyleSheet = {
|
||||
absoluteFill,
|
||||
absoluteFillObject,
|
||||
compose(style1, style2) {
|
||||
if (style1 && style2) {
|
||||
return [style1, style2];
|
||||
} else {
|
||||
return style1 || style2;
|
||||
}
|
||||
},
|
||||
create(styles) {
|
||||
const result = {};
|
||||
Object.keys(styles).forEach(key => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const StyleSheetValidation = require('./StyleSheetValidation').default;
|
||||
StyleSheetValidation.validateStyle(key, styles);
|
||||
}
|
||||
const id = styles[key] && ReactNativePropRegistry.register(styles[key]);
|
||||
result[key] = id;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
flatten: flattenStyle,
|
||||
hairlineWidth: getHairlineWidth()
|
||||
};
|
||||
|
||||
export default StyleSheet;
|
||||
+2
-54
@@ -1,19 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2016-present, Nicolas Gallagher.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @providesModule StyleSheet
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
import flattenStyle from './flattenStyle';
|
||||
import getHairlineWidth from './getHairlineWidth';
|
||||
import modality from '../../modules/modality';
|
||||
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
|
||||
import styleResolver from './styleResolver';
|
||||
import StyleSheet from './StyleSheet';
|
||||
|
||||
// initialize focus-ring fix
|
||||
modality();
|
||||
@@ -22,46 +8,8 @@ modality();
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const { canUseDOM } = require('fbjs/lib/ExecutionEnvironment');
|
||||
if (canUseDOM && window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.resolveRNStyle = flattenStyle;
|
||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.resolveRNStyle = StyleSheet.flatten;
|
||||
}
|
||||
}
|
||||
|
||||
const absoluteFillObject = {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0
|
||||
};
|
||||
const absoluteFill = ReactNativePropRegistry.register(absoluteFillObject);
|
||||
|
||||
const StyleSheet = {
|
||||
absoluteFill,
|
||||
absoluteFillObject,
|
||||
compose(style1, style2) {
|
||||
if (style1 && style2) {
|
||||
return [style1, style2];
|
||||
} else {
|
||||
return style1 || style2;
|
||||
}
|
||||
},
|
||||
create(styles) {
|
||||
const result = {};
|
||||
Object.keys(styles).forEach(key => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const StyleSheetValidation = require('./StyleSheetValidation').default;
|
||||
StyleSheetValidation.validateStyle(key, styles);
|
||||
}
|
||||
const id = styles[key] && ReactNativePropRegistry.register(styles[key]);
|
||||
result[key] = id;
|
||||
});
|
||||
return result;
|
||||
},
|
||||
flatten: flattenStyle,
|
||||
getStyleSheets() {
|
||||
return styleResolver.getStyleSheets();
|
||||
},
|
||||
hairlineWidth: getHairlineWidth()
|
||||
};
|
||||
|
||||
export default StyleSheet;
|
||||
|
||||
Reference in New Issue
Block a user