[change] support CSS custom properties

Update 'setValueForStyles' and style validation to support defining and
using custom properties.

Fix #516
This commit is contained in:
Nicolas Gallagher
2017-07-27 16:46:08 -07:00
parent fee909d26a
commit 4e3d8dbb02
12 changed files with 292 additions and 220 deletions
@@ -14,6 +14,7 @@ import UIExplorer, {
Code,
Description,
DocItem,
ExternalLink,
Section,
StyleList
} from '../../ui-explorer';
@@ -291,6 +292,12 @@ const ViewScreen = () =>
</UIExplorer>;
const stylePropTypes = [
{
label: 'web',
name: (
<ExternalLink href="https://drafts.csswg.org/css-variables/">Custom properties</ExternalLink>
)
},
{
name: 'alignContent',
typeInfo: 'string'
@@ -0,0 +1,12 @@
/* eslint-disable react/prop-types */
/**
* @flow
*/
import AppText from './AppText';
import React from 'react';
const ExternalLink = props => <AppText {...props} accessibilityRole="link" target="_blank" />;
export default ExternalLink;
+6 -4
View File
@@ -16,10 +16,12 @@ const StyleList = ({ stylePropTypes }) =>
<Text style={styles.name}>
{name}
</Text>
{': '}
<Text style={styles.code}>
{typeInfo}
</Text>
{typeInfo ? ': ' : null}
{typeInfo
? <Text style={styles.code}>
{typeInfo}
</Text>
: null}
</AppText>
)}
</View>;
+3 -4
View File
@@ -5,6 +5,7 @@
*/
import AppText from './AppText';
import ExternalLink from './ExternalLink';
import insertBetween from './insertBetween';
import React from 'react';
import { StyleSheet, View } from 'react-native';
@@ -22,14 +23,12 @@ export const Description = ({ children }) =>
const Divider = () => <View style={styles.divider} />;
const SourceLink = ({ uri }) =>
<AppText
accessibilityRole="link"
<ExternalLink
href={`https://github.com/necolas/react-native-web/tree/master/docs/storybook/${uri}`}
style={styles.link}
target="_blank"
>
View source code on GitHub
</AppText>;
</ExternalLink>;
const UIExplorer = ({ children, description, sections, title, url }) =>
<View style={styles.root}>
+2 -1
View File
@@ -5,10 +5,11 @@
import AppText from './AppText';
import Code from './Code';
import DocItem from './DocItem';
import ExternalLink from './ExternalLink';
import Section from './Section';
import StyleList from './StyleList';
import TextList from './TextList';
import UIExplorer, { Description } from './UIExplorer';
export default UIExplorer;
export { AppText, Code, Description, DocItem, Section, StyleList, TextList };
export { AppText, Code, Description, DocItem, ExternalLink, Section, StyleList, TextList };