Skip to content

Commit

Permalink
Make ColorValue public in StyleSheet.js
Browse files Browse the repository at this point in the history
Summary:
This diff makes the ColorValue export "official" by exporting it from StyleSheet in order to encourage its use in product code.

Changelog: Moved ColorValue export from StyleSheetTypes to StyleSheet

Reviewed By: TheSavior

Differential Revision: D21076969

fbshipit-source-id: 972ef5a1b13bd9f6b7691a279a73168e7ce9d9ab
  • Loading branch information
Zack Argyle authored and facebook-github-bot committed Apr 17, 2020
1 parent 894f6b3 commit 0a67133
Show file tree
Hide file tree
Showing 49 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Libraries/ActionSheetIOS/ActionSheetIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import RCTActionSheetManager from './NativeActionSheetManager';

const invariant = require('invariant');
const processColor = require('../StyleSheet/processColor');
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../StyleSheet/processColor';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const StyleSheet = require('../../StyleSheet/StyleSheet');
const View = require('../View/View');
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

const PlatformActivityIndicator =
Platform.OS === 'android'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import type {WithDefault} from '../../Types/CodegenTypes';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const View = require('./View/View');
const invariant = require('invariant');

import type {PressEvent} from '../Types/CoreEventTypes';
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../StyleSheet/StyleSheet';

type ButtonProps = $ReadOnly<{|
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet';
import type {
WithDefault,
DirectEventHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import AndroidDrawerLayoutNativeComponent, {

const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'];

import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue, ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {DirectEventHandler} from '../../Types/CodegenTypes';
import type {
MeasureOnSuccessCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
} from '../../Types/CodegenTypes';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../../StyleSheet/processColor';
import type {ViewProps} from '../../Components/View/ViewPropTypes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
} from '../../Types/CodegenTypes';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../../StyleSheet/processColor';
import type {ViewProps} from '../../Components/View/ViewPropTypes';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const React = require('react');
const UnimplementedView = require('../UnimplementedViews/UnimplementedView');

import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

const MODE_DIALOG = 'dialog';
const MODE_DROPDOWN = 'dropdown';
Expand Down
3 changes: 1 addition & 2 deletions Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import StyleSheet from '../../StyleSheet/StyleSheet';
import invariant from 'invariant';
import processColor from '../../StyleSheet/processColor';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue, TextStyleProp} from '../../StyleSheet/StyleSheet';

type PickerItemSelectSyntheticEvent = SyntheticEvent<
$ReadOnly<{|
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import RCTPickerNativeComponent, {
Commands as PickerCommands,
} from './RCTPickerNativeComponent';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../../StyleSheet/processColor';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Pressable/useAndroidRippleForView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import invariant from 'invariant';
import {Commands} from '../View/ViewNativeComponent';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {PressEvent} from '../../Types/CoreEventTypes';
import {Platform, View, processColor} from 'react-native';
import * as React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const React = require('react');
import ProgressBarAndroidNativeComponent from './ProgressBarAndroidNativeComponent';

import type {ViewProps} from '../View/ViewPropTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

export type ProgressBarAndroidProps = $ReadOnly<{|
...ViewProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import type {Double, WithDefault} from '../../Types/CodegenTypes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const StyleSheet = require('../../StyleSheet/StyleSheet');

import RCTProgressViewNativeComponent from './RCTProgressViewNativeComponent';
import type {ImageSource} from '../../Image/ImageSource';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

type Props = $ReadOnly<{|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import type {Float, WithDefault} from '../../Types/CodegenTypes';
import type {ImageSource} from '../../Image/ImageSource';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
Int32,
WithDefault,
} from '../../Types/CodegenTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

type NativeProps = $ReadOnly<{|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

import type {DirectEventHandler, WithDefault} from '../../Types/CodegenTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import * as React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/RefreshControl/RefreshControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const Platform = require('../../Utilities/Platform');
const React = require('react');

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import AndroidSwipeRefreshLayoutNativeComponent, {
Commands as AndroidSwipeRefreshLayoutCommands,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const setAndForwardRef = require('../../Utilities/setAndForwardRef');
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
import type {PointProp} from '../../StyleSheet/PointPropType';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {
PressEvent,
ScrollEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
ViewStyleProp,
DangerouslyImpreciseStyle,
} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
import type {ScrollEvent} from '../../Types/CoreEventTypes';
import type {PointProp} from '../../StyleSheet/PointPropType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
WithDefault,
Int32,
} from '../../Types/CodegenTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

export type OnChangeEvent = $ReadOnly<{|
value: Int32,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyleSheet = require('../../StyleSheet/StyleSheet');

import type {ImageSource} from '../../Image/ImageSource';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Slider/SliderNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ImageSource} from '../../Image/ImageSource';
import type {ViewProps} from '../View/ViewPropTypes';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/StatusBar/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const React = require('react');

const invariant = require('invariant');
const processColor = require('../../StyleSheet/processColor');
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

import NativeStatusBarManagerAndroid from './NativeStatusBarManagerAndroid';
import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativ
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

type SwitchChangeEvent = $ReadOnly<{|
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import SwitchNativeComponent, {
Commands as SwitchCommands,
} from './SwitchNativeComponent';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Switch/SwitchNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

import type {BubblingEventHandler, WithDefault} from '../../Types/CodegenTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import * as React from 'react';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
} from '../../Types/CodegenTypes';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {TextStyleProp, ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import type {TextInputNativeCommands} from './TextInputNativeCommands';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/TextInput/InputAccessoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyleSheet = require('../../StyleSheet/StyleSheet');
import RCTInputAccessoryViewNativeComponent from './RCTInputAccessoryViewNativeComponent';

import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

/**
* Note: iOS only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';

import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const nullthrows = require('nullthrows');
const setAndForwardRef = require('../../Utilities/setAndForwardRef');

import type {TextStyleProp, ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {ViewProps} from '../View/ViewPropTypes';
import type {SyntheticEvent, ScrollEvent} from '../../Types/CoreEventTypes';
import type {PressEvent} from '../../Types/CoreEventTypes';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Pressability, {
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
import TVTouchable from './TVTouchable';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import Platform from '../../Utilities/Platform';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/ImageViewNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
import type {ImageProps} from './ImageProps';
import type {ViewProps} from '../Components/View/ViewPropTypes';
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../StyleSheet/StyleSheet';

import ImageViewViewConfig from './ImageViewViewConfig';
const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Pressability/PressabilityDebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

import normalizeColor from '../StyleSheet/normalizeColor';
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../StyleSheet/StyleSheet';

import Touchable from '../Components/Touchable/Touchable';
import View from '../Components/View/View';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/PlatformColorValueTypes.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from './StyleSheetTypes';
import type {ColorValue} from './StyleSheet';
import type {ProcessedColorValue} from './processColor';

export opaque type NativeColorValue = {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/PlatformColorValueTypes.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from './StyleSheetTypes';
import type {ColorValue} from './StyleSheet';
import type {ProcessedColorValue} from './processColor';

export opaque type NativeColorValue = {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from './StyleSheetTypes';
import type {ColorValue} from './StyleSheet';
import {DynamicColorIOSPrivate} from './PlatformColorValueTypes';

export type DynamicColorIOSTuple = {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/PlatformColorValueTypesIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ColorValue} from './StyleSheetTypes';
import type {ColorValue} from './StyleSheet';

export type DynamicColorIOSTuple = {
light: ColorValue,
Expand Down
10 changes: 10 additions & 0 deletions Libraries/StyleSheet/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const StyleSheetValidation = require('./StyleSheetValidation');
const flatten = require('./flattenStyle');

import type {
____ColorValue_Internal,
____Styles_Internal,
____DangerouslyImpreciseStyle_Internal,
____DangerouslyImpreciseStyleProp_Internal,
Expand All @@ -28,6 +29,15 @@ import type {
____ImageStyleProp_Internal,
} from './StyleSheetTypes';

/**
* This type should be used as the type for anything that is a color. It is
* most useful when using DynamicColorIOS which can be a string or a dynamic
* color object.
*
* type props = {backgroundColor: ColorValue};
*/
export type ColorValue = ____ColorValue_Internal;

/**
* This type should be used as the type for a prop that is passed through
* to a <View>'s `style` prop. This ensures call sites of the component
Expand Down
Loading

0 comments on commit 0a67133

Please sign in to comment.