mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 18:41:17 +00:00
Component stylePropTypes keys as constants
This commit is contained in:
@@ -11,6 +11,8 @@ const STATUS_LOADING = 'LOADING'
|
|||||||
const STATUS_PENDING = 'PENDING'
|
const STATUS_PENDING = 'PENDING'
|
||||||
const STATUS_IDLE = 'IDLE'
|
const STATUS_IDLE = 'IDLE'
|
||||||
|
|
||||||
|
const imageStyleKeys = Object.keys(ImageStylePropTypes)
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
initial: {
|
initial: {
|
||||||
alignSelf: 'flex-start',
|
alignSelf: 'flex-start',
|
||||||
@@ -176,7 +178,7 @@ class Image extends React.Component {
|
|||||||
const isLoaded = this.state.status === STATUS_LOADED
|
const isLoaded = this.state.status === STATUS_LOADED
|
||||||
const defaultImage = defaultSource.uri || null
|
const defaultImage = defaultSource.uri || null
|
||||||
const displayImage = !isLoaded ? defaultImage : source.uri
|
const displayImage = !isLoaded ? defaultImage : source.uri
|
||||||
const resolvedStyle = pickProps(style, Object.keys(ImageStylePropTypes))
|
const resolvedStyle = pickProps(style, imageStyleKeys)
|
||||||
const backgroundImage = displayImage ? `url("${displayImage}")` : null
|
const backgroundImage = displayImage ? `url("${displayImage}")` : null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import CoreComponent from '../CoreComponent'
|
|||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import TextStylePropTypes from './TextStylePropTypes'
|
import TextStylePropTypes from './TextStylePropTypes'
|
||||||
|
|
||||||
|
const textStyleKeys = Object.keys(TextStylePropTypes)
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
initial: {
|
initial: {
|
||||||
color: 'inherit',
|
color: 'inherit',
|
||||||
@@ -43,7 +45,7 @@ class Text extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children, component, numberOfLines, style, testID } = this.props
|
const { children, component, numberOfLines, style, testID } = this.props
|
||||||
const resolvedStyle = pickProps(style, Object.keys(TextStylePropTypes))
|
const resolvedStyle = pickProps(style, textStyleKeys)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CoreComponent
|
<CoreComponent
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import CoreComponent from '../CoreComponent'
|
|||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import TextInputStylePropTypes from './TextInputStylePropTypes'
|
import TextInputStylePropTypes from './TextInputStylePropTypes'
|
||||||
|
|
||||||
|
const textInputStyleKeys = Object.keys(TextInputStylePropTypes)
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
initial: {
|
initial: {
|
||||||
appearance: 'none',
|
appearance: 'none',
|
||||||
@@ -70,7 +72,7 @@ class TextInput extends React.Component {
|
|||||||
testID
|
testID
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const resolvedStyle = pickProps(style, Object.keys(TextInputStylePropTypes))
|
const resolvedStyle = pickProps(style, textInputStyleKeys)
|
||||||
const type = secureTextEntry && 'password' || (keyboardType === 'default' ? '' : keyboardType)
|
const type = secureTextEntry && 'password' || (keyboardType === 'default' ? '' : keyboardType)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import CoreComponent from '../CoreComponent'
|
|||||||
import React, { PropTypes } from 'react'
|
import React, { PropTypes } from 'react'
|
||||||
import ViewStylePropTypes from './ViewStylePropTypes'
|
import ViewStylePropTypes from './ViewStylePropTypes'
|
||||||
|
|
||||||
|
const viewStyleKeys = Object.keys(ViewStylePropTypes)
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
// https://github.com/facebook/css-layout#default-values
|
// https://github.com/facebook/css-layout#default-values
|
||||||
initial: {
|
initial: {
|
||||||
@@ -51,7 +53,7 @@ class View extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const { accessibilityLabel, pointerEvents, style, testID, ...other } = this.props
|
const { accessibilityLabel, pointerEvents, style, testID, ...other } = this.props
|
||||||
const pointerEventsStyle = pointerEvents && { pointerEvents }
|
const pointerEventsStyle = pointerEvents && { pointerEvents }
|
||||||
const resolvedStyle = pickProps(style, Object.keys(ViewStylePropTypes))
|
const resolvedStyle = pickProps(style, viewStyleKeys)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CoreComponent
|
<CoreComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user