@carbon/styles 0.10.0 → 0.11.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.
package/docs/sass.md CHANGED
@@ -120,23 +120,6 @@ to `false`:
120
120
  );
121
121
  ```
122
122
 
123
- ### Emitting additional typefaces
124
-
125
- When using the font-face declarations, only `IBM Plex Sans` and `IBM Plex Mono`
126
- are emitted. If you would like to emit additional typefaces, like
127
- `IBM Plex Sans Arabic`, you can set additional config tokens:
128
-
129
- ```scss
130
- @use '@carbon/styles/scss/config' with (
131
- $css--plex-arabic: true,
132
- );
133
- ```
134
-
135
- | IBM Plex Language | Token |
136
- | :---------------- | :------------------ |
137
- | Arabic | `$css--plex-arabic` |
138
- | TODO | `TODO` |
139
-
140
123
  ## Grid
141
124
 
142
125
  | Import | Filepath |
package/index.scss CHANGED
@@ -7,7 +7,6 @@
7
7
 
8
8
  @forward 'scss/config';
9
9
  @forward 'scss/colors' hide $white;
10
- @forward 'scss/font-face';
11
10
  @forward 'scss/grid';
12
11
  @forward 'scss/motion';
13
12
  @forward 'scss/type';
@@ -15,4 +14,5 @@
15
14
  @forward 'scss/theme';
16
15
 
17
16
  @use 'scss/reset';
17
+ @forward 'scss/fonts';
18
18
  @use 'scss/components';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/styles",
3
3
  "description": "Styles for the Carbon Design System",
4
- "version": "0.10.0",
4
+ "version": "0.11.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,13 +25,13 @@
25
25
  "@carbon/grid": "^10.39.0",
26
26
  "@carbon/layout": "^10.34.0",
27
27
  "@carbon/motion": "^10.26.0",
28
- "@carbon/themes": "^10.47.0",
29
- "@carbon/type": "^10.38.0",
28
+ "@carbon/themes": "^10.48.0-rc.0",
29
+ "@carbon/type": "^10.39.0-rc.0",
30
30
  "@ibm/plex": "6.0.0-next.6"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@carbon/test-utils": "^10.20.0",
34
34
  "css": "^3.0.0"
35
35
  },
36
- "gitHead": "505af1963e6f78a204212e4f322c247f4eb4f217"
36
+ "gitHead": "f6e5dd2362aa2970add45c7fb7fc32841c252671"
37
37
  }
package/scss/_config.scss CHANGED
@@ -5,14 +5,7 @@
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  //
7
7
 
8
- /// The value used to prefix selectors and CSS Custom Properties across the
9
- /// codebase
10
- /// @access public
11
- /// @type String
12
- /// @group config
13
- $prefix: 'cds' !default;
14
-
15
- /// If true, includes font face mixins in `_css--font-face.scss` depending on the `css--plex` feature flag
8
+ /// If true, includes font face mixins from scss/fonts
16
9
  /// @access public
17
10
  /// @type Bool
18
11
  /// @group config
@@ -30,8 +23,22 @@ $css--reset: true !default;
30
23
  /// @group config
31
24
  $css--default-type: true !default;
32
25
 
33
- /// If true, include IBM Plex Arabic type
26
+ /// Specify the default value for the `font-display` property used for fonts
27
+ /// loaded with @font-face
34
28
  /// @access public
35
- /// @type Bool
29
+ /// @type String
30
+ /// @group config
31
+ $font-display: 'swap' !default;
32
+
33
+ /// Specify the base path for loading IBM Plex
34
+ /// @access public
35
+ /// @type String
36
+ /// @group config
37
+ $font-path: '~@ibm/plex' !default;
38
+
39
+ /// The value used to prefix selectors and CSS Custom Properties across the
40
+ /// codebase
41
+ /// @access public
42
+ /// @type String
36
43
  /// @group config
37
- $css--plex-arabic: false !default;
44
+ $prefix: 'cds' !default;
@@ -743,8 +743,8 @@ $list-box-menu-width: rem(300px);
743
743
 
744
744
  .#{$prefix}--list-box__menu-item--active:hover,
745
745
  .#{$prefix}--list-box__menu-item--active.#{$prefix}--list-box__menu-item--highlighted {
746
- border-bottom-color: $layer-selected;
747
- background-color: $layer-selected;
746
+ border-bottom-color: $layer-selected-hover;
747
+ background-color: $layer-selected-hover;
748
748
  }
749
749
 
750
750
  .#{$prefix}--list-box__menu-item--active
@@ -121,15 +121,15 @@ $radio-border-width: 1px !default;
121
121
  }
122
122
  }
123
123
 
124
- .#{$prefix}--radio-button:button-disabled + .#{$prefix}--radio-button__label {
124
+ .#{$prefix}--radio-button:disabled + .#{$prefix}--radio-button__label {
125
125
  color: $button-disabled;
126
126
  cursor: not-allowed;
127
127
  }
128
128
 
129
- .#{$prefix}--radio-button:button-disabled
129
+ .#{$prefix}--radio-button:disabled
130
130
  + .#{$prefix}--radio-button__label
131
131
  .#{$prefix}--radio-button__appearance,
132
- .#{$prefix}--radio-button:button-disabled:checked
132
+ .#{$prefix}--radio-button:disabled:checked
133
133
  + .#{$prefix}--radio-button__label
134
134
  .#{$prefix}--radio-button__appearance {
135
135
  border-color: $border-disabled;
@@ -0,0 +1,148 @@
1
+ # `scss/fonts`
2
+
3
+ The `scss/fonts` folder provides a way to incorporate IBM Plex into your
4
+ project. Below is a table of what fonts are currently supported from IBM Plex in
5
+ Carbon:
6
+
7
+ | Font | Available | Entrypoint |
8
+ | ------------------------- | --------- | ----------------------------- |
9
+ | IBM Plex Mono | ✅ | `scss/fonts/mono` |
10
+ | IBM Plex Sans Arabic | ✅ | `scss/fonts/sans-arabic` |
11
+ | IBM Plex Sans Devanagari | ✅ | `scss/fonts/sans-devanagari` |
12
+ | IBM Plex Sans Hebrew | ✅ | `scss/fonts/sans-hebrew` |
13
+ | IBM Plex Sans KR | | |
14
+ | IBM Plex Sans JP | | |
15
+ | IBM Plex Sans Thai Looped | ✅ | `scss/fonts/sans-thai-looped` |
16
+ | IBM Plex Sans Thai | ✅ | `scss/fonts/sans-thai` |
17
+ | IBM Plex Sans | ✅ | `scss/fonts/sans` |
18
+ | IBM Plex Serif | ✅ | `scss/fonts/serif` |
19
+
20
+ By default, Carbon provides the default font weights for: IBM Plex Mono, IBM
21
+ Plex Sans, and IBM Plex Serif. To bring in additional fonts, you can include the
22
+ `@carbon/styles/scss/fonts` entrypoint and configure it:
23
+
24
+ ```scss
25
+ @use '@carbon/styles/scss/fonts' with (
26
+ $fonts: (
27
+ IBM-Plex-Sans-Arabic: true,
28
+ ),
29
+ );
30
+ ```
31
+
32
+ You can also configure it to disable specific fonts:
33
+
34
+ ```scss
35
+ @use '@carbon/styles/scss/fonts' with (
36
+ $fonts: (
37
+ IBM-Plex-Sans: false,
38
+ ),
39
+ );
40
+ ```
41
+
42
+ If you would like to disable all fonts, you can use the `$css--font-face` flag
43
+ in:
44
+
45
+ ```scss
46
+ @use '@carbon/styles/scss/config' with (
47
+ $css--font-face: false,
48
+ );
49
+ ```
50
+
51
+ ## Features
52
+
53
+ Each font is available as an entrypoint in the `fonts` folder. You can use these
54
+ entrypoints to include specific font weights, styles, and more for IBM Plex. For
55
+ example, if you only want to include the regular font weight for IBM Plex Sans
56
+ then you could do the following:
57
+
58
+ ```scss
59
+ @use '@carbon/styles/scss/fonts/sans';
60
+
61
+ @include sans.regular($styles: normal);
62
+ ```
63
+
64
+ Each font entrypoint supports the following weights:
65
+
66
+ - `thin`
67
+ - `extralight`
68
+ - `light`
69
+ - `regular`
70
+ - `tex`
71
+ - `medium`
72
+ - `semibold`
73
+ - `bold`
74
+
75
+ All fonts support the `normal` font style, some fonts include support for the
76
+ `italic` font style, as well.
77
+
78
+ ### Custom font src resolver
79
+
80
+ By default, `@carbon/styles/scss/fonts` attempts to resolve fonts directly from
81
+ the `@ibm/plex` package. You can configure the location of these font files in
82
+ two ways:
83
+
84
+ - Use the `$font-path` option to define a path "prefix"
85
+ - Provide a custom resolver to point to where your font files are hosted
86
+
87
+ The `$font-path` options is available in `scss/config`:
88
+
89
+ ```scss
90
+ @use '@carbon/styles/scss/config' with (
91
+ $font-path: 'https://cdn.custom-font-path.com/fonts',
92
+ );
93
+ ```
94
+
95
+ And allows you to change the beginning part of each `src` URL that is generated.
96
+ You can also completely override the default behavior and provide your own URL
97
+ resolver through `scss/fonts/src`:
98
+
99
+ ```scss
100
+ @use 'sass:meta';
101
+ @use './my-custom-resolver' as resolver;
102
+ @use '@carbon/styles/scss/fonts/src' with (
103
+ // Here, "resolve" is the name of the function in the "resolver" module
104
+ $resolver: meta.get-function('resolve', 'resolver')
105
+ );
106
+ ```
107
+
108
+ This can be particularly useful for self-hosted projects that are not using
109
+ webpack. This custom resolver should follow the signature:
110
+
111
+ ```scss
112
+ /// @param {String} $name
113
+ /// @param {String} $weight
114
+ /// @param {String} $style
115
+ /// @param {String} $unicode-range
116
+ /// @param {List} $formats
117
+ /// @returns List
118
+ @function resolver($name, $weight, $style, $unicode-range, $formats) {
119
+ // Here, you will need to return a list of url() format() that will be used in
120
+ // the src property
121
+ }
122
+ ```
123
+
124
+ ## Contributing
125
+
126
+ **How do I add support for a font?**
127
+
128
+ You will need to do the following:
129
+
130
+ - [ ] Create a file for the font under `scss/fonts/`, for example
131
+ `scss/fonts/_sans-arabic.scss`
132
+ - [ ] Define all available weights as mixins in that file
133
+ - [ ] Emit `@font-face` blocks in each font weight mixin
134
+ - [ ] Add a `default` mixin for the default font weights to include for a font
135
+ - [ ] Add an `all` mixin which emits all font weights
136
+ - [ ] Export a `$name` variable for the name of the font to be used to detect if
137
+ a font should be auto-included
138
+ - [ ] Add the base font name to the `$-filenames` map in `fonts/_src.scss`. This
139
+ will be used in the font src resolver to get the correct path from
140
+ `@ibm/plex`
141
+ - [ ] In `fonts/_index.scss`
142
+ - [ ] Update the `$-fonts` map to include the `$name` for the font and specify
143
+ whether it should be included automatically
144
+ - [ ] Update the block at the end of the file to call the default mixin of the
145
+ file if the font is enabled
146
+ - [ ] Update `packages/carbon-react/tasks/build-styles.js` to include the font
147
+ file as a re-export
148
+ - [ ] Add a story for the font in `Plex.stories.js`
@@ -0,0 +1,75 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
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:meta';
9
+ @use 'sass:map';
10
+ @use '../config';
11
+ @use './mono';
12
+ @use './sans-arabic';
13
+ @use './sans-devanagari';
14
+ @use './sans-hebrew';
15
+ @use './sans-thai-looped';
16
+ @use './sans-thai';
17
+ @use './sans';
18
+ @use './serif';
19
+
20
+ $-fonts: (
21
+ IBM-Plex-Mono: true,
22
+ IBM-Plex-Sans-Arabic: false,
23
+ IBM-Plex-Sans-Devanagari: false,
24
+ IBM-Plex-Sans-Hebrew: false,
25
+ IBM-Plex-Sans-Thai-Looped: false,
26
+ IBM-Plex-Sans-Thai: false,
27
+ IBM-Plex-Sans: true,
28
+ IBM-Plex-Serif: true,
29
+ );
30
+ $fonts: () !default;
31
+ $fonts: map.merge($-fonts, $fonts);
32
+
33
+ /// Determine if the given font has been enabled or not
34
+ /// @param String $name
35
+ /// @returns Boolean
36
+ @function enabled($name) {
37
+ @if map.has-key($fonts, $name) {
38
+ @return map.get($fonts, $name);
39
+ }
40
+ @return false;
41
+ }
42
+
43
+ @if config.$css--font-face == true {
44
+ @if enabled(mono.$name) {
45
+ @include mono.default();
46
+ }
47
+
48
+ @if enabled(sans-arabic.$name) {
49
+ @include sans-arabic.default();
50
+ }
51
+
52
+ @if enabled(sans-devanagari.$name) {
53
+ @include sans-devanagari.default();
54
+ }
55
+
56
+ @if enabled(sans-hebrew.$name) {
57
+ @include sans-hebrew.default();
58
+ }
59
+
60
+ @if enabled(sans-thai-looped.$name) {
61
+ @include sans-thai-looped.default();
62
+ }
63
+
64
+ @if enabled(sans-thai.$name) {
65
+ @include sans-thai.default();
66
+ }
67
+
68
+ @if enabled(sans.$name) {
69
+ @include sans.default();
70
+ }
71
+
72
+ @if enabled(serif.$name) {
73
+ @include serif.default();
74
+ }
75
+ }
@@ -0,0 +1,153 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
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 '../config';
9
+ @use './src';
10
+ @use './unicode';
11
+
12
+ $font-family: 'IBM Plex Mono';
13
+ $name: 'IBM-Plex-Mono';
14
+ $styles: (normal, italic);
15
+ $unicode-ranges: (Cyrillic, Pi, Latin3, Latin2, Latin1);
16
+ $formats: (woff2, woff);
17
+
18
+ @mixin thin($styles: $styles, $unicode-ranges: $unicode-ranges) {
19
+ @each $style in $styles {
20
+ @each $unicode-range in $unicode-ranges {
21
+ @font-face {
22
+ font-display: config.$font-display;
23
+ font-family: $font-family;
24
+ font-style: $style;
25
+ font-weight: 100;
26
+ src: src.get($name, Thin, $style, $unicode-range, $formats);
27
+ unicode-range: unicode.get-range($unicode-range);
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ @mixin extralight($styles: $styles, $unicode-ranges: $unicode-ranges) {
34
+ @each $style in $styles {
35
+ @each $unicode-range in $unicode-ranges {
36
+ @font-face {
37
+ font-display: config.$font-display;
38
+ font-family: $font-family;
39
+ font-style: $style;
40
+ font-weight: 200;
41
+ src: src.get($name, ExtraLight, $style, $unicode-range, $formats);
42
+ unicode-range: unicode.get-range($unicode-range);
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ @mixin light($styles: $styles, $unicode-ranges: $unicode-ranges) {
49
+ @each $style in $styles {
50
+ @each $unicode-range in $unicode-ranges {
51
+ @font-face {
52
+ font-display: config.$font-display;
53
+ font-family: $font-family;
54
+ font-style: $style;
55
+ font-weight: 300;
56
+ src: src.get($name, Light, $style, $unicode-range, $formats);
57
+ unicode-range: unicode.get-range($unicode-range);
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ @mixin regular($styles: $styles, $unicode-ranges: $unicode-ranges) {
64
+ @each $style in $styles {
65
+ @each $unicode-range in $unicode-ranges {
66
+ @font-face {
67
+ font-display: config.$font-display;
68
+ font-family: $font-family;
69
+ font-style: $style;
70
+ font-weight: 400;
71
+ src: src.get($name, Regular, $style, $unicode-range, $formats);
72
+ unicode-range: unicode.get-range($unicode-range);
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ @mixin text($styles: $styles, $unicode-ranges: $unicode-ranges) {
79
+ @each $style in $styles {
80
+ @each $unicode-range in $unicode-ranges {
81
+ @font-face {
82
+ font-display: config.$font-display;
83
+ font-family: $font-family;
84
+ font-style: $style;
85
+ font-weight: 450;
86
+ src: src.get($name, Text, $style, $unicode-range, $formats);
87
+ unicode-range: unicode.get-range($unicode-range);
88
+ }
89
+ }
90
+ }
91
+ }
92
+
93
+ @mixin medium($styles: $styles, $unicode-ranges: $unicode-ranges) {
94
+ @each $style in $styles {
95
+ @each $unicode-range in $unicode-ranges {
96
+ @font-face {
97
+ font-display: config.$font-display;
98
+ font-family: $font-family;
99
+ font-style: $style;
100
+ font-weight: 500;
101
+ src: src.get($name, Medium, $style, $unicode-range, $formats);
102
+ unicode-range: unicode.get-range($unicode-range);
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ @mixin semibold($styles: $styles, $unicode-ranges: $unicode-ranges) {
109
+ @each $style in $styles {
110
+ @each $unicode-range in $unicode-ranges {
111
+ @font-face {
112
+ font-display: config.$font-display;
113
+ font-family: $font-family;
114
+ font-style: $style;
115
+ font-weight: 600;
116
+ src: src.get($name, SemiBold, $style, $unicode-range, $formats);
117
+ unicode-range: unicode.get-range($unicode-range);
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ @mixin bold($styles: $styles, $unicode-ranges: $unicode-ranges) {
124
+ @each $style in $styles {
125
+ @each $unicode-range in $unicode-ranges {
126
+ @font-face {
127
+ font-display: config.$font-display;
128
+ font-family: $font-family;
129
+ font-style: $style;
130
+ font-weight: 700;
131
+ src: src.get($name, Bold, $style, $unicode-range, $formats);
132
+ unicode-range: unicode.get-range($unicode-range);
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ @mixin all($styles: $styles, $unicode-ranges: $unicode-ranges) {
139
+ @include thin($styles, $unicode-ranges);
140
+ @include extralight($styles, $unicode-ranges);
141
+ @include light($styles, $unicode-ranges);
142
+ @include regular($styles, $unicode-ranges);
143
+ @include text($styles, $unicode-ranges);
144
+ @include medium($styles, $unicode-ranges);
145
+ @include semibold($styles, $unicode-ranges);
146
+ @include bold($styles, $unicode-ranges);
147
+ }
148
+
149
+ @mixin default() {
150
+ @include light();
151
+ @include regular();
152
+ @include semibold();
153
+ }
@@ -0,0 +1,151 @@
1
+ //
2
+ // Copyright IBM Corp. 2018, 2018
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 '../config';
9
+ @use './src';
10
+
11
+ $font-family: 'IBM Plex Sans Arabic';
12
+ $name: 'IBM-Plex-Sans-Arabic';
13
+ $styles: (normal);
14
+ $formats: (woff2, woff);
15
+
16
+ @mixin thin() {
17
+ @font-face {
18
+ font-display: config.$font-display;
19
+ font-family: $font-family;
20
+ font-style: normal;
21
+ font-weight: 100;
22
+ src: src.get(
23
+ $name: $name,
24
+ $weight: Thin,
25
+ $style: $styles,
26
+ $formats: $formats
27
+ );
28
+ }
29
+ }
30
+
31
+ @mixin extralight() {
32
+ @font-face {
33
+ font-display: config.$font-display;
34
+ font-family: $font-family;
35
+ font-style: normal;
36
+ font-weight: 200;
37
+ src: src.get(
38
+ $name: $name,
39
+ $weight: ExtraLight,
40
+ $style: $styles,
41
+ $formats: $formats
42
+ );
43
+ }
44
+ }
45
+
46
+ @mixin light() {
47
+ @font-face {
48
+ font-display: config.$font-display;
49
+ font-family: $font-family;
50
+ font-style: normal;
51
+ font-weight: 300;
52
+ src: src.get(
53
+ $name: $name,
54
+ $weight: Light,
55
+ $style: $styles,
56
+ $formats: $formats
57
+ );
58
+ }
59
+ }
60
+
61
+ @mixin regular() {
62
+ @font-face {
63
+ font-display: config.$font-display;
64
+ font-family: $font-family;
65
+ font-style: normal;
66
+ font-weight: 400;
67
+ src: src.get(
68
+ $name: $name,
69
+ $weight: Regular,
70
+ $style: $styles,
71
+ $formats: $formats
72
+ );
73
+ }
74
+ }
75
+
76
+ @mixin text() {
77
+ @font-face {
78
+ font-display: config.$font-display;
79
+ font-family: $font-family;
80
+ font-style: normal;
81
+ font-weight: 450;
82
+ src: src.get(
83
+ $name: $name,
84
+ $weight: Text,
85
+ $style: $styles,
86
+ $formats: $formats
87
+ );
88
+ }
89
+ }
90
+
91
+ @mixin medium() {
92
+ @font-face {
93
+ font-display: config.$font-display;
94
+ font-family: $font-family;
95
+ font-style: normal;
96
+ font-weight: 500;
97
+ src: src.get(
98
+ $name: $name,
99
+ $weight: Medium,
100
+ $style: $styles,
101
+ $formats: $formats
102
+ );
103
+ }
104
+ }
105
+
106
+ @mixin semibold() {
107
+ @font-face {
108
+ font-display: config.$font-display;
109
+ font-family: $font-family;
110
+ font-style: normal;
111
+ font-weight: 500;
112
+ src: src.get(
113
+ $name: $name,
114
+ $weight: SemiBold,
115
+ $style: $styles,
116
+ $formats: $formats
117
+ );
118
+ }
119
+ }
120
+
121
+ @mixin bold() {
122
+ @font-face {
123
+ font-display: config.$font-display;
124
+ font-family: $font-family;
125
+ font-style: normal;
126
+ font-weight: 500;
127
+ src: src.get(
128
+ $name: $name,
129
+ $weight: Bold,
130
+ $style: $styles,
131
+ $formats: $formats
132
+ );
133
+ }
134
+ }
135
+
136
+ @mixin all() {
137
+ @include thin();
138
+ @include extralight();
139
+ @include light();
140
+ @include regular();
141
+ @include text();
142
+ @include medium();
143
+ @include semibold();
144
+ @include bold();
145
+ }
146
+
147
+ @mixin default() {
148
+ @include light();
149
+ @include regular();
150
+ @include semibold();
151
+ }