Skip to content

Commit e3f96ac

Browse files
lackerFacebook Github Bot 5
authored andcommitted
Make a new "Style" doc that's in The Basics and uses the RNWP
Summary: The example uses StyleSheet.create and also arrays-of-styles. I think this covers everything the old one did, but in simple-enough-for-the-basics form, so I removed the old one. I also reordered so that "Style -> Dimensions -> Layout" is the flow for learning "Styley" things. Closes #8379 Differential Revision: D3478384 Pulled By: caabernathy fbshipit-source-id: 158f0f0367c8eb8b2b24feda0d8d7a533fd7af4d
1 parent 0c9dba4 commit e3f96ac

File tree

6 files changed

+52
-106
lines changed

6 files changed

+52
-106
lines changed

docs/Basics-Component-ListView.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: ListView
44
layout: docs
55
category: The Basics
66
permalink: docs/basics-component-listview.html
7-
next: basics-dimensions
7+
next: basics-network
88
---
99

1010
On mobile devices, lists are a core element in many applications. The [`ListView`](/react-native/docs/listview.html#content) component is a special type of [`View`](/react-native/docs/basics-component-view.html) that displays a *vertically* scrolling list of changing, but similarly structured, data.

docs/Basics-Component-View.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: View
44
layout: docs
55
category: The Basics
66
permalink: docs/basics-component-view.html
7-
next: basics-component-textinput
7+
next: style
88
---
99

1010
A [`View`](/react-native/docs/view.html#content) is the most basic building block for a React Native application. The `View` is an abstraction on top of the target platform's native equivalent, such as iOS's `UIView`.

docs/Basics-IntegrationWithExistingApps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Integration With Existing Apps
44
layout: docs
55
category: Guides
66
permalink: docs/integration-with-existing-apps.html
7-
next: style
7+
next: colors
88
---
99

1010
<div class="integration-toggler">

docs/Basics-Layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Layout
44
layout: docs
55
category: The Basics
66
permalink: docs/basics-layout.html
7-
next: basics-network
7+
next: basics-component-textinput
88
---
99

1010
A component can specify the layout of its children using the flexbox algorithm. Flexbox is designed to provide a consistent layout on different screen sizes.

docs/Basics-Style.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: style
3+
title: Style
4+
layout: docs
5+
category: The Basics
6+
permalink: docs/style.html
7+
next: basics-dimensions
8+
---
9+
10+
With React Native, you don't use a special language or syntax for defining styles. You just style your application using JavaScript. All of the core components accept a prop named `style`. The style names and values usually match how CSS works on the web, except names are written like `backgroundColor` instead of like `background-color`.
11+
12+
The `style` prop can be a plain old JavaScript object. That's the simplest and what we usually use for example code. You can also pass an array of styles - the last style in the array has precedence, so you can use this to inherit styles.
13+
14+
As a component grows in complexity, it is often cleaner to use `StyleSheet.create` to define several styles in one place. Here's an example:
15+
16+
```ReactNativeWebPlayer
17+
import React, { Component } from 'react';
18+
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
19+
20+
class LotsOfStyles extends Component {
21+
render() {
22+
return (
23+
<View>
24+
<Text style={styles.red}>just red</Text>
25+
<Text style={styles.bigblue}>just bigblue</Text>
26+
<Text style={[styles.bigblue, styles.red]}>bigblue, then red</Text>
27+
<Text style={[styles.red, styles.bigblue]}>red, then bigblue</Text>
28+
</View>
29+
);
30+
}
31+
}
32+
33+
const styles = StyleSheet.create({
34+
bigblue: {
35+
color: 'blue',
36+
fontWeight: 'bold',
37+
fontSize: 30,
38+
},
39+
red: {
40+
color: 'red',
41+
},
42+
});
43+
44+
AppRegistry.registerComponent('AwesomeProject', () => LotsOfStyles);
45+
```
46+
47+
One common pattern is to make your component accept a `style` prop which in
48+
turn is used to style subcomponents. You can use this to make styles "cascade" they way they do in CSS.

docs/Style.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)