2015-06-03 20:55:52 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-06-03 20:55:52 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-06-03 20:55:52 +00:00
|
|
|
*
|
2018-05-11 02:06:46 +00:00
|
|
|
* @format
|
2018-08-09 15:32:04 +00:00
|
|
|
* @flow strict-local
|
2015-06-03 20:55:52 +00:00
|
|
|
*/
|
2018-05-11 02:06:46 +00:00
|
|
|
|
2015-06-03 20:55:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
const React = require('React');
|
|
|
|
const StyleSheet = require('StyleSheet');
|
|
|
|
const Text = require('Text');
|
|
|
|
const View = require('View');
|
2015-06-03 20:55:52 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class StyleInspector extends React.Component<$FlowFixMeProps> {
|
2015-06-03 20:55:52 +00:00
|
|
|
render() {
|
|
|
|
if (!this.props.style) {
|
|
|
|
return <Text style={styles.noStyle}>No style</Text>;
|
|
|
|
}
|
2018-05-10 22:44:52 +00:00
|
|
|
const names = Object.keys(this.props.style);
|
2015-06-03 20:55:52 +00:00
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<View>
|
2018-05-11 02:06:46 +00:00
|
|
|
{names.map(name => (
|
|
|
|
<Text key={name} style={styles.attr}>
|
|
|
|
{name}:
|
|
|
|
</Text>
|
|
|
|
))}
|
2015-06-03 20:55:52 +00:00
|
|
|
</View>
|
2016-02-06 00:29:17 +00:00
|
|
|
|
2015-06-03 20:55:52 +00:00
|
|
|
<View>
|
2016-02-06 00:29:17 +00:00
|
|
|
{names.map(name => {
|
2018-05-11 02:06:46 +00:00
|
|
|
const value =
|
|
|
|
typeof this.props.style[name] === 'object'
|
|
|
|
? JSON.stringify(this.props.style[name])
|
|
|
|
: this.props.style[name];
|
|
|
|
return (
|
|
|
|
<Text key={name} style={styles.value}>
|
|
|
|
{value}
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
})}
|
2015-06-03 20:55:52 +00:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
const styles = StyleSheet.create({
|
2015-06-03 20:55:52 +00:00
|
|
|
container: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
},
|
|
|
|
row: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-around',
|
|
|
|
},
|
|
|
|
attr: {
|
|
|
|
fontSize: 10,
|
|
|
|
color: '#ccc',
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
fontSize: 10,
|
|
|
|
color: 'white',
|
|
|
|
marginLeft: 10,
|
|
|
|
},
|
|
|
|
noStyle: {
|
|
|
|
color: 'white',
|
|
|
|
fontSize: 10,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = StyleInspector;
|