-
Notifications
You must be signed in to change notification settings - Fork 646
Getting started #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Getting started #518
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a711bb3
create getting started docs
00c7cc9
add getting started to side nav
6263282
Update pages/components/docs/getting-started.md
bf95abc
Update pages/components/docs/getting-started.md
b70f4e5
Update pages/components/docs/getting-started.md
6ba9c45
Update pages/components/docs/getting-started.md
743f0db
Update pages/components/docs/getting-started.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 +1,49 @@ | ||
| ### Coming soon | ||
| # Getting Started | ||
|
|
||
| To get started using Primer Components, run `npm install @primer/components` in your application. | ||
|
|
||
| You can now start importing Primer Components! There are a few ways to import Primer Components. You can either: | ||
|
|
||
| Import them individually from the main bundle: | ||
|
|
||
| ``` | ||
| import {Box, Flex} from '@primer/components' | ||
| ``` | ||
|
|
||
| or, if you've configured your application to tree-shake with webpack, you can import them indivdually from the `src` folder: | ||
|
|
||
| ``` | ||
| import Box from '@primer/components/src/Box' | ||
| import Flex from '@primer/components/src/Flex' | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ## Installing Peer Dependencies | ||
|
|
||
| Primer Components is shipped with a few libraries labeled as peer dependencies. These libraries are separated because they are commonly already installed in the host project. This keeps the bundle size down and allows you to specify the version number you'd like in your own project. | ||
|
|
||
| Before getting started using Primer Components, make sure that the following libraries are installed in your host project: | ||
|
|
||
| - `styled-components` at version 4.0.0 or higher | ||
| - `react` at versions 16.8.0 and higher | ||
|
|
||
|
|
||
| ## BaseStyles | ||
|
|
||
| In order to set basic color, font-family, and line-heights across your project, you will need to establish base Primer styles for your app by wrapping all of your Primer components in `<BaseStyles>`: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little unclear what "basic color" means at the beginning of this sentence. Maybe we should say "text color"? |
||
|
|
||
| ```jsx | ||
| import {BaseStyles, Box, Heading} from '@primer/components' | ||
|
|
||
| export default const MyApp = () => ( | ||
| <BaseStyles> | ||
| <Box m={4}> | ||
| <Heading mb={2}>Hello, world!</Heading> | ||
| <p>This will get Primer text styles.</p> | ||
| </Box> | ||
| </BaseStyles> | ||
| ) | ||
| ``` | ||
|
|
||
| This will apply the same `color`, `font-family`, and `line-height` styles to the `<body>` as [Primer CSS's base styles](https://github.com/primer/css/blob/master/src/base/base.scss#L15-L20). | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be recommending that people import components like this? A few people in the #react channel have had trouble with this kind of import because the imported code isn't processed by Babel.
In theory, we should be able to make tree-shaking work with imports like
import {Box, Flex} from '@primer/components', right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my assumption but webpack is still pulling in all exports even though our ESM module should work with tree-shaking fine. You can follow the discussion here: #456