Skip to content

Commit 09e64d8

Browse files
committed
docs: add description for various properties in the theme
1 parent 872efda commit 09e64d8

File tree

8 files changed

+25
-11
lines changed

8 files changed

+25
-11
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const theme = {
6666
colors: {
6767
...DefaultTheme.colors,
6868
primary: 'tomato',
69-
primaryDark: color('tomato').darken(0.2).rgb().string(),
7069
accent: 'yellow',
7170
},
7271
};

docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"description": "Documentation for React Native Paper",
55
"private": true,
66
"scripts": {
7-
"dev": "babel-node index",
7+
"start": "babel-node index",
88
"build": "babel-node index build",
99
"clean": "del dist/",
10-
"predev": "yarn run clean"
10+
"prestart": "yarn run clean"
1111
},
1212
"devDependencies": {
1313
"babel-cli": "^6.18.0",

docs/pages/1.getting-started.md

-2
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,13 @@ Example:
7272
```js
7373
import * as React from 'react';
7474
import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
75-
import color from 'color';
7675
import App from './src/App';
7776

7877
const theme = {
7978
...DefaultTheme,
8079
colors: {
8180
...DefaultTheme.colors,
8281
primary: 'tomato',
83-
primaryDark: color('tomato').darken(0.2).rgb().string(),
8482
accent: 'yellow',
8583
},
8684
};

docs/pages/2.theming.md

+20
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ export default function Main() {
4848

4949
You can change the theme prop dynamically and all the components will automatically update to reflect the new theme.
5050

51+
A theme contains the following properties:
52+
53+
- `dark` (`boolean`): whether this is a dark theme or light theme.
54+
- `roundness` (`number`): roundness of common elements, such as buttons.
55+
- `colors` (`object`): various colors used throught different elements.
56+
- `primary` - primary color for your app, usually your brand color.
57+
- `accent` - secondary color for your app which complements the primary color.
58+
- `background` - background color for pages, such as lists.
59+
- `paper` - background color for elements containing content, such as cards.
60+
- `text` - text color for content.
61+
- `disabled` - color for disabled elements.
62+
- `placeholder` - color for placeholder text, such as input placeholder.
63+
- `fonts` (`object`): various fonts used throught different elements
64+
- `regular`
65+
- `medium`
66+
- `light`
67+
- `thin`
68+
69+
When creating a custom theme, you will need to provide all of these properties.
70+
5171
## Applying a theme to a paper component
5272

5373
If you want to change the theme for a certain component from the library, you can directly pass the `theme` prop to the component. The theme passed as the prop is merged with the theme from the `Provider`.

src/core/Provider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Theme } from '../types';
77

88
type Props = {
99
children: React.Node,
10-
theme?: Theme,
10+
theme?: $Shape<Theme>,
1111
};
1212

1313
export default class Provider extends React.Component<Props> {

src/styles/DarkTheme.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import color from 'color';
44
import DefaultTheme from './DefaultTheme';
5-
import { white, grey800, lightBlue500, lightBlue700 } from './colors';
5+
import { white, grey800, lightBlue500 } from './colors';
66
import type { Theme } from '../types';
77

88
const DarkTheme: Theme = {
@@ -11,7 +11,6 @@ const DarkTheme: Theme = {
1111
colors: {
1212
...DefaultTheme.colors,
1313
primary: lightBlue500,
14-
primaryDark: lightBlue700,
1514
background: '#303030',
1615
paper: grey800,
1716
text: white,

src/styles/DefaultTheme.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* @flow */
22

33
import color from 'color';
4-
import { indigo500, indigo700, pinkA200, black, white, grey50 } from './colors';
4+
import { indigo500, pinkA200, black, white, grey50 } from './colors';
55
import fonts from './fonts';
66

77
export default {
88
dark: false,
99
roundness: 2,
1010
colors: {
1111
primary: indigo500,
12-
primaryDark: indigo700,
1312
accent: pinkA200,
1413
background: grey50,
1514
paper: white,

src/types.js

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export type Theme = {
55
roundness: number,
66
colors: {
77
primary: string,
8-
primaryDark: string,
98
background: string,
109
paper: string,
1110
accent: string,

0 commit comments

Comments
 (0)