diff --git a/.babelrc.js b/.babelrc.js
index 3579315ef8e..c1e808c5983 100644
--- a/.babelrc.js
+++ b/.babelrc.js
@@ -72,6 +72,11 @@ module.exports = {
test: withTests,
},
},
+ {
+ test: './app/react-native',
+ presets: ['module:metro-react-native-babel-preset'],
+ plugins: ['babel-plugin-macros', ['emotion', { sourceMap: true, autoLabel: true }]],
+ },
{
test: [
'./lib/node-logger',
diff --git a/addons/ondevice-knobs/package.json b/addons/ondevice-knobs/package.json
index 6abe47ed847..eff830f410c 100644
--- a/addons/ondevice-knobs/package.json
+++ b/addons/ondevice-knobs/package.json
@@ -27,6 +27,7 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
+ "@emotion/native": "^10.0.14",
"@storybook/addons": "5.3.0-alpha.40",
"@storybook/core-events": "5.3.0-alpha.40",
"core-js": "^3.0.1",
diff --git a/addons/ondevice-knobs/src/GroupTabs.js b/addons/ondevice-knobs/src/GroupTabs.js
index b1e38d7ff19..e423304468e 100644
--- a/addons/ondevice-knobs/src/GroupTabs.js
+++ b/addons/ondevice-knobs/src/GroupTabs.js
@@ -1,6 +1,12 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { ScrollView, Text, TouchableOpacity } from 'react-native';
+import styled from '@emotion/native';
+
+const Label = styled.Text(({ theme, active }) => ({
+ color: active ? theme.buttonActiveTextColor : theme.buttonTextColor,
+ fontSize: 17,
+}));
class GroupTabs extends Component {
renderTab(name, group) {
@@ -21,14 +27,7 @@ class GroupTabs extends Component {
key={name}
onPress={() => onGroupSelect(name)}
>
-
- {title}
-
+
);
}
diff --git a/addons/ondevice-knobs/src/PropField.js b/addons/ondevice-knobs/src/PropField.js
index 3b053b5a180..dfde3288ceb 100644
--- a/addons/ondevice-knobs/src/PropField.js
+++ b/addons/ondevice-knobs/src/PropField.js
@@ -1,27 +1,24 @@
import PropTypes from 'prop-types';
import { View, Text } from 'react-native';
import React from 'react';
+import styled from '@emotion/native';
import TypeMap from './types';
const InvalidType = () => Invalid Type;
+const Label = styled.Text(({ theme }) => ({
+ marginLeft: 10,
+ fontSize: 14,
+ color: theme.labelColor,
+ fontWeight: 'bold',
+}));
+
const PropField = ({ onChange, onPress, knob }) => {
const InputType = TypeMap[knob.type] || InvalidType;
return (
- {!knob.hideLabel ? (
-
- {`${knob.label || knob.name}`}
-
- ) : null}
+ {!knob.hideLabel ? : null}
);
diff --git a/addons/ondevice-knobs/src/panel.js b/addons/ondevice-knobs/src/panel.js
index dceafd9e414..5c5eae0f7cb 100644
--- a/addons/ondevice-knobs/src/panel.js
+++ b/addons/ondevice-knobs/src/panel.js
@@ -1,8 +1,9 @@
import React from 'react';
-import { View, Text, TouchableOpacity } from 'react-native';
+import { View, Text } from 'react-native';
import PropTypes from 'prop-types';
import { SELECT_STORY, FORCE_RE_RENDER } from '@storybook/core-events';
import { SET, SET_OPTIONS, RESET, CHANGE, CLICK } from '@storybook/addon-knobs';
+import styled from '@emotion/native';
import GroupTabs from './GroupTabs';
import PropForm from './PropForm';
@@ -10,6 +11,25 @@ const getTimestamp = () => +new Date();
const DEFAULT_GROUP_ID = 'Other';
+const Touchable = styled.TouchableOpacity(({ theme }) => ({
+ borderRadius: 2,
+ borderWidth: 1,
+ borderColor: theme.borderColor,
+ padding: 4,
+ margin: 10,
+ justifyContent: 'center',
+ alignItems: 'center',
+}));
+
+const ResetButton = styled.Text(({ theme }) => ({
+ color: theme.buttonTextColor,
+}));
+
+const HideIcon = styled.Text(({ theme }) => ({
+ fontSize: 14,
+ color: theme.buttonTextColor,
+}));
+
export default class Panel extends React.Component {
constructor(props) {
super(props);
@@ -152,7 +172,7 @@ export default class Panel extends React.Component {
}
return (
-
+
{groupIds.length > 0 && (
)}
@@ -163,20 +183,9 @@ export default class Panel extends React.Component {
onFieldClick={this.handleClick}
/>
-
- RESET
-
+
+ RESET
+
);
}
diff --git a/addons/ondevice-knobs/src/types/Array.js b/addons/ondevice-knobs/src/types/Array.js
index 8234353f642..88b781ea14e 100644
--- a/addons/ondevice-knobs/src/types/Array.js
+++ b/addons/ondevice-knobs/src/types/Array.js
@@ -1,7 +1,16 @@
import PropTypes from 'prop-types';
import React from 'react';
+import styled from '@emotion/native';
-import { TextInput } from 'react-native';
+const Input = styled.TextInput(({ theme }) => ({
+ borderWidth: 1,
+ borderColor: theme.borderColor,
+ borderRadius: 2,
+ fontSize: 13,
+ padding: 5,
+ margin: 10,
+ color: theme.labelColor,
+}));
function formatArray(value, separator) {
if (value === '') {
@@ -11,19 +20,10 @@ function formatArray(value, separator) {
}
const ArrayType = ({ knob, onChange }) => (
- onChange(formatArray(e, knob.separator))}
/>
diff --git a/addons/ondevice-knobs/src/types/Button.js b/addons/ondevice-knobs/src/types/Button.js
index f6f05d05109..5b5a4238a67 100644
--- a/addons/ondevice-knobs/src/types/Button.js
+++ b/addons/ondevice-knobs/src/types/Button.js
@@ -1,10 +1,16 @@
import PropTypes from 'prop-types';
import React from 'react';
-import { TouchableOpacity, Text } from 'react-native';
+import { TouchableOpacity } from 'react-native';
+import styled from '@emotion/native';
+
+const Label = styled.Text(({ theme }) => ({
+ fontSize: 17,
+ color: theme.labelColor,
+}));
const ButtonType = ({ knob, onPress }) => (
onPress(knob)}>
- {knob.name}
+
);
diff --git a/addons/ondevice-knobs/src/types/Color.js b/addons/ondevice-knobs/src/types/Color.js
index ebee0bbbe27..ef286eb17f6 100644
--- a/addons/ondevice-knobs/src/types/Color.js
+++ b/addons/ondevice-knobs/src/types/Color.js
@@ -2,6 +2,17 @@ import PropTypes from 'prop-types';
import React from 'react';
import { Text, Modal, View, TouchableOpacity, TouchableWithoutFeedback } from 'react-native';
import { ColorPicker, fromHsv } from 'react-native-color-picker';
+import styled from '@emotion/native';
+
+const Touchable = styled.TouchableOpacity(({ theme, color }) => ({
+ borderColor: theme.borderColor,
+ width: 30,
+ height: 20,
+ borderRadius: 2,
+ borderWidth: 1,
+ margin: 10,
+ backgroundColor: color,
+}));
class ColorType extends React.Component {
constructor(props) {
@@ -32,17 +43,10 @@ class ColorType extends React.Component {
render() {
const { knob } = this.props;
const { displayColorPicker } = this.state;
- const colorStyle = {
- borderColor: 'rgb(247, 244, 244)',
- width: 30,
- height: 20,
- borderRadius: 2,
- margin: 10,
- backgroundColor: knob.value,
- };
+ const colorStyle = {};
return (
-
+
({
+ borderColor: theme.borderColor,
+ borderWidth: 1,
+ borderRadius: 2,
+ padding: 5,
+}));
+
+const Label = styled.Text(({ theme }) => ({
+ fontSize: 13,
+ color: theme.labelColor,
+}));
// TODO seconds support
class DateType extends PureComponent {
@@ -49,29 +62,17 @@ class DateType extends PureComponent {
return (
-
+
+
+
- {dateString}
-
-
- {timeString}
-
+
+
({
+ borderWidth: 1,
+ borderColor: theme.borderColor,
+ borderRadius: 2,
+ fontSize: 13,
+ padding: 5,
+ color: theme.labelColor,
+}));
class NumberType extends React.Component {
constructor(props) {
@@ -29,15 +39,7 @@ class NumberType extends React.Component {
const { knob } = this.props;
return (
- ({
borderWidth: 1,
- borderColor: '#f7f4f4',
borderRadius: 2,
fontSize: 13,
padding: 5,
margin: 10,
- color: '#555',
-};
+ borderColor: theme.borderColor,
+ color: theme.labelColor,
+}));
class ObjectType extends React.Component {
constructor(...args) {
@@ -70,9 +70,9 @@ class ObjectType extends React.Component {
}
return (
- ({
+ borderWidth: 1,
+ borderRadius: 2,
+ padding: 5,
+ margin: 10,
+ borderColor: theme.borderColor,
+ color: theme.labelColor,
+}));
class SelectType extends React.Component {
getOptions = ({ options }) => {
@@ -30,15 +40,7 @@ class SelectType extends React.Component {
onChange={option => onChange(option.key)}
animationType="none"
>
- ({
+ borderWidth: 1,
+ borderColor: theme.borderColor,
+ borderRadius: 2,
+ fontSize: 13,
+ padding: 5,
+ margin: 10,
+ color: theme.labelColor,
+}));
const TextType = ({ knob, onChange }) => (
- {
return (
- {textAfterFormatted}
+
+ {theme => (
+
+ {textAfterFormatted}
+
+ )}
+
);
};