@carbon/type 11.25.1 → 11.26.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +85 -110
  2. package/package.json +10 -7
  3. package/telemetry.yml +7 -0
package/README.md CHANGED
@@ -33,49 +33,39 @@ These features include:
33
33
  | [Scale](#type-scale) | Provides the type scale. Can access the size at any given step (step 1, 2, 3, etc) |
34
34
  | [Styles](#type-styles) | Provides type styles for your application (heading-01, body-long-01, etc) |
35
35
 
36
- To include `@carbon/type` in your project, you can write the following in your
37
- Sass file:
36
+ The `@carbon/type` package enables you to use typography from the IBM Design
37
+ Language, including the type scale and fonts, along with typography design
38
+ tokens from the Carbon Design System. It also comes with opinionated defaults
39
+ for type styles on common elements like `h1`, `h2`, `p`, etc.
40
+
41
+ You can use this package by writing the following:
38
42
 
39
43
  ```scss
40
- @import '@carbon/type/scss/type';
41
- @import '@carbon/type/scss/font-face/mono';
42
- @import '@carbon/type/scss/font-face/sans';
44
+ @use '@carbon/type';
45
+
46
+ // Include type reset
47
+ @include type.reset();
48
+
49
+ // Include default type styles, targets h1, h2, h3, etc
50
+ @include type.default-type();
51
+
52
+ // Include utility classes for type-related properties
53
+ @include type.type-classes();
43
54
 
44
- @include carbon--type-reset();
45
- @include carbon--font-face-mono();
46
- @include carbon--font-face-sans();
55
+ .selector {
56
+ // Include a type style
57
+ @include type.type-style('productive-heading-01');
58
+ }
47
59
  ```
48
60
 
49
61
  This should include the default type reset from the project, in addition to
50
62
  font-face definitions for IBM Plex Mono and IBM Plex Sans that come from Google
51
63
  Fonts.
52
64
 
53
- If you are using `@carbon/elements`, the import paths become:
54
-
55
- ```scss
56
- @import '@carbon/elements/scss/type/path-to-import';
57
- ```
58
-
59
- For example:
65
+ If you are using `@carbon/react`, the import paths become:
60
66
 
61
67
  ```scss
62
- @import '@carbon/elements/scss/type/styles';
63
- ```
64
-
65
- In addition, you will need to setup `node-sass` so that `node_modules` is
66
- included in the `includePaths` option. Often times, the tool that you are using
67
- to build Sass files in your project should expose this option for you to set.
68
-
69
- For example, if you are using Webpack you would use `node-sass` and
70
- `sass-loader` with the following configuration for `includePaths`:
71
-
72
- ```js
73
- {
74
- loader: 'sass-loader',
75
- options: {
76
- includePaths: ['node_modules'],
77
- },
78
- }
68
+ @use '@carbon/react/scss/type';
79
69
  ```
80
70
 
81
71
  ### Type styles
@@ -91,55 +81,19 @@ You can find a full reference of the type styles that are available on the
91
81
  You can include a token in your Sass file by writing:
92
82
 
93
83
  ```scss
94
- @import '@carbon/type/scss/styles';
84
+ @use '@carbon/type';
95
85
 
96
- @include carbon--type-style('token-name');
86
+ @include type.type-style('token-name');
97
87
  ```
98
88
 
99
89
  In addition, if the type style you are using has a fluid style then you can pass
100
- in `true` as the second argument to `carbon--type-style` to enable fluid styles.
101
- For example:
102
-
103
- ```scss
104
- @import '@carbon/type/scss/styles';
105
-
106
- @include carbon--type-style('token-name', true);
107
- ```
108
-
109
- ### Font-face
110
-
111
- `@carbon/type` supports three font-face definitions that you can use to add IBM
112
- Plex to your project. These font-face definitions include support for:
113
-
114
- - IBM Plex Mono
115
- - IBM Plex Sans
116
- - IBM Plex Serif
117
-
118
- For most projects, only IBM Plex Mono and IBM Plex Sans is necessary. We also
119
- provide IBM Plex Serif if you are building an editorial or marketing project.
120
-
121
- These font-face definitions are pulling the above fonts from an Akamai CDN.
122
-
123
- You can include each font-face definition by including the corresponding file
124
- and calling its mixin. For example, if you wanted to include IBM Plex Mono in
125
- your project you would write the following in your Sass file:
126
-
127
- ```scss
128
- @import '@carbon/type/scss/font-face/mono';
129
-
130
- @include carbon--font-face-mono();
131
- ```
132
-
133
- Similarly, you can include IBM Plex Sans and IBM Plex Serif by writing:
90
+ in `true` as the second argument to `type-style` to enable fluid styles. For
91
+ example:
134
92
 
135
93
  ```scss
136
- @import '@carbon/type/scss/font-face/mono';
137
- @import '@carbon/type/scss/font-face/sans';
138
- @import '@carbon/type/scss/font-face/serif';
94
+ @use '@carbon/type';
139
95
 
140
- @include carbon--font-face-mono();
141
- @include carbon--font-face-sans();
142
- @include carbon--font-face-serif();
96
+ @include type.type-style('token-name', true);
143
97
  ```
144
98
 
145
99
  ### Type classes
@@ -152,19 +106,29 @@ You can include type classes in your project by writing the following in your
152
106
  Sass file:
153
107
 
154
108
  ```scss
155
- @import '@carbon/type/scss/classes';
109
+ @use '@carbon/type';
110
+
111
+ :root {
112
+ @include type.type-classes();
113
+ }
114
+ ```
115
+
116
+ And then add the appropriate classes to the element you want to style
117
+
118
+ ```html
119
+ <span className="cds--type-mono">Test sentence</span>
156
120
  ```
157
121
 
158
- | Selector | Description |
159
- | ------------------------ | ----------------------------------------- |
160
- | `.bx--type-mono` | Specify the font face as IBM Plex Mono |
161
- | `.bx--type-sans` | Specify the font face as IBM Plex Sans |
162
- | `.bx--type-serif` | Specify the font face as IBM Plex Serif |
163
- | `.bx--type-light` | Specify the font weight as light (300) |
164
- | `.bx--type-regular` | Specify the font weight as regular (400) |
165
- | `.bx--type-semibold` | Specify the font weight as semibold (600) |
166
- | `.bx--type-italic` | Specify the font style as italic |
167
- | `.bx--type-<type-style>` | Set styles for the given type style |
122
+ | Selector | Description |
123
+ | ------------------------- | ----------------------------------------- |
124
+ | `.cds--type-mono` | Specify the font face as IBM Plex Mono |
125
+ | `.cds--type-sans` | Specify the font face as IBM Plex Sans |
126
+ | `.cds--type-serif` | Specify the font face as IBM Plex Serif |
127
+ | `.cds--type-light` | Specify the font weight as light (300) |
128
+ | `.cds--type-regular` | Specify the font weight as regular (400) |
129
+ | `.cds--type-semibold` | Specify the font weight as semibold (600) |
130
+ | `.cds--type-italic` | Specify the font style as italic |
131
+ | `.cds--type-<type-style>` | Set styles for the given type style |
168
132
 
169
133
  ### Font family
170
134
 
@@ -173,39 +137,40 @@ You can access the font family information by including the following import in
173
137
  your Sass file:
174
138
 
175
139
  ```scss
176
- @import '@carbon/type/scss/font-family';
140
+ @use '@carbon/type';
177
141
  ```
178
142
 
179
- The font stacks are available under the `$carbon--font-families` variable. You
180
- can also access a specific font family by using the `carbon--font-family`
181
- function by doing:
143
+ The font stacks are available under the `$font-families` variable. You can also
144
+ access a specific font family by using the `font-family` function by doing:
182
145
 
183
146
  ```scss
184
147
  .my-selector {
185
- font-family: carbon--font-family('mono');
148
+ font-family: type.font-family('mono');
186
149
  }
187
150
  ```
188
151
 
189
- You can also use the `carbon--font-family` mixin to automatically set the
190
- `font-family` property for you:
152
+ You can also use the `font-family` mixin to automatically set the `font-family`
153
+ property for you:
191
154
 
192
155
  ```scss
193
156
  .my-selector {
194
- @include carbon--font-family('mono');
157
+ @include type.font-family('serif');
195
158
  }
196
159
  ```
197
160
 
198
- You can see all the available font families in `$carbon--font-families` .
161
+ You can see all the available font families in `$font-families` .
199
162
 
200
163
  ### Reset
201
164
 
202
- An optional type reset is provided under the `carbon--type-reset` mixin. You can
203
- include this mixin by writing the following in your Sass file:
165
+ An optional type reset is provided under the `reset` mixin. You can include this
166
+ mixin by writing the following in your Sass file:
204
167
 
205
168
  ```scss
206
- @import '@carbon/type/scss/reset';
169
+ @use '@carbon/type';
207
170
 
208
- @include carbon--type-reset();
171
+ :root {
172
+ @include type.reset();
173
+ }
209
174
  ```
210
175
 
211
176
  This reset sets some top-level properties on `html` and `body`, namely
@@ -214,35 +179,33 @@ This reset sets some top-level properties on `html` and `body`, namely
214
179
 
215
180
  ### Type scale
216
181
 
217
- A type scale is provided through the `$carbon--type-scale` variable and
218
- corresponding `carbon--type-scale` function and mixin. However, for specifying
219
- type styles, the recommendation is to use [type styles](#type-styles) .
182
+ A type scale is provided through the `$type-scale` variable and corresponding
183
+ `type-scale` function and mixin. However, for specifying type styles, the
184
+ recommendation is to use [type styles](#type-styles) .
220
185
 
221
186
  If you are looking to use the type scale, you can include all the scale-related
222
187
  utilities and variables by writing the following in your Sass file:
223
188
 
224
189
  ```scss
225
- @import '@carbon/type/scss/scale';
190
+ @use '@carbon/type';
226
191
  ```
227
192
 
228
- You can access a specific step in the type scale by using the
229
- `carbon--type-scale` function:
193
+ You can access a specific step in the type scale by using the `type-scale`
194
+ function:
230
195
 
231
196
  ```scss
232
- @import '@carbon/type/scss/scale';
233
-
234
197
  .my-selector {
235
- font-size: carbon--type-scale(1);
198
+ font-size: type.type-scale(1);
236
199
  }
237
200
  ```
238
201
 
239
202
  There is also a `type-scale` mixin that will set `font-size` for your directly:
240
203
 
241
204
  ```scss
242
- @import '@carbon/type/scss/scale';
205
+ @use '@carbon/type';
243
206
 
244
207
  .my-selector {
245
- @include carbon--type-scale(1);
208
+ @include type.type-scale(4);
246
209
  }
247
210
  ```
248
211
 
@@ -251,7 +214,10 @@ There is also a `type-scale` mixin that will set `font-size` for your directly:
251
214
  If you're looking for more examples on how to use `@carbon/type`, we have some
252
215
  examples that you can check out:
253
216
 
254
- - [styled-components](./examples/styled-components)
217
+ - [Stackblitz](https://stackblitz.com/edit/github-wdcdqx?file=src%2Findex.scss)
218
+
219
+ You can also see more documentation regarding the available tokens
220
+ [here](./docs/sass.md)
255
221
 
256
222
  ## 🙌 Contributing
257
223
 
@@ -262,3 +228,12 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀
262
228
  ## 📝 License
263
229
 
264
230
  Licensed under the [Apache 2.0 License](/LICENSE).
231
+
232
+ ## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry
233
+
234
+ This package uses IBM Telemetry to collect metrics data. By installing this
235
+ package as a dependency you are agreeing to telemetry collection. To opt out,
236
+ see
237
+ [Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
238
+ For more information on the data being collected, please see the
239
+ [IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/type",
3
3
  "description": "Typography for digital and software products using the Carbon Design System",
4
- "version": "11.25.1",
4
+ "version": "11.26.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -17,7 +17,8 @@
17
17
  "scss",
18
18
  "src",
19
19
  "umd",
20
- "index.scss"
20
+ "index.scss",
21
+ "telemetry.yml"
21
22
  ],
22
23
  "keywords": [
23
24
  "eyeglass-module",
@@ -35,14 +36,16 @@
35
36
  },
36
37
  "scripts": {
37
38
  "build": "yarn clean && carbon-cli bundle src/index.js --name CarbonType && carbon-cli check \"scss/*.scss\"",
38
- "clean": "rimraf css es lib umd"
39
+ "clean": "rimraf css es lib umd",
40
+ "postinstall": "ibmtelemetry --config=telemetry.yml"
39
41
  },
40
42
  "dependencies": {
41
- "@carbon/grid": "^11.21.1",
42
- "@carbon/layout": "^11.20.1"
43
+ "@carbon/grid": "^11.22.0-rc.0",
44
+ "@carbon/layout": "^11.21.0-rc.0",
45
+ "@ibm/telemetry-js": "^1.2.1"
43
46
  },
44
47
  "devDependencies": {
45
- "@carbon/cli": "^11.15.1",
48
+ "@carbon/cli": "^11.16.0-rc.0",
46
49
  "@carbon/test-utils": "^10.30.0",
47
50
  "change-case": "^4.1.1",
48
51
  "css": "^3.0.0",
@@ -54,5 +57,5 @@
54
57
  "sassDir": "scss",
55
58
  "needs": "^1.3.0"
56
59
  },
57
- "gitHead": "d6904c019acc9b8cb8f5a01732bc963a71fa93bf"
60
+ "gitHead": "fd9030978919c8d2ce0c102db94aeabf88563c34"
58
61
  }
package/telemetry.yml ADDED
@@ -0,0 +1,7 @@
1
+ # yaml-language-server: $schema=https://unpkg.com/@ibm/telemetry-config-schema@v1/dist/config.schema.json
2
+ version: 1
3
+ projectId: 43a17f29-6354-4c01-b4ec-920a1248f0f7
4
+ endpoint: https://collector-prod.1am6wm210aow.us-south.codeengine.appdomain.cloud/v1/metrics
5
+ collect:
6
+ npm:
7
+ dependencies: null