Skip to content

Commit 09119d0

Browse files
committed
add getting started guide
1 parent c90a1b5 commit 09119d0

File tree

6 files changed

+153
-23
lines changed

6 files changed

+153
-23
lines changed

content/foundations/primitives/color.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Color
33
description:
4-
An overview of all available color CSS variables.
4+
An overview of all available color CSS variables
55
---
66

77
<Note>The following color tokens are still in beta and require a fallback value be used.</Note>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: Getting started
3+
description:
4+
Get started with Primer Primitives
5+
---
6+
7+
## Installation
8+
9+
To get started using Primer Primitives, install the package with your package manager of choice:
10+
11+
npm:
12+
13+
```bash
14+
npm install @primer/primitives
15+
```
16+
yarn:
17+
18+
```bash
19+
yarn add @primer/primitives
20+
```
21+
22+
## Usage
23+
24+
Primer Primitive design tokens are available to consume as CSS variables. Import the desired token files into the root of your project.
25+
26+
For sizing, spacing and typography tokens, import the following files:
27+
28+
```css
29+
@import '@primer/primitives/dist/css/base/size/size.css';
30+
@import '@primer/primitives/dist/css/base/typography/typography.css';
31+
@import '@primer/primitives/dist/css/functional/size/border.css';
32+
@import '@primer/primitives/dist/css/functional/size/breakpoints.css';
33+
@import '@primer/primitives/dist/css/functional/size/size-coarse.css';
34+
@import '@primer/primitives/dist/css/functional/size/size-fine.css';
35+
@import '@primer/primitives/dist/css/functional/size/size.css';
36+
@import '@primer/primitives/dist/css/functional/size/viewport.css';
37+
@import '@primer/primitives/dist/css/functional/typography/typography.css';
38+
```
39+
40+
Color tokens are grouped by individual theme files:
41+
42+
```css
43+
@import '@primer/primitives/dist/css/functional/themes/light.css';
44+
@import '@primer/primitives/dist/css/functional/themes/light-tritanopia.css';
45+
@import '@primer/primitives/dist/css/functional/themes/light-high-contrast.css';
46+
@import '@primer/primitives/dist/css/functional/themes/light-colorblind.css';
47+
@import '@primer/primitives/dist/css/functional/themes/dark.css';
48+
@import '@primer/primitives/dist/css/functional/themes/dark-colorblind.css';
49+
@import '@primer/primitives/dist/css/functional/themes/dark-dimmed.css';
50+
@import '@primer/primitives/dist/css/functional/themes/dark-high-contrast.css';
51+
@import '@primer/primitives/dist/css/functional/themes/dark-tritanopia.css';
52+
```
53+
54+
## Theming
55+
56+
Primer color design tokens are made available within data-attribute selectors on the `body` tag or other high level dom element. There are three distinct data-attributes used to handle theming: `data-color-mode`, `data-light-theme`, and `data-dark-theme`.
57+
58+
### Color mode
59+
60+
The `data-color-mode` attribute is used to set the color mode of the theme. The value of the attribute should be either `auto`, `light`, or `dark`. When set to `auto`, the theme will automatically switch between light and dark based on the user's system preferences.
61+
62+
### Color theme
63+
64+
The `data-light-theme` and `data-dark-theme` attributes are used to set the theme. The value of the attribute should be the name of the theme file, replacing dashes `-` with underscore `_`. For example, to use the light theme, set the `data-light-theme` attribute to `light`.
65+
66+
```html
67+
<body data-color-mode="light" data-light-theme="light" data-dark-theme="dark">
68+
```
69+
70+
### Available themes
71+
72+
- light: `light`
73+
- light-tritanopia: `light_tritanopia`
74+
- light-high-contrast: `light_high_contrast`
75+
- light-colorblind: `light_colorblind`
76+
- dark: `dark`
77+
- dark-colorblind: `dark_colorblind`
78+
- dark-dimmed: `dark_dimmed`
79+
- dark-high-contrast: `dark_high_contrast`
80+
- dark-tritanopia: `dark_tritanopia`
81+
82+
## CSS variables
83+
84+
To see all available tokens, reference the following guides:
85+
86+
- [Colors](/docs/primitives/colors)
87+
- [Spacing](/docs/primitives/spacing)
88+
- [Typography](/docs/primitives/typography)

content/foundations/primitives/size.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Size
33
description:
4-
An overview of all available size CSS variables.
4+
An overview of all available size CSS variables
55
---
66

77
## Base

content/foundations/primitives/token-names.mdx

+60-20
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
---
22
title: Token names
33
description:
4-
An explanation of Primer's design token naming convention.
4+
An explanation of Primer's design token naming convention
55
---
66

77
## Intro
88

99
Naming things is hard. Primer design tokens are named using a consistent convention to make it easier to understand what they do and how they should be used at a glance.
1010

11-
img of token breakdown
11+
<img width="960" alt="a design token broken down by property, variant, and scale" src="https://github.com/primer/react/assets/18661030/85ec0655-0426-4a79-9ac0-0bee97e5e9b1" />
1212

1313
## Categories
1414

15-
Our naming convention is broken down into three categories: **base, component/pattern, functional**. Each category is a subset of the over-arching convention.
15+
<img width="960" alt="graphic listing out prefix, namespace, pattern, variant, property, variant, and scale all color coded to match help illustrate the differences between them" src="https://github.com/primer/react/assets/18661030/d89da86b-5b9d-43f2-b745-126fe35ea500" />
1616

17-
Across all categories, the `property` value is always required. This value specifies exactly how a token is indended to be applied to a UI.
17+
This naming convention is broken down into three categories: **base, component/pattern, functional**. Each category is a subset of the over-arching convention.
1818

19-
<img width="960" alt="graphic listing out namespace, pattern, variant, property, variant, and scale all color coded to match ADR docs" src="https://github.com/primer/react/assets/18661030/d89da86b-5b9d-43f2-b745-126fe35ea500" />
19+
Across all categories, the [property](#property-required) value is always required. This value specifies exactly how a token is indended to be applied to a UI.
2020

2121
### Base
2222

2323
Base tokens are the lowest level tokens and map directly to a raw value.
2424

25-
<img width="960" alt="a graphic illustrating five words, uniquely colored and displayed left to right in a horizontal direction. Words are prefix, namespace (with an asterix), property (with an asterix), variant and scale. Followed by color coded tokens, which will be described in the next section." src="https://github.com/primer/react/assets/18661030/3bffcdaf-60f1-4824-b30c-25951f2d5156" />
25+
<img width="960" alt="a graphic illustrating five words, uniquely colored and displayed left to right in a horizontal direction. Words are prefix, namespace, pattern, variant, property, variant and scale. The pattern and variant words are dimmed to signify their exclusions from this pattern. Followed by color coded tokens, which will be described in the next section." src="https://github.com/primer/react/assets/18661030/3bffcdaf-60f1-4824-b30c-25951f2d5156" />
2626

2727

2828
#### Example `base` tokens
2929

3030
```
31-
brand-base-color-lime-5
3231
base-size-4
3332
base-color-green-5
33+
brand-base-color-lime-5
3434
base-fontWeight-semibold
3535
```
3636

3737
### Functional
3838

3939
Functional tokens represent global UI patterns.
4040

41-
<img width="960" alt="a graphic illustrating six words, each uniquely color coded and displayed left to right in a horizontal direction. Words are prefix, type, property (with an asterix), variant and scale. Followed by example tokens that are similarly color coded and will be described again in the next section." src="https://github.com/primer/react/assets/18661030/7124ced5-96d1-4479-996a-641579a2cd4c" />
41+
<img width="960" alt="a graphic illustrating five words, uniquely colored and displayed left to right in a horizontal direction. Words are prefix, namespace, pattern, variant, property, variant and scale. The namespace, pattern and variant words are dimmed to signify their exclusions from this pattern. Followed by color coded tokens, which will be described in the next section." src="https://github.com/primer/react/assets/18661030/7124ced5-96d1-4479-996a-641579a2cd4c" />
4242

4343
#### Example `functional` tokens
4444

@@ -51,62 +51,62 @@ boxShadow-inset-thick
5151

5252
### Component/pattern
5353

54-
Component/pattern represents component and pattern specific tokens which should only be used in component CSS.
54+
Component/pattern tokens should only be used in component CSS.
5555

56-
<img width="960" alt="a graphic illustrating six words, each uniquely color coded and displayed left to right in a horizontal direction. Words are prefix, pattern, variant, type, property (with an asterix) and scale. Followed by similarly color coded tokens, which will be described again in the next section." src="https://github.com/primer/react/assets/18661030/d1d77c2f-e8c4-4d38-b295-1231bc82648f" />
56+
<img width="960" alt="a graphic illustrating five words, uniquely colored and displayed left to right in a horizontal direction. Words are prefix, namespace, pattern, variant, property, variant and scale. The namespace word is dimmed to signify its exclusion from this pattern. Followed by color coded tokens, which will be described in the next section." src="https://github.com/primer/react/assets/18661030/d1d77c2f-e8c4-4d38-b295-1231bc82648f" />
5757

5858

5959
#### Example `component`/`pattern` tokens
6060

6161
```
62-
control-danger-bgColor-hover
63-
button-primary-bgColor-rest
64-
brand-control-xsmall-paddingInline-normal
62+
control-danger-borderColor-rest
63+
button-primary-bgColor-hover
64+
brand-overlay-bgColor
6565
text-codeInline-fontSize
6666
```
6767

6868
## Convention breakdown
6969

7070
### Prefix
7171

72-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/7519380f-7cd2-4304-87b9-5556f4801af8" />
72+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/7519380f-7cd2-4304-87b9-5556f4801af8" />
7373

7474
Prefix provides top-level encapsulation of a particular flavor of Primer, such as Primer Brand. It can be used for protected base tokens like Brand color scales, or value overrides for traditional Primer tokens in order to avoid collisions.
7575

7676
`brand`: used for marketing/brand specific tokens.
7777

7878
### Namespace
7979

80-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/50899a02-1fac-474c-b99c-426d6853c92c" />
80+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/50899a02-1fac-474c-b99c-426d6853c92c" />
8181

8282
Namespace creates a scope used to identify how a token may be used. For example, `base` tokens are the lowest level and are generally used as a reference for functional tokens (the next step above).
8383

8484
`base`: represents global, constant values. These are the lowest level tokens and map directly to a raw value.
8585

8686
### Pattern
8787

88-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/abc16bcd-64e3-43a7-bca6-82a31190acf1" />
88+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/abc16bcd-64e3-43a7-bca6-82a31190acf1" />
8989

90-
Pattern represents a group of design decisions, or a specific Primer component. Whenever possible, aim to use a name that is generic enough to influence related components. In the example below, the item `control` can be used for multiple types of controls like buttons, inputs, or interactive action list items.
90+
Pattern represents a group of design decisions, or a specific Primer component. Whenever possible, aim to use a name that is generic enough to influence related components. For example, the pattern `control` can be used for multiple types of controls like buttons, inputs, or interactive action list items.
9191

9292
For pattern and component names that are multi-word, use camelCase to separate each word.
9393

9494
### Variant
9595

96-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/6d105711-c815-488d-997c-dfd639cb8123" />
96+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/6d105711-c815-488d-997c-dfd639cb8123" />
9797

9898
Variant can be used to either modify the **pattern** or **property**. Only one variant is allowed per token. It typically represents a stylistic variant of a token such as color (danger) or size (small).
9999

100100

101101
### Property (required)
102102

103-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/87514222-3db7-4e98-bd81-5ce8d40d2529" />
103+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/87514222-3db7-4e98-bd81-5ce8d40d2529" />
104104

105105
Property is used to represent an item’s style. It usually matches a [CSS property](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference#index), but it can also store other conceptual definitions such as `size`, `minTarget`, etc. Use camelCase for multi-word properties.
106106

107107
### Scale
108108

109-
<img width="960" alt="wip" src="https://github.com/primer/react/assets/18661030/9a1e8baf-66e2-494c-9ff3-0655d285f145" />
109+
<img width="960" alt="" src="https://github.com/primer/react/assets/18661030/9a1e8baf-66e2-494c-9ff3-0655d285f145" />
110110

111111
Scale represents ordinals to describe things like state, density, thickness, range, and speed. Scale names strive to follow our [size naming convention standards](https://github.com/github/primer/blob/main/adrs/2022-02-09-size-naming-guidelines.md).
112112

@@ -132,3 +132,43 @@ Individual name blocks for each token should be separated with a single characte
132132
<Caption>Don't use other characters to separate words.</Caption>
133133
</Dont>
134134
</DoDontContainer>
135+
136+
## Color modifiers
137+
138+
We use the following values to modify the color [variant](#variant):
139+
140+
- `default` - The default color variant for a given token. Example: `fgColor-default`
141+
- `muted` - The secondary color variant for a given token. Example: `fgColor-muted`
142+
- `emphasis` - The opposite of "muted", emphasis is a stronger color variant. Example: `bgColor-accent-emphasis`
143+
144+
## Size modifiers
145+
146+
Size modifiers are often found as part of the [scale](#scale) block. The following describes how we name size modifiers for each category.
147+
148+
### General-purpose t-shirt sizes
149+
150+
```
151+
xsmall | small | medium | large | xlarge | xxlarge
152+
```
153+
154+
### Density
155+
156+
Use `normal` as the default size
157+
158+
```
159+
condensed | normal | spacious
160+
```
161+
162+
### Thickness names
163+
164+
Use `thin` as the default size
165+
166+
```
167+
thin | thick | thicker
168+
```
169+
170+
### Viewport ranges names
171+
172+
```
173+
narrow | regular | wide
174+
```

content/foundations/primitives/typography.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Typography
33
description:
4-
An overview of all available typography CSS variables.
4+
An overview of all available typography CSS variables
55
---
66

77
## Weight

src/@primer/gatsby-theme-doctocat/nav.yml

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
- title: Primitives
112112
url: /foundations/primitives
113113
children:
114+
- title: Getting started
115+
url: /foundations/primitives/getting-started
114116
- title: Token names
115117
url: /foundations/primitives/token-names
116118
- title: Color

0 commit comments

Comments
 (0)