-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from c8r/update-docs
Update docs
- Loading branch information
Showing
17 changed files
with
206 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# Composite Components | ||
|
||
In addition to creating primitive style components, | ||
Lab can be used to create multi-element composite components | ||
with the other style components in your library. | ||
|
||
To create a composite component, click the *Add* button in the upper right, | ||
then click the *Composite Component* tab. | ||
|
||
![library view](images/composite-library.png) | ||
|
||
![composite component tab](images/composite-tab.png) | ||
|
||
Next, in the *Imports* field start typing the name of the components that | ||
you plan to use for creating the composite component. | ||
A list of available components will appear in the text below the form field. | ||
|
||
**Note:** Lab currently only supports creating composite components with primitive style components and extended components; | ||
other composite components cannot be imported. | ||
|
||
![composite component imports field](images/composite-imports.png) | ||
|
||
Next, in the JSX editor, start using the imported components to build a composite component. | ||
To allow the values used in the composite component to be changed dynamically, use [React props][react-props]. | ||
|
||
Don't worry if the component isn't perfect at this step, you'll be able to edit it in the next step. | ||
|
||
![composite component JSX field](images/composite-jsx.png) | ||
|
||
Give your new component a unique name, then click the *Create Component* button to add the component to your library and start editing it. | ||
|
||
![composite component name field](images/composite-name.png) | ||
|
||
To start, make sure you add an example in the *Examples* editor to give your component some test content. | ||
|
||
![composite component examples](images/composite-examples.png) | ||
|
||
Since Lab components use [styled-system][system] you can adjust things like margin, padding and font-size for the components | ||
used in your composite component. | ||
|
||
|
||
- Next: [Importing Components](importing.md) | ||
|
||
[system]: https://github.com/jxnblk/styled-system | ||
[react-props]: https://reactjs.org/docs/components-and-props.html |
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,82 @@ | ||
|
||
# Exporting Lab Components | ||
|
||
Components created in Lab can be exported as static React components for use in a React application. | ||
|
||
Click the `File > Export Library` menu item and select a folder to export your components to. Note that any files that are named the same as a component in your library will be overwritten. | ||
|
||
## ThemeProviders | ||
|
||
Because Lab components make use of a ThemeProvider component, you will also need to use a ThemeProvider in your own application to use Lab components. | ||
|
||
Depending on the CSS-in-JS library you export to, importing a ThemeProvider will look like one of the examples below: | ||
|
||
[*styled-components*][sc-theme] | ||
|
||
```js | ||
import { ThemeProvider } from 'styled-components' | ||
``` | ||
|
||
[*glamorous*][g-theme] | ||
|
||
```js | ||
import { ThemeProvider } from 'glamorous' | ||
``` | ||
|
||
[*cxs*][cxs-theme] | ||
|
||
```js | ||
import ThemeProvider from 'cxs/ThemeProvider' | ||
``` | ||
|
||
[*fela*][fela-theme] | ||
|
||
```js | ||
import { ThemeProvider } from 'react-fela' | ||
``` | ||
|
||
[*emotion* & *theming*][emotion-theme] | ||
|
||
```js | ||
import { ThemeProvider } from 'theming' | ||
``` | ||
|
||
The theme created in a Lab project is automatically saved as a JSON file named `theme.json`. | ||
Because it‘s a static JSON file, it can be imported in projects using webpack 2 or higher. | ||
|
||
```js | ||
import theme from '../theme.json' | ||
``` | ||
|
||
At the root of your React application, wrap the entire component tree with the ThemeProvider. | ||
|
||
```jsx | ||
const App = props => ( | ||
<ThemeProvider theme={theme}> | ||
<Main /> | ||
</ThemeProvider> | ||
) | ||
``` | ||
|
||
[sc-theme]: https://www.styled-components.com/docs/advanced#theming | ||
[g-theme]: https://glamorous.rocks/advanced/#theming | ||
[cxs-theme]: https://github.com/jxnblk/cxs#theming | ||
[fela-theme]: http://fela.js.org/docs/guides/UsageWithReact.html#component-theming | ||
[emotion-theme]: https://github.com/emotion-js/emotion/blob/master/docs/theming.md | ||
|
||
|
||
## styled-system | ||
|
||
Lab components use [styled-system][system] for thematically controlled style props. | ||
Styled-system allows you to control font-size, margin, padding, color, and more via React props. [Read more][system] | ||
|
||
[system]: https://github.com/jxnblk/styled-system | ||
|
||
--- | ||
|
||
- [Installation](installation.md) | ||
- [Getting Started](getting-started.md) | ||
- [Extending components](extending.md) | ||
- [Composite components](composite-components.md) | ||
- [Importing components](importing.md) | ||
- [Exporting components](exporting.md) |
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,31 @@ | ||
|
||
# Extending Components | ||
|
||
Primitive style components can be extended when you want to take a component's existing styles and change them slightly, for example, making a BigButton variation of a Button component. | ||
|
||
To extend a component, click on the base component and click the *Extend Component* button in the lower part of the edit panel. | ||
|
||
![extend component button](images/extend-button.png) | ||
|
||
Give your new extended component a unique name and click *Create Component*. | ||
|
||
![extend component form](images/extend-name.png) | ||
|
||
The new extended component will inherit any styles set on its base component. | ||
Edit any styles you'd like to override such as font size and padding. | ||
|
||
![extended component detail](images/extend-detail.png) | ||
|
||
![extended component library view](images/extend-library.png) | ||
|
||
Extended components are linked to their base component, which means | ||
that any changes made to the Button component in this example | ||
will also be inherited by the extended component. | ||
|
||
In this example, the border radius was adjusted on the Button component, | ||
and the BigButton component inherited the new border radius. | ||
|
||
![extended component library view](images/extend-base-edits.png) | ||
|
||
|
||
- Next: [Composite Components](composite-components.md) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,24 @@ | ||
|
||
# Importing Components | ||
|
||
A React component created outside of Lab can be imported to Lab. | ||
This is helpful for viewing your Lab components in the context | ||
of others, and for using Lab as an isolated development environment. | ||
|
||
To import a component, select the `File > Import Component` menu item. | ||
Navigate to a component within the same folder as your project to select a component for importing. | ||
|
||
![external component](images/detail-external.png) | ||
|
||
Once a component is loaded into your project, you can make changes to the source file in your own text editor, | ||
and changes will be automatically reloaded in Lab. | ||
|
||
*Troubleshooting* | ||
|
||
- If a component fails to load, the preview should display an error to help with debugging. | ||
- Make sure components are located within the same root folder as your Lab project or in a subdirectory. | ||
- Make sure any npm dependencies have been installed in your project by running `npm install` in your terminal. | ||
- Make sure your component *DOES NOT* make use of any webpack loaders or other build-specific tools. | ||
- Lab currently only supports standard ECMAScript (ES). Components written in other formats such as TypeScript will need to be converted to ES before importing. | ||
|
||
- Next: [Exporting Components](exporting.md) |