Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion pages/components/docs/getting-started.md
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'
Copy link
Contributor

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?

Copy link
Author

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


```


## 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>`:
Copy link
Contributor

Choose a reason for hiding this comment

The 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).
11 changes: 11 additions & 0 deletions pages/doc-components/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ const SideNav = ({router}) => (
>
<BorderBox border="none" borderBottom={1} borderRadius={0} borderColor="gray.2" bg="gray.0">
<Flex flexDirection="column" alignItems="start" p={5}>
<NextLink href="/components/docs/getting-started">
<Link
color="gray.9"
href="/components/docs/getting-started"
m={0}
mb={4}
fontWeight={router.pathname === '/components/docs/getting-started' ? 'bold' : null}
>
Getting Started
</Link>
</NextLink>
<NextLink href="/components/docs/system-props">
<Link
color="gray.9"
Expand Down