@octaviaflow/type 1.0.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 (49) hide show
  1. package/README.md +239 -0
  2. package/es/index.js +850 -0
  3. package/index.scss +14 -0
  4. package/lib/index.js +922 -0
  5. package/package.json +59 -0
  6. package/scss/_classes.scss +42 -0
  7. package/scss/_default-type.scss +50 -0
  8. package/scss/_font-family.scss +105 -0
  9. package/scss/_prefix.scss +28 -0
  10. package/scss/_reset.scss +42 -0
  11. package/scss/_scale.scss +58 -0
  12. package/scss/_styles.scss +902 -0
  13. package/src/__tests__/__snapshots__/fontFamily-test.js.snap +13 -0
  14. package/src/__tests__/__snapshots__/fontFamily.test.js.snap +13 -0
  15. package/src/__tests__/__snapshots__/fontWeight-test.js.snap +11 -0
  16. package/src/__tests__/__snapshots__/fontWeight.test.js.snap +11 -0
  17. package/src/__tests__/__snapshots__/reset-test.js.snap +11 -0
  18. package/src/__tests__/__snapshots__/reset.test.js.snap +11 -0
  19. package/src/__tests__/__snapshots__/scale-test.js.snap +29 -0
  20. package/src/__tests__/__snapshots__/scale.test.js.snap +29 -0
  21. package/src/__tests__/__snapshots__/styles-test.js.snap +411 -0
  22. package/src/__tests__/__snapshots__/styles.test.js.snap +411 -0
  23. package/src/__tests__/exports-test.js +88 -0
  24. package/src/__tests__/exports.test.js +88 -0
  25. package/src/__tests__/fluid-test.js +71 -0
  26. package/src/__tests__/fluid.test.js +71 -0
  27. package/src/__tests__/fontFamily-test.js +33 -0
  28. package/src/__tests__/fontFamily.test.js +33 -0
  29. package/src/__tests__/fontWeight-test.js +33 -0
  30. package/src/__tests__/fontWeight.test.js +33 -0
  31. package/src/__tests__/reset-test.js +23 -0
  32. package/src/__tests__/reset.test.js +23 -0
  33. package/src/__tests__/scale-test.js +31 -0
  34. package/src/__tests__/scale.test.js +31 -0
  35. package/src/__tests__/styles-test.js +18 -0
  36. package/src/__tests__/styles.test.js +18 -0
  37. package/src/__tests__/tokens-test.js +21 -0
  38. package/src/__tests__/tokens.test.js +21 -0
  39. package/src/fluid.js +89 -0
  40. package/src/fontFamily.js +33 -0
  41. package/src/fontWeight.js +27 -0
  42. package/src/index.js +31 -0
  43. package/src/print.js +39 -0
  44. package/src/reset.js +32 -0
  45. package/src/scale.js +33 -0
  46. package/src/styles.js +491 -0
  47. package/src/tokens.js +132 -0
  48. package/telemetry.yml +16 -0
  49. package/umd/index.js +926 -0
package/README.md ADDED
@@ -0,0 +1,239 @@
1
+ # @octaviaflow/type
2
+
3
+ > Typography for digital and software products using the Carbon Design System
4
+
5
+ ## Getting started
6
+
7
+ To install `@octaviaflow/type` in your project, you will need to run the following
8
+ command using [npm](https://www.npmjs.com/):
9
+
10
+ ```bash
11
+ npm install -S @octaviaflow/type
12
+ ```
13
+
14
+ If you prefer [Yarn](https://yarnpkg.com/en/), use the following command
15
+ instead:
16
+
17
+ ```bash
18
+ yarn add @octaviaflow/type
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ `@octaviaflow/type` provides a variety of ways to work with typography from the IBM
24
+ Design Language. You can use all of these features either in JavaScript or Sass.
25
+ These features include:
26
+
27
+ | Feature | Description |
28
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
29
+ | [Font face](#font-face) | Include IBM Plex™ font faces in your application. Uses Akamai CDN |
30
+ | [Type classes](#type-classes) | Helpers to use type styles directly. Not included by default |
31
+ | [Font family](#font-family) | Defines the font stack for IBM Plex™ in your application, provides helpers for working with font definitions |
32
+ | [Reset](#reset) | Provides a high-level CSS Reset to use in your project |
33
+ | [Scale](#type-scale) | Provides the type scale. Can access the size at any given step (step 1, 2, 3, etc) |
34
+ | [Styles](#type-styles) | Provides type styles for your application (heading-01, body-long-01, etc) |
35
+
36
+ The `@octaviaflow/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:
42
+
43
+ ```scss
44
+ @use '@octaviaflow/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();
54
+
55
+ .selector {
56
+ // Include a type style
57
+ @include type.type-style('productive-heading-01');
58
+ }
59
+ ```
60
+
61
+ This should include the default type reset from the project, in addition to
62
+ font-face definitions for IBM Plex Mono and IBM Plex Sans that come from Google
63
+ Fonts.
64
+
65
+ If you are using `@octaviaflow/react`, the import paths become:
66
+
67
+ ```scss
68
+ @use '@octaviaflow/react/scss/type';
69
+ ```
70
+
71
+ ### Type styles
72
+
73
+ Instead of using a type scale, `@octaviaflow/type` provides tokens that represent
74
+ what we call type styles. These tokens have a variety of properties for styling
75
+ how text is rendered on a page.
76
+
77
+ You can find a full reference of the type styles that are available on the
78
+ [Carbon Design System website](https://www.carbondesignsystem.com/guidelines/typography/type-sets)
79
+ .
80
+
81
+ You can include a token in your Sass file by writing:
82
+
83
+ ```scss
84
+ @use '@octaviaflow/type';
85
+
86
+ @include type.type-style('token-name');
87
+ ```
88
+
89
+ In addition, if the type style you are using has a fluid style then you can pass
90
+ in `true` as the second argument to `type-style` to enable fluid styles. For
91
+ example:
92
+
93
+ ```scss
94
+ @use '@octaviaflow/type';
95
+
96
+ @include type.type-style('token-name', true);
97
+ ```
98
+
99
+ ### Type classes
100
+
101
+ The recommended way to style your application will be to use our
102
+ [type styles](#type-styles). However, we also offer helper CSS classes for
103
+ specific use-cases. These are also helpful when quickly prototyping a project.
104
+
105
+ You can include type classes in your project by writing the following in your
106
+ Sass file:
107
+
108
+ ```scss
109
+ @use '@octaviaflow/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>
120
+ ```
121
+
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 |
132
+
133
+ ### Font family
134
+
135
+ `@octaviaflow/type` provides the font stacks for all the IBM Plex fonts available.
136
+ You can access the font family information by including the following import in
137
+ your Sass file:
138
+
139
+ ```scss
140
+ @use '@octaviaflow/type';
141
+ ```
142
+
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:
145
+
146
+ ```scss
147
+ .my-selector {
148
+ font-family: type.font-family('mono');
149
+ }
150
+ ```
151
+
152
+ You can also use the `font-family` mixin to automatically set the `font-family`
153
+ property for you:
154
+
155
+ ```scss
156
+ .my-selector {
157
+ @include type.font-family('serif');
158
+ }
159
+ ```
160
+
161
+ You can see all the available font families in `$font-families` .
162
+
163
+ ### Reset
164
+
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:
167
+
168
+ ```scss
169
+ @use '@octaviaflow/type';
170
+
171
+ :root {
172
+ @include type.reset();
173
+ }
174
+ ```
175
+
176
+ This reset sets some top-level properties on `html` and `body`, namely
177
+ `font-size`, `font-family`, and some `text-rendering` options. We also map the
178
+ `strong` tag to the semibold font weight.
179
+
180
+ ### Type scale
181
+
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) .
185
+
186
+ If you are looking to use the type scale, you can include all the scale-related
187
+ utilities and variables by writing the following in your Sass file:
188
+
189
+ ```scss
190
+ @use '@octaviaflow/type';
191
+ ```
192
+
193
+ You can access a specific step in the type scale by using the `type-scale`
194
+ function:
195
+
196
+ ```scss
197
+ .my-selector {
198
+ font-size: type.type-scale(1);
199
+ }
200
+ ```
201
+
202
+ There is also a `type-scale` mixin that will set `font-size` for your directly:
203
+
204
+ ```scss
205
+ @use '@octaviaflow/type';
206
+
207
+ .my-selector {
208
+ @include type.type-scale(4);
209
+ }
210
+ ```
211
+
212
+ ## 📚 Examples
213
+
214
+ If you're looking for more examples on how to use `@octaviaflow/type`, we have some
215
+ examples that you can check out:
216
+
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)
221
+
222
+ ## 🙌 Contributing
223
+
224
+ We're always looking for contributors to help us fix bugs, build new features,
225
+ or help us improve the project documentation. If you're interested, definitely
226
+ check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀
227
+
228
+ ## 📝 License
229
+
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 de-identified and anonymized metrics
235
+ data. By installing this package as a dependency you are agreeing to telemetry
236
+ collection. To opt out, 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).