mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-06 03:45:18 +00:00
@@ -0,0 +1,24 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
import processTextShadow from '../processTextShadow'
|
||||||
|
|
||||||
|
suite('apis/StyleSheet/processTextShadow', () => {
|
||||||
|
test('textShadowOffset', () => {
|
||||||
|
const style = {
|
||||||
|
textShadowColor: 'red',
|
||||||
|
textShadowOffset: { width: 2, height: 2 },
|
||||||
|
textShadowRadius: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
processTextShadow(style),
|
||||||
|
{
|
||||||
|
textShadow: '2px 2px 5px red',
|
||||||
|
textShadowColor: null,
|
||||||
|
textShadowOffset: null,
|
||||||
|
textShadowRadius: null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -26,7 +26,10 @@ suite('apis/StyleSheet/processTransform', () => {
|
|||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
processTransform(style),
|
processTransform(style),
|
||||||
{ transform: 'matrix3d(1,2,3,4,5,6)' }
|
{
|
||||||
|
transform: 'matrix3d(1,2,3,4,5,6)',
|
||||||
|
transformMatrix: null
|
||||||
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
|
||||||
|
import assert from 'assert'
|
||||||
|
import processVendorPrefixes from '../processVendorPrefixes'
|
||||||
|
|
||||||
|
suite('apis/StyleSheet/processVendorPrefixes', () => {
|
||||||
|
test('handles array values', () => {
|
||||||
|
const style = {
|
||||||
|
display: [ '-webkit-flex', 'flex' ]
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
processVendorPrefixes(style),
|
||||||
|
{ display: 'flex' }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
import expandStyle from './expandStyle'
|
import expandStyle from './expandStyle'
|
||||||
import flattenStyle from '../../modules/flattenStyle'
|
import flattenStyle from '../../modules/flattenStyle'
|
||||||
import prefixAll from 'inline-style-prefixer/static'
|
import prefixAll from 'inline-style-prefixer/static'
|
||||||
|
import processTextShadow from './processTextShadow'
|
||||||
import processTransform from './processTransform'
|
import processTransform from './processTransform'
|
||||||
|
import processVendorPrefixes from './processVendorPrefixes'
|
||||||
|
|
||||||
const addVendorPrefixes = (style) => {
|
const plugins = [
|
||||||
let prefixedStyles = prefixAll(style)
|
processTextShadow,
|
||||||
// React@15 removed undocumented support for fallback values in
|
processTransform,
|
||||||
// inline-styles. Revert array values to the standard CSS value
|
processVendorPrefixes
|
||||||
for (const prop in prefixedStyles) {
|
]
|
||||||
const value = prefixedStyles[prop]
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
prefixedStyles[prop] = value[value.length - 1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return prefixedStyles
|
|
||||||
}
|
|
||||||
|
|
||||||
const _createReactDOMStyleObject = (reactNativeStyle) => processTransform(expandStyle(flattenStyle(reactNativeStyle)))
|
const applyPlugins = (style) => plugins.reduce((style, plugin) => plugin(style), style)
|
||||||
const createReactDOMStyleObject = (reactNativeStyle) => addVendorPrefixes(_createReactDOMStyleObject(reactNativeStyle))
|
|
||||||
|
const createReactDOMStyleObject = (reactNativeStyle) => applyPlugins(expandStyle(flattenStyle(reactNativeStyle)))
|
||||||
|
|
||||||
module.exports = createReactDOMStyleObject
|
module.exports = createReactDOMStyleObject
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import normalizeValue from './normalizeValue'
|
||||||
|
|
||||||
|
const processTextShadow = (style) => {
|
||||||
|
if (style && style.textShadowOffset) {
|
||||||
|
const { height, width } = style.textShadowOffset
|
||||||
|
const offsetX = normalizeValue(null, height || 0)
|
||||||
|
const offsetY = normalizeValue(null, width || 0)
|
||||||
|
const blurRadius = normalizeValue(null, style.textShadowRadius || 0)
|
||||||
|
const color = style.textShadowColor || 'currentcolor'
|
||||||
|
|
||||||
|
style.textShadow = `${offsetX} ${offsetY} ${blurRadius} ${color}`
|
||||||
|
style.textShadowColor = null
|
||||||
|
style.textShadowOffset = null
|
||||||
|
style.textShadowRadius = null
|
||||||
|
}
|
||||||
|
return style
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = processTextShadow
|
||||||
@@ -20,7 +20,7 @@ const processTransform = (style) => {
|
|||||||
style.transform = style.transform.map(mapTransform).join(' ')
|
style.transform = style.transform.map(mapTransform).join(' ')
|
||||||
} else if (style.transformMatrix) {
|
} else if (style.transformMatrix) {
|
||||||
style.transform = convertTransformMatrix(style.transformMatrix)
|
style.transform = convertTransformMatrix(style.transformMatrix)
|
||||||
delete style.transformMatrix
|
style.transformMatrix = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return style
|
return style
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import prefixAll from 'inline-style-prefixer/static'
|
||||||
|
|
||||||
|
const processVendorPrefixes = (style) => {
|
||||||
|
let prefixedStyles = prefixAll(style)
|
||||||
|
// React@15 removed undocumented support for fallback values in
|
||||||
|
// inline-styles. Revert array values to the standard CSS value
|
||||||
|
for (const prop in prefixedStyles) {
|
||||||
|
const value = prefixedStyles[prop]
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
prefixedStyles[prop] = value[value.length - 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prefixedStyles
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = processVendorPrefixes
|
||||||
@@ -2,7 +2,7 @@ import { PropTypes } from 'react'
|
|||||||
import ColorPropType from '../../propTypes/ColorPropType'
|
import ColorPropType from '../../propTypes/ColorPropType'
|
||||||
import ViewStylePropTypes from '../View/ViewStylePropTypes'
|
import ViewStylePropTypes from '../View/ViewStylePropTypes'
|
||||||
|
|
||||||
const { number, oneOf, oneOfType, string } = PropTypes
|
const { number, oneOf, oneOfType, shape, string } = PropTypes
|
||||||
const numberOrString = oneOfType([ number, string ])
|
const numberOrString = oneOfType([ number, string ])
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -19,8 +19,9 @@ module.exports = {
|
|||||||
textDecorationLine: string,
|
textDecorationLine: string,
|
||||||
/* @platform web */
|
/* @platform web */
|
||||||
textOverflow: string,
|
textOverflow: string,
|
||||||
/* @platform web */
|
textShadowColor: ColorPropType,
|
||||||
textShadow: string,
|
textShadowOffset: shape({ width: number, height: number }),
|
||||||
|
textShadowRadius: number,
|
||||||
/* @platform web */
|
/* @platform web */
|
||||||
textTransform: oneOf([ 'capitalize', 'lowercase', 'none', 'uppercase' ]),
|
textTransform: oneOf([ 'capitalize', 'lowercase', 'none', 'uppercase' ]),
|
||||||
/* @platform web */
|
/* @platform web */
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ module.exports = {
|
|||||||
outline: string,
|
outline: string,
|
||||||
overflowX: autoOrHiddenOrVisible,
|
overflowX: autoOrHiddenOrVisible,
|
||||||
overflowY: autoOrHiddenOrVisible,
|
overflowY: autoOrHiddenOrVisible,
|
||||||
|
transition: string,
|
||||||
userSelect: string,
|
userSelect: string,
|
||||||
visibility: hiddenOrVisible,
|
visibility: hiddenOrVisible,
|
||||||
zIndex: number
|
zIndex: number
|
||||||
|
|||||||
Reference in New Issue
Block a user