1
1
mirror of https://github.com/primer/css.git synced 2024-12-28 08:31:58 +03:00
css/DEVELOP.md

97 lines
5.2 KiB
Markdown
Raw Normal View History

2019-04-25 23:42:54 +03:00
# Primer CSS Development
2018-10-19 02:49:10 +03:00
2019-02-15 03:51:29 +03:00
If you've made it this far, **thank you**! We appreciate your contribution, and hope that this document helps you along the way. If you have any questions or problems, don't hesitate to [file an issue](https://github.com/primer/css/issues/new).
2018-10-19 02:49:10 +03:00
## Structure
Primer CSS is published to [npm] as [@primer/css]. Each of Primer CSS's "modules" lives in a subfolder under `src/` with an `index.scss` in it. Generally speaking, the styles are divided into three primary themes:
* **Core** styles (in `core/`) are common dependencies, which include support variables, native element and typography styles, buttons, navigation, tooltips, etc.
* **Product** styles (in `product/`) are specific to github.com, and include components such as avatars, labels, markdown styles, popovers, and progress indicators.
* **Marketing** styles (in `marketing/`) are specific to GitHub marketing efforts, including international and event-focused sites as well as the more design-heavy feature pages on github.com. Marketing styles include new colors and button styles, and extend the core typography and whitespace scales.
### Paths
Here's what you need to know about how the files are structured in both git and in the published npm module:
* In git, all of the SCSS source files live in the `src/` directory.
* When published, all of the files in `src/` are "hoisted" to the package root so that you can import, say, utilities with:
```scss
@import "@primer/css/utilities/index.scss";
```
2019-02-12 10:04:12 +03:00
2019-02-15 21:56:40 +03:00
* All bundle interdependencies within Primer CSS are defined as relative imports (e.g. with `../`), so everything should work fine as long as the `@primer/css` directory is in one of your Sass include paths (i.e. `node_modules`).
2018-10-19 02:49:10 +03:00
## Workflow
The typical Primer workflow looks something like this:
1. `npm install` to install the development dependencies.
1. [Start Storybook](#storybook)
1. Navigate to the module you're working on and modify the SCSS and/or markdown files.
1. Test your changes in Storybook.
1. Push your work to a new branch.
1. Request a review from one of the Primer "core" team members.
2018-10-19 02:49:10 +03:00
## Install
Run `npm install` to install the npm dependencies.
2018-10-19 02:49:10 +03:00
## Docs site
The Primer CSS docs are built with React using [Doctocat](https://primer.style/doctocat) and automatically deployed on every push to this repo with [Now]. You can run the server locally with:
2018-10-19 02:49:10 +03:00
```sh
npm start
```
Then visit http://localhost:8000 to view the site.
### The docs directory
The [docs directory](./docs/) contains all of the documentation files in our docs site. Files are nested in the `/content` folder.
### URL tests
We have a script that catches inadvertent URL changes caused by renaming or deleting Markdown docs:
```sh
npm run test-urls
```
This script includes some exceptions for URLs that have been intentionally moved or removed in the process of moving away from the [GitHub Style Guide](https://styleguide.github.com/primer/), and which you will need to modify if you rename or remove either Markdown docs or their `path` frontmatter. See [#641](https://github.com/primer/css/pull/641) for more information.
## Storybook
To borrow a [metaphor from Brad Frost](http://bradfrost.com/blog/post/the-workshop-and-the-storefront/), the [docs site](#docs-site) is Primer CSS's storefront, and [Storybook] is its workshop.
Our Storybook setup allows you to view every HTML code block in Primer CSS's Markdown docs in isolation. To get started, run the Storybook server with:
2018-10-19 02:49:10 +03:00
```sh
npm run start-storybook
2018-10-19 02:49:10 +03:00
```
This should open up the site in your browser (if not, navigate to `http://localhost:8001`).
### Code blocks
All `html` fenced code blocks in `src/**/*.md` will be rendered as stories and listed under the relevant module's name in the left-hand nav. File changes should trigger a live reload automatically (after a brief delay).
2018-10-19 07:06:45 +03:00
2018-10-19 02:49:10 +03:00
2018-10-19 07:06:45 +03:00
## Scripts
2019-08-05 21:52:30 +03:00
Our [`package.json`](package.json) houses a collection of [run-scripts] that we use to maintain, test, build, and publish Primer CSS. Run `npm run <script>` with any of the following values for `<script>`:
2019-08-05 21:52:30 +03:00
* `fresh` does a "fresh" npm install (like `npm install -f`)
* `dist` runs `script/dist`, which creates CSS bundles of all the `index.scss` files in `src/`.
* `check-links` runs a link checker on your local development server (`localhost:3000`, started with `npm start`).
2019-08-05 21:52:30 +03:00
* `lint` lints both our SCSS and JavaScript source files.
* `lint-css` lints our SCSS source files.
* `lint-js` lints the JavaScript source files.
* `now-build` and `now-start` are run on [Now] to build and start the docs site server. `now-test` runs them both in order.
2019-08-05 21:52:30 +03:00
* `start` runs the documentation site locally (alias: `dev`).
* `test-urls` compares a (pre-generated) list of paths from the **deprecated** [Primer Style Guide](https://styleguide.github.com/primer/) to files in `pages/css`, and lets us know if we've inadvertently deleted or renamed anything.
2019-08-05 21:52:30 +03:00
The above list may not always be up-to-date. You can list all of the available scripts by calling `npm run` with no other arguments.
2018-10-19 07:06:45 +03:00
2018-10-19 02:49:10 +03:00
[@primer/css]: https://www.npmjs.com/package/@primer/css
2018-10-19 02:49:10 +03:00
[run-scripts]: https://docs.npmjs.com/cli/run-script
[storybook]: https://storybook.js.org/
2019-08-05 21:52:30 +03:00
[now]: https://zeit.co/now
[npm]: https://www.npmjs.com/
2018-10-19 07:06:45 +03:00
[npx]: https://www.npmjs.com/package/npx