From 5c74c0efb7e7f2bed9520b149b8ef0b405c918f4 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Tue, 16 Feb 2016 23:40:50 -0800 Subject: [PATCH] Move StyleSheet into 'apis' directory --- src/{modules => apis}/StyleSheet/Store.js | 2 +- .../index.js => apis/StyleSheet/StylePropTypes.js} | 0 src/{modules => apis}/StyleSheet/__tests__/Store-test.js | 6 ++++-- .../StyleSheet/__tests__/expandStyle-test.js | 2 +- .../StyleSheet/__tests__/getStyleObjects-test.js | 2 +- .../StyleSheet/__tests__/hyphenate-test.js | 2 +- src/{modules => apis}/StyleSheet/__tests__/index-test.js | 2 +- src/{modules => apis}/StyleSheet/__tests__/isObject-test.js | 2 +- .../StyleSheet/__tests__/isStyleObject-test.js | 2 +- .../StyleSheet/__tests__/normalizeValue-test.js | 2 +- src/{modules => apis}/StyleSheet/expandStyle.js | 0 src/{modules => apis}/StyleSheet/getStyleObjects.js | 0 src/{modules => apis}/StyleSheet/hyphenate.js | 0 src/{modules => apis}/StyleSheet/index.js | 4 ++-- src/{modules => apis}/StyleSheet/isObject.js | 0 src/{modules => apis}/StyleSheet/isStyleObject.js | 0 src/{modules => apis}/StyleSheet/normalizeValue.js | 0 src/{modules => apis}/StyleSheet/predefs.js | 0 src/{modules => apis}/StyleSheet/prefixer.js | 0 src/components/CoreComponent/index.js | 4 ++-- src/components/Image/index.js | 2 +- src/components/ScrollView/index.js | 4 ++-- src/components/Text/index.js | 2 +- src/components/TextInput/index.js | 2 +- src/components/Touchable/index.js | 2 +- src/components/View/index.js | 2 +- 26 files changed, 23 insertions(+), 21 deletions(-) rename src/{modules => apis}/StyleSheet/Store.js (97%) rename src/{modules/StylePropTypes/index.js => apis/StyleSheet/StylePropTypes.js} (100%) rename src/{modules => apis}/StyleSheet/__tests__/Store-test.js (94%) rename src/{modules => apis}/StyleSheet/__tests__/expandStyle-test.js (94%) rename src/{modules => apis}/StyleSheet/__tests__/getStyleObjects-test.js (92%) rename src/{modules => apis}/StyleSheet/__tests__/hyphenate-test.js (91%) rename src/{modules => apis}/StyleSheet/__tests__/index-test.js (98%) rename src/{modules => apis}/StyleSheet/__tests__/isObject-test.js (88%) rename src/{modules => apis}/StyleSheet/__tests__/isStyleObject-test.js (92%) rename src/{modules => apis}/StyleSheet/__tests__/normalizeValue-test.js (86%) rename src/{modules => apis}/StyleSheet/expandStyle.js (100%) rename src/{modules => apis}/StyleSheet/getStyleObjects.js (100%) rename src/{modules => apis}/StyleSheet/hyphenate.js (100%) rename src/{modules => apis}/StyleSheet/index.js (95%) rename src/{modules => apis}/StyleSheet/isObject.js (100%) rename src/{modules => apis}/StyleSheet/isStyleObject.js (100%) rename src/{modules => apis}/StyleSheet/normalizeValue.js (100%) rename src/{modules => apis}/StyleSheet/predefs.js (100%) rename src/{modules => apis}/StyleSheet/prefixer.js (100%) diff --git a/src/modules/StyleSheet/Store.js b/src/apis/StyleSheet/Store.js similarity index 97% rename from src/modules/StyleSheet/Store.js rename to src/apis/StyleSheet/Store.js index aa0528a5..5f23c37f 100644 --- a/src/modules/StyleSheet/Store.js +++ b/src/apis/StyleSheet/Store.js @@ -41,7 +41,7 @@ export default class Store { const getCssSelector = (property, value) => { let className = this.get(property, value) if (!obfuscate && className) { - className = className.replace(/[,":?.%\\$#]/g, '\\$&') + className = className.replace(/[(),":?.%\\$#]/g, '\\$&') } return className } diff --git a/src/modules/StylePropTypes/index.js b/src/apis/StyleSheet/StylePropTypes.js similarity index 100% rename from src/modules/StylePropTypes/index.js rename to src/apis/StyleSheet/StylePropTypes.js diff --git a/src/modules/StyleSheet/__tests__/Store-test.js b/src/apis/StyleSheet/__tests__/Store-test.js similarity index 94% rename from src/modules/StyleSheet/__tests__/Store-test.js rename to src/apis/StyleSheet/__tests__/Store-test.js index 9b67d8c0..6922220f 100644 --- a/src/modules/StyleSheet/__tests__/Store-test.js +++ b/src/apis/StyleSheet/__tests__/Store-test.js @@ -3,7 +3,7 @@ import assert from 'assert' import Store from '../Store' -suite('modules/StyleSheet/Store', () => { +suite('apis/StyleSheet/Store', () => { suite('the constructor', () => { test('initialState', () => { const initialState = { classNames: { 'alignItems:center': '__classname__' } } @@ -92,13 +92,15 @@ suite('modules/StyleSheet/Store', () => { test('human-readable style sheet', () => { const store = new Store() store.set('alignItems', 'center') + store.set('backgroundColor', 'rgba(0,0,0,0)') store.set('color', '#fff') store.set('fontFamily', '"Helvetica Neue", Arial, sans-serif') store.set('marginBottom', 0) store.set('width', '100%') - const expected = '/* 5 unique declarations */\n' + + const expected = '/* 6 unique declarations */\n' + '.alignItems\\:center{align-items:center;}\n' + + '.backgroundColor\\:rgba\\(0\\,0\\,0\\,0\\){background-color:rgba(0,0,0,0);}\n' + '.color\\:\\#fff{color:#fff;}\n' + '.fontFamily\\:\\"Helvetica-Neue\\"\\,-Arial\\,-sans-serif{font-family:"Helvetica Neue", Arial, sans-serif;}\n' + '.marginBottom\\:0px{margin-bottom:0px;}\n' + diff --git a/src/modules/StyleSheet/__tests__/expandStyle-test.js b/src/apis/StyleSheet/__tests__/expandStyle-test.js similarity index 94% rename from src/modules/StyleSheet/__tests__/expandStyle-test.js rename to src/apis/StyleSheet/__tests__/expandStyle-test.js index a68de4e4..521e29bb 100644 --- a/src/modules/StyleSheet/__tests__/expandStyle-test.js +++ b/src/apis/StyleSheet/__tests__/expandStyle-test.js @@ -3,7 +3,7 @@ import assert from 'assert' import expandStyle from '../expandStyle' -suite('modules/StyleSheet/expandStyle', () => { +suite('apis/StyleSheet/expandStyle', () => { test('style resolution', () => { const initial = { borderTopWidth: 1, diff --git a/src/modules/StyleSheet/__tests__/getStyleObjects-test.js b/src/apis/StyleSheet/__tests__/getStyleObjects-test.js similarity index 92% rename from src/modules/StyleSheet/__tests__/getStyleObjects-test.js rename to src/apis/StyleSheet/__tests__/getStyleObjects-test.js index edbcf5f5..b29759a1 100644 --- a/src/modules/StyleSheet/__tests__/getStyleObjects-test.js +++ b/src/apis/StyleSheet/__tests__/getStyleObjects-test.js @@ -22,7 +22,7 @@ const fixture = { } } -suite('modules/StyleSheet/getStyleObjects', () => { +suite('apis/StyleSheet/getStyleObjects', () => { test('returns only style objects', () => { const actual = getStyleObjects(fixture) assert.deepEqual(actual, [ diff --git a/src/modules/StyleSheet/__tests__/hyphenate-test.js b/src/apis/StyleSheet/__tests__/hyphenate-test.js similarity index 91% rename from src/modules/StyleSheet/__tests__/hyphenate-test.js rename to src/apis/StyleSheet/__tests__/hyphenate-test.js index 41f6afaa..ca2f1e31 100644 --- a/src/modules/StyleSheet/__tests__/hyphenate-test.js +++ b/src/apis/StyleSheet/__tests__/hyphenate-test.js @@ -3,7 +3,7 @@ import assert from 'assert' import hyphenate from '../hyphenate' -suite('modules/StyleSheet/hyphenate', () => { +suite('apis/StyleSheet/hyphenate', () => { test('style property', () => { assert.equal(hyphenate('alignItems'), 'align-items') assert.equal(hyphenate('color'), 'color') diff --git a/src/modules/StyleSheet/__tests__/index-test.js b/src/apis/StyleSheet/__tests__/index-test.js similarity index 98% rename from src/modules/StyleSheet/__tests__/index-test.js rename to src/apis/StyleSheet/__tests__/index-test.js index 93939085..da00a625 100644 --- a/src/modules/StyleSheet/__tests__/index-test.js +++ b/src/apis/StyleSheet/__tests__/index-test.js @@ -6,7 +6,7 @@ import StyleSheet from '..' const styles = { root: { borderWidth: 1 } } -suite('modules/StyleSheet', () => { +suite('apis/StyleSheet', () => { setup(() => { StyleSheet._destroy() }) diff --git a/src/modules/StyleSheet/__tests__/isObject-test.js b/src/apis/StyleSheet/__tests__/isObject-test.js similarity index 88% rename from src/modules/StyleSheet/__tests__/isObject-test.js rename to src/apis/StyleSheet/__tests__/isObject-test.js index f8bb977a..756216c0 100644 --- a/src/modules/StyleSheet/__tests__/isObject-test.js +++ b/src/apis/StyleSheet/__tests__/isObject-test.js @@ -3,7 +3,7 @@ import assert from 'assert' import isObject from '../isObject' -suite('modules/StyleSheet/isObject', () => { +suite('apis/StyleSheet/isObject', () => { test('returns "true" for objects', () => { assert.ok(isObject({}) === true) }) diff --git a/src/modules/StyleSheet/__tests__/isStyleObject-test.js b/src/apis/StyleSheet/__tests__/isStyleObject-test.js similarity index 92% rename from src/modules/StyleSheet/__tests__/isStyleObject-test.js rename to src/apis/StyleSheet/__tests__/isStyleObject-test.js index b0ea8678..aded3cc0 100644 --- a/src/modules/StyleSheet/__tests__/isStyleObject-test.js +++ b/src/apis/StyleSheet/__tests__/isStyleObject-test.js @@ -17,7 +17,7 @@ const styles = { } } -suite('modules/StyleSheet/isStyleObject', () => { +suite('apis/StyleSheet/isStyleObject', () => { test('returns "false" for non-style objects', () => { assert.ok(isStyleObject(styles) === false) assert.ok(isStyleObject(styles.align) === false) diff --git a/src/modules/StyleSheet/__tests__/normalizeValue-test.js b/src/apis/StyleSheet/__tests__/normalizeValue-test.js similarity index 86% rename from src/modules/StyleSheet/__tests__/normalizeValue-test.js rename to src/apis/StyleSheet/__tests__/normalizeValue-test.js index 5dee4d3e..9eb6a489 100644 --- a/src/modules/StyleSheet/__tests__/normalizeValue-test.js +++ b/src/apis/StyleSheet/__tests__/normalizeValue-test.js @@ -3,7 +3,7 @@ import assert from 'assert' import normalizeValue from '../normalizeValue' -suite('modules/StyleSheet/normalizeValue', () => { +suite('apis/StyleSheet/normalizeValue', () => { test('normalizes property values requiring units', () => { assert.deepEqual(normalizeValue('margin', 0), '0px') }) diff --git a/src/modules/StyleSheet/expandStyle.js b/src/apis/StyleSheet/expandStyle.js similarity index 100% rename from src/modules/StyleSheet/expandStyle.js rename to src/apis/StyleSheet/expandStyle.js diff --git a/src/modules/StyleSheet/getStyleObjects.js b/src/apis/StyleSheet/getStyleObjects.js similarity index 100% rename from src/modules/StyleSheet/getStyleObjects.js rename to src/apis/StyleSheet/getStyleObjects.js diff --git a/src/modules/StyleSheet/hyphenate.js b/src/apis/StyleSheet/hyphenate.js similarity index 100% rename from src/modules/StyleSheet/hyphenate.js rename to src/apis/StyleSheet/hyphenate.js diff --git a/src/modules/StyleSheet/index.js b/src/apis/StyleSheet/index.js similarity index 95% rename from src/modules/StyleSheet/index.js rename to src/apis/StyleSheet/index.js index 3f67fe9d..1507d7fd 100644 --- a/src/modules/StyleSheet/index.js +++ b/src/apis/StyleSheet/index.js @@ -3,7 +3,7 @@ import expandStyle from './expandStyle' import getStyleObjects from './getStyleObjects' import prefixer from './prefixer' import Store from './Store' -import StylePropTypes from '../StylePropTypes' +import StylePropTypes from './StylePropTypes' /** * Initialize the store with pointer-event styles mapping to our custom pointer @@ -58,7 +58,7 @@ const create = (styles: Object): Object => { if (stylesheet) { stylesheet.textContent = _renderToString() } else if (process.env.NODE_ENV !== 'production') { - console.error('ReactNativeWeb: cannot find "react-stylesheet" element') + console.error('ReactNative: cannot find "react-stylesheet" element') } } diff --git a/src/modules/StyleSheet/isObject.js b/src/apis/StyleSheet/isObject.js similarity index 100% rename from src/modules/StyleSheet/isObject.js rename to src/apis/StyleSheet/isObject.js diff --git a/src/modules/StyleSheet/isStyleObject.js b/src/apis/StyleSheet/isStyleObject.js similarity index 100% rename from src/modules/StyleSheet/isStyleObject.js rename to src/apis/StyleSheet/isStyleObject.js diff --git a/src/modules/StyleSheet/normalizeValue.js b/src/apis/StyleSheet/normalizeValue.js similarity index 100% rename from src/modules/StyleSheet/normalizeValue.js rename to src/apis/StyleSheet/normalizeValue.js diff --git a/src/modules/StyleSheet/predefs.js b/src/apis/StyleSheet/predefs.js similarity index 100% rename from src/modules/StyleSheet/predefs.js rename to src/apis/StyleSheet/predefs.js diff --git a/src/modules/StyleSheet/prefixer.js b/src/apis/StyleSheet/prefixer.js similarity index 100% rename from src/modules/StyleSheet/prefixer.js rename to src/apis/StyleSheet/prefixer.js diff --git a/src/components/CoreComponent/index.js b/src/components/CoreComponent/index.js index 3c1c6e8a..111f9a1b 100644 --- a/src/components/CoreComponent/index.js +++ b/src/components/CoreComponent/index.js @@ -1,6 +1,6 @@ import React, { PropTypes } from 'react' -import StylePropTypes from '../../modules/StylePropTypes' -import StyleSheet from '../../modules/StyleSheet' +import StylePropTypes from '../../apis/StyleSheet/StylePropTypes' +import StyleSheet from '../../apis/StyleSheet' const roleComponents = { article: 'article', diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 4ba15444..dff09599 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -1,6 +1,6 @@ /* global window */ import { pickProps } from '../../modules/filterObjectProps' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' import CoreComponent from '../CoreComponent' import ImageStylePropTypes from './ImageStylePropTypes' import React, { PropTypes } from 'react' diff --git a/src/components/ScrollView/index.js b/src/components/ScrollView/index.js index 93c1cb84..17ac133a 100644 --- a/src/components/ScrollView/index.js +++ b/src/components/ScrollView/index.js @@ -2,7 +2,7 @@ import { pickProps } from '../../modules/filterObjectProps' import debounce from 'lodash.debounce' import React, { PropTypes } from 'react' import ScrollViewStylePropTypes from './ScrollViewStylePropTypes' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' import View from '../View' const scrollViewStyleKeys = Object.keys(ScrollViewStylePropTypes) @@ -11,7 +11,7 @@ const styles = StyleSheet.create({ initial: { flexGrow: 1, flexShrink: 1, - overflow: 'scroll' + overflow: 'auto' }, initialContentContainer: { flexGrow: 1, diff --git a/src/components/Text/index.js b/src/components/Text/index.js index 97d75f5a..b1fde7ca 100644 --- a/src/components/Text/index.js +++ b/src/components/Text/index.js @@ -1,7 +1,7 @@ import { pickProps } from '../../modules/filterObjectProps' import CoreComponent from '../CoreComponent' import React, { PropTypes } from 'react' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' import TextStylePropTypes from './TextStylePropTypes' const textStyleKeys = Object.keys(TextStylePropTypes) diff --git a/src/components/TextInput/index.js b/src/components/TextInput/index.js index 12fa3164..98250134 100644 --- a/src/components/TextInput/index.js +++ b/src/components/TextInput/index.js @@ -2,7 +2,7 @@ import { pickProps } from '../../modules/filterObjectProps' import CoreComponent from '../CoreComponent' import React, { PropTypes } from 'react' import ReactDOM from 'react-dom' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' import Text from '../Text' import TextareaAutosize from 'react-textarea-autosize' import TextInputStylePropTypes from './TextInputStylePropTypes' diff --git a/src/components/Touchable/index.js b/src/components/Touchable/index.js index f63a22c3..782c1557 100644 --- a/src/components/Touchable/index.js +++ b/src/components/Touchable/index.js @@ -1,7 +1,7 @@ import React, { PropTypes } from 'react' import Tappable from 'react-tappable' import View from '../View' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' const styles = StyleSheet.create({ initial: { diff --git a/src/components/View/index.js b/src/components/View/index.js index 550e7382..94777e91 100644 --- a/src/components/View/index.js +++ b/src/components/View/index.js @@ -1,7 +1,7 @@ import { pickProps } from '../../modules/filterObjectProps' import CoreComponent from '../CoreComponent' import React, { PropTypes } from 'react' -import StyleSheet from '../../modules/StyleSheet' +import StyleSheet from '../../apis/StyleSheet' import ViewStylePropTypes from './ViewStylePropTypes' const viewStyleKeys = Object.keys(ViewStylePropTypes)