-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add native support for react-native
- Loading branch information
1 parent
a70dc7d
commit f998874
Showing
13 changed files
with
446 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
# ⚠️ [MOVED REPO](https://github.com/pedronauck/docz-plugin-react-native/tree/master/example) | ||
## Docz React Native | ||
|
||
To avoid some performances issues, we move this example to a new repo! | ||
Use your React Native components inside docz | ||
|
||
> We're using [react-native-web](https://github.com/necolas/react-native-web) to make this integration possible. So, maybe you can have some caveats. | ||
## Instalation | ||
|
||
These packages are required to use React Native with docz: | ||
|
||
```bash | ||
$ yarn add react-native-web react-art | ||
``` | ||
|
||
Then, just set the `--native` argument with docz script: | ||
|
||
```bash | ||
$ docz dev --native | ||
$ docz build --native | ||
``` | ||
|
||
Or you can set directly on your `doczrc.js`: | ||
|
||
```js | ||
export default { | ||
native: true | ||
} | ||
``` | ||
|
||
That's it 🙌🏻 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
title: 'React Native', | ||
native: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "docz-example-react-native", | ||
"version": "0.11.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "docz dev", | ||
"build": "docz build" | ||
}, | ||
"dependencies": { | ||
"prop-types": "^15.6.2", | ||
"react": "^16.6.3", | ||
"react-art": "^16.6.3", | ||
"react-dom": "^16.6.3", | ||
"react-native-web": "^0.9.8", | ||
"styled-components": "^4.1.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.2.0", | ||
"docz": "^0.12.14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { Fragment } from 'react' | ||
import { Text as BaseText } from 'react-native' | ||
import styled from 'styled-components/native' | ||
import * as t from 'prop-types' | ||
|
||
const kinds = { | ||
info: '#5352ED', | ||
positive: '#2ED573', | ||
negative: '#FF4757', | ||
warning: '#FFA502', | ||
} | ||
|
||
const AlertStyled = styled.View` | ||
padding: 15px 20px; | ||
background: white; | ||
border-radius: 3px; | ||
background: ${({ kind = 'info' }) => kinds[kind]}; | ||
` | ||
|
||
export const Text = styled(BaseText)` | ||
color: white; | ||
` | ||
|
||
export const Alert = ({ kind = 'info', ...props }) => ( | ||
<AlertStyled {...props} kind={kind} /> | ||
) | ||
|
||
Alert.propTypes = { | ||
kind: t.oneOf(['info', 'positive', 'negative', 'warning']), | ||
} | ||
|
||
Alert.defaultProps = { | ||
kind: 'info', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
name: Alert | ||
menu: Components | ||
--- | ||
|
||
import { Playground, PropsTable } from 'docz' | ||
import { Alert, Text } from './Alert' | ||
|
||
# Alert | ||
|
||
## Properties | ||
|
||
<PropsTable of={Alert} /> | ||
|
||
## Basic usage | ||
|
||
<Playground> | ||
<Alert> | ||
<Text>Hello world</Text> | ||
</Alert> | ||
</Playground> | ||
|
||
## Using different kinds | ||
|
||
<Playground> | ||
<Alert kind="info"><Text>Some message</Text></Alert> | ||
<Alert kind="positive"><Text>Some message</Text></Alert> | ||
<Alert kind="negative"><Text>Some message</Text></Alert> | ||
<Alert kind="warning"><Text>Some message</Text></Alert> | ||
</Playground> | ||
|
||
|
||
## Use with children as a function | ||
|
||
<Playground> | ||
{() => { | ||
const message = 'Hello world' | ||
|
||
return ( | ||
<Alert><Text>{message}</Text></Alert> | ||
) | ||
}} | ||
</Playground> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react' | ||
import styled from 'styled-components/native' | ||
import * as t from 'prop-types' | ||
|
||
const scales = { | ||
small: ` | ||
width: 100px; | ||
padding: 5px 10px; | ||
font-size: 14; | ||
`, | ||
normal: ` | ||
width: 130px; | ||
padding: 10px 20px; | ||
font-size: 16; | ||
`, | ||
big: ` | ||
width: 180px; | ||
padding: 20px 30px; | ||
font-size: 18; | ||
`, | ||
} | ||
|
||
const kind = (bg, color) => ` | ||
background: ${bg}; | ||
border-color: red; | ||
color: ${color}; | ||
transition: all .3s; | ||
` | ||
|
||
const kinds = { | ||
primary: kind('#1FB6FF', 'white'), | ||
secondary: kind('#5352ED', 'white'), | ||
cancel: kind('#FF4949', 'white'), | ||
dark: kind('#273444', 'white'), | ||
gray: kind('#8492A6', 'white'), | ||
} | ||
|
||
const getScale = ({ scale = 'normal' }) => scales[scale] | ||
const getKind = ({ kind = 'primary' }) => kinds[kind] | ||
|
||
const ButtonStyled = styled.TouchableOpacity` | ||
${getKind}; | ||
${getScale}; | ||
cursor: pointer; | ||
margin: 3px 5px; | ||
border: 0; | ||
border-radius: 3px; | ||
` | ||
|
||
const Text = styled.Text` | ||
${getScale}; | ||
width: 100%; | ||
padding: 0; | ||
color: white; | ||
text-align: center; | ||
color: ${p => kinds[p.outline]}; | ||
` | ||
|
||
export const Button = ({ | ||
scale = 'normal', | ||
kind = 'primary', | ||
outline = false, | ||
children, | ||
}) => ( | ||
<ButtonStyled scale={scale} kind={kind} outline={outline}> | ||
<Text scale={scale}>{children}</Text> | ||
</ButtonStyled> | ||
) | ||
|
||
Button.propTypes = { | ||
scales: t.oneOf(['small', 'normal', 'big']), | ||
kind: t.oneOf(['primary', 'secondary', 'cancel', 'dark', 'gray']), | ||
} | ||
|
||
Button.defaultProps = { | ||
scales: 'normal', | ||
kind: 'primary', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: Button | ||
menu: Components | ||
--- | ||
|
||
import { Playground, PropsTable } from 'docz' | ||
import { Button } from './Button' | ||
|
||
# Button | ||
|
||
Buttons make common actions more obvious and help users more easily perform them. Buttons use labels and sometimes icons to communicate the action that will occur when the user touches them. | ||
|
||
### Best practices | ||
|
||
- Group buttons logically into sets based on usage and importance. | ||
- Ensure that button actions are clear and consistent. | ||
- The main action of a group set can be a primary button. | ||
- Select a single button variation and do not mix them. | ||
|
||
## Properties | ||
|
||
<PropsTable of={Button} /> | ||
|
||
## Basic usage | ||
|
||
<Playground> | ||
<Button>Click me</Button> | ||
</Playground> | ||
|
||
## With different sizes | ||
|
||
<Playground> | ||
<Button scale="small">Click me</Button> | ||
<Button scale="normal">Click me</Button> | ||
<Button scale="big">Click me</Button> | ||
</Playground> | ||
|
||
## With different colors | ||
|
||
<Playground> | ||
<Button kind="primary">Click me</Button> | ||
<Button kind="secondary">Click me</Button> | ||
<Button kind="cancel">Click me</Button> | ||
<Button kind="dark">Click me</Button> | ||
<Button kind="gray">Click me</Button> | ||
</Playground> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Getting Started | ||
route: / | ||
order: 1 | ||
--- | ||
|
||
# Getting Started | ||
|
||
Design systems enable teams to build better products faster by making design reusable—reusability makes scale possible. This is the heart and primary value of design systems. A design system is a collection of reusable components, guided by clear standards, that can be assembled together to build any number of applications. | ||
|
||
Regardless of the technologies and tools behind them, a successful design system follows these guiding principles: | ||
|
||
- **It’s consistent**. The way components are built and managed follows a predictable pattern. | ||
- **It’s self-contained**. Your design system is treated as a standalone dependency. | ||
- **It’s reusable**. You’ve built components so they can be reused in many contexts. | ||
- **It’s accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web. | ||
- **It’s robust**. No matter the product or platform to which your design system is applied, it should perform with grace and minimal bugs. | ||
|
||
## Consistency | ||
|
||
Your first, most important task when starting out is to define the rules of your system, document them, and ensure that everyone follows them. When you have clearly documented code standards and best practices in place, designers and developers from across your organization can easily use and, more importantly, contribute to your design system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.