@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/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@octaviaflow/type",
3
+ "description": "Typography for digital and software products using the OctaviaFlow Design System",
4
+ "version": "1.0.0",
5
+ "license": "Apache-2.0",
6
+ "main": "lib/index.js",
7
+ "module": "es/index.js",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/octaviaflow-design-system.git",
11
+ "directory": "packages/type"
12
+ },
13
+ "bugs": "https://github.com/octaviaflow-design-system/issues",
14
+ "files": [
15
+ "es",
16
+ "lib",
17
+ "scss",
18
+ "src",
19
+ "umd",
20
+ "index.scss",
21
+ "telemetry.yml"
22
+ ],
23
+ "keywords": [
24
+ "eyeglass-module",
25
+ "ibm",
26
+ "elements",
27
+ "carbon",
28
+ "carbon-elements",
29
+ "carbon-design-system",
30
+ "components",
31
+ "react"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "scripts": {
37
+ "build": "bun run clean && octaviaflow-cli bundle src/index.js --name OctaviaFlowType && octaviaflow-cli check \"scss/*.scss\"",
38
+ "clean": "rimraf css es lib umd"
39
+ },
40
+ "dependencies": {
41
+ "@octaviaflow/grid": "^1.0.0",
42
+ "@octaviaflow/layout": "^1.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@babel/core": "^7.28.6",
46
+ "@babel/preset-env": "^7.28.6",
47
+ "@octaviaflow/cli": "^1.0.0",
48
+ "@octaviaflow/test-utils": "^1.0.0",
49
+ "change-case": "^4.1.1",
50
+ "css": "^3.0.0",
51
+ "rimraf": "^6.0.0"
52
+ },
53
+ "eyeglass": {
54
+ "exports": false,
55
+ "name": "@octaviaflow/type",
56
+ "sassDir": "scss",
57
+ "needs": "^1.3.0"
58
+ }
59
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use 'sass:map';
9
+ @use 'font-family' as *;
10
+ @use 'prefix' as *;
11
+ @use 'styles' as *;
12
+
13
+ /// Create type classes for font families, weights, styles
14
+ /// @access public
15
+ /// @group @octaviaflow/type
16
+ @mixin type-classes {
17
+ // Font families
18
+ @each $name, $value in $font-families {
19
+ .#{$prefix}--type-#{$name} {
20
+ font-family: $value;
21
+ }
22
+ }
23
+
24
+ // Font weights
25
+ @each $name, $value in $font-weights {
26
+ .#{$prefix}--type-#{$name} {
27
+ font-weight: $value;
28
+ }
29
+ }
30
+
31
+ // Font styles
32
+ .#{$prefix}--type-italic {
33
+ font-style: italic;
34
+ }
35
+
36
+ // Type styles
37
+ @each $name, $value in $tokens {
38
+ .#{$prefix}--type-#{$name} {
39
+ @include type-style($name, map.has-key($value, breakpoints));
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,50 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+ @use 'sass:meta';
8
+ @use 'styles' as *;
9
+ @use 'prefix' as *;
10
+
11
+ /// Include default type styles
12
+ /// @access public
13
+ /// @group @octaviaflow/type
14
+ @mixin default-type {
15
+ h1 {
16
+ @include type-style('heading-06');
17
+ }
18
+
19
+ h2 {
20
+ @include type-style('heading-05');
21
+ }
22
+
23
+ h3 {
24
+ @include type-style('heading-04');
25
+ }
26
+
27
+ h4 {
28
+ @include type-style('heading-03');
29
+ }
30
+
31
+ h5 {
32
+ @include type-style('heading-02');
33
+ }
34
+
35
+ h6 {
36
+ @include type-style('heading-01');
37
+ }
38
+
39
+ p {
40
+ @include type-style('body-02');
41
+ }
42
+
43
+ a {
44
+ color: var(--#{$prefix}-link-primary, #0062fe);
45
+ }
46
+
47
+ em {
48
+ font-style: italic;
49
+ }
50
+ }
@@ -0,0 +1,105 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use 'sass:string';
9
+ @use 'sass:map';
10
+
11
+ /// Font family fallbacks for: Lufga, JetBrains Mono, Noto Sans, and Noto Serif
12
+ /// Octaviaflow custom font stack replacing IBM Plex fonts
13
+ /// @type Map
14
+ /// @access public
15
+ /// @group @octaviaflow/type
16
+ $font-families: (
17
+ 'mono':
18
+ string.unquote(
19
+ "'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace"
20
+ ),
21
+ 'sans':
22
+ string.unquote(
23
+ "'Lufga', 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
24
+ ),
25
+ 'sans-condensed':
26
+ string.unquote(
27
+ "'Noto Sans', 'Lufga', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
28
+ ),
29
+ 'sans-arabic':
30
+ string.unquote(
31
+ "'Noto Sans Arabic', 'RTL United Text', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
32
+ ),
33
+ 'sans-devanagari':
34
+ string.unquote(
35
+ "'Noto Sans Devanagari', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
36
+ ),
37
+ 'sans-hebrew':
38
+ string.unquote(
39
+ "'Noto Sans Hebrew', 'RTL United Text', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
40
+ ),
41
+ 'sans-jp':
42
+ string.unquote(
43
+ "'Noto Sans JP', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
44
+ ),
45
+ 'sans-kr':
46
+ string.unquote(
47
+ "'Noto Sans KR', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
48
+ ),
49
+ 'sans-thai-looped':
50
+ string.unquote(
51
+ "'Noto Sans Thai Looped', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
52
+ ),
53
+ 'sans-thai':
54
+ string.unquote(
55
+ "'Noto Sans Thai', system-ui, -apple-system, BlinkMacSystemFont, sans-serif"
56
+ ),
57
+ 'serif':
58
+ string.unquote(
59
+ "'Noto Serif', 'Georgia', 'Times New Roman', serif"
60
+ ),
61
+ ) !default;
62
+
63
+ /// Get the font-family for an Octaviaflow font
64
+ /// @param {String} $name
65
+ /// @return {String}
66
+ /// @access public
67
+ /// @group @octaviaflow/type
68
+ @function font-family($name) {
69
+ @return map.get($font-families, $name);
70
+ }
71
+
72
+ /// Include the `font-family` definition for the given name in your selector
73
+ /// @param {String} $name
74
+ /// @access public
75
+ /// @group @octaviaflow/type
76
+ @mixin font-family($name) {
77
+ font-family: font-family($name);
78
+ }
79
+
80
+ /// Suggested font weights to be used in product
81
+ /// @type Map
82
+ /// @access public
83
+ /// @group @octaviaflow/type
84
+ $font-weights: (
85
+ 'light': 300,
86
+ 'regular': 400,
87
+ 'semibold': 600,
88
+ ) !default;
89
+
90
+ /// Retrieve the font-weight value for a given name
91
+ /// @param {String} $weight
92
+ /// @return {Number}
93
+ /// @access public
94
+ /// @group @octaviaflow/type
95
+ @function font-weight($weight) {
96
+ @return map.get($font-weights, $weight);
97
+ }
98
+
99
+ /// Set the `font-weight` property with the value for a given name
100
+ /// @param {String} $weight
101
+ /// @access public
102
+ /// @group @octaviaflow/type
103
+ @mixin font-weight($weight) {
104
+ font-weight: font-weight($weight);
105
+ }
@@ -0,0 +1,28 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use 'sass:map';
9
+
10
+ /// @type String
11
+ /// @access public
12
+ /// @group @octaviaflow/type
13
+ $prefix: 'cds' !default;
14
+
15
+ /// @type String
16
+ /// @access public
17
+ /// @group @octaviaflow/type
18
+ $custom-property-prefix: 'cds' !default;
19
+
20
+ @mixin configure($values) {
21
+ @if map.has-key($values, 'prefix') {
22
+ $prefix: map.get($values, 'prefix') !global;
23
+ }
24
+
25
+ @if map.has-key($values, 'custom-property-prefix') {
26
+ $custom-property-prefix: map.get($values, 'custom-property-prefix') !global;
27
+ }
28
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use 'sass:map';
9
+ @use 'sass:meta';
10
+ @use '@octaviaflow/layout';
11
+ @use 'font-family' as *;
12
+
13
+ /// Include a type reset for a given body and mono font family
14
+ /// @param {String} $body-font-family [font-family('sans')] - The font family used on the `<body>` element
15
+ /// @param {String} $mono-font-family [font-family('mono')] - The font family used on elements that require mono fonts, like the `<code>` element
16
+ /// @access public
17
+ /// @group @octaviaflow/type
18
+ @mixin reset(
19
+ $body-font-family: font-family('sans'),
20
+ $mono-font-family: font-family('mono')
21
+ ) {
22
+ html {
23
+ font-size: 100%;
24
+ }
25
+
26
+ body {
27
+ @include font-weight('regular');
28
+
29
+ font-family: $body-font-family;
30
+ -moz-osx-font-smoothing: grayscale;
31
+ -webkit-font-smoothing: antialiased;
32
+ text-rendering: optimizeLegibility;
33
+ }
34
+
35
+ code {
36
+ font-family: $mono-font-family;
37
+ }
38
+
39
+ strong {
40
+ @include font-weight('semibold');
41
+ }
42
+ }
@@ -0,0 +1,58 @@
1
+ //
2
+ // Copyright OctaviaFlow. 2025
3
+ //
4
+ // This source code is licensed under the Apache-2.0 license found in the
5
+ // LICENSE file in the root directory of this source tree.
6
+ //
7
+
8
+ @use '@octaviaflow/layout';
9
+ @use 'sass:list';
10
+ @use 'sass:math';
11
+
12
+ /// Compute the type size for the given type scale step
13
+ /// @param {Number} $step
14
+ /// @return {Number} In px
15
+ /// @access public
16
+ /// @group @octaviaflow/type
17
+ @function get-type-size($step) {
18
+ @if $step == 1 {
19
+ @return 12px;
20
+ }
21
+ // Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
22
+ @return get-type-size($step - 1) + (math.floor(($step - 2) * 0.25) + 1) * 2;
23
+ }
24
+
25
+ /// Type scale follows a custom formula for determining each step size and supports sizes from 12px to 92px
26
+ /// @type Map
27
+ /// @access public
28
+ /// @group @octaviaflow/type
29
+ $type-scale: ();
30
+ @for $i from 1 through 23 {
31
+ $type-scale: list.append($type-scale, layout.to-rem(get-type-size($i)));
32
+ }
33
+
34
+ /// Get the value of a specific step in the type scale
35
+ /// @param {Number} $step
36
+ /// @return {Number} In rem
37
+ /// @access public
38
+ /// @group @octaviaflow/type
39
+ @function type-scale($step) {
40
+ @return list.nth($type-scale, $step);
41
+ }
42
+
43
+ /// Set the font-size value of a selector with the value at the given `$step`
44
+ /// @param {Number} $step
45
+ /// @access public
46
+ /// @group @octaviaflow/type
47
+ @mixin type-scale($step) {
48
+ font-size: type-scale($step);
49
+ }
50
+
51
+ /// Alias of `type-scale` mixin.
52
+ /// @param {Number} $step
53
+ /// @alias type-scale
54
+ /// @access public
55
+ /// @group @octaviaflow/type
56
+ @mixin font-size($step) {
57
+ font-size: type-scale($step);
58
+ }