@carbon/styles 0.9.0 → 0.11.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.
@@ -9,3 +9,4 @@
9
9
  @use 'tooltip';
10
10
 
11
11
  @include tooltip.tooltip;
12
+ @include tooltip.icon-tooltip;
@@ -12,6 +12,16 @@
12
12
  @use '../../utilities/custom-property';
13
13
  @use '../../utilities/convert';
14
14
 
15
+ $tooltip-padding-block: custom-property.get-var(
16
+ 'tooltip-padding-block',
17
+ spacing.$spacing-05
18
+ );
19
+
20
+ $tooltip-padding-inline: custom-property.get-var(
21
+ 'tooltip-padding-inline',
22
+ spacing.$spacing-05
23
+ );
24
+
15
25
  @mixin tooltip {
16
26
  .#{$prefix}--tooltip {
17
27
  @include custom-property.declaration('popover-offset', 12px);
@@ -21,7 +31,7 @@
21
31
  @include type.type-style('body-long-01');
22
32
 
23
33
  max-width: convert.rem(288px);
24
- padding: spacing.$spacing-05;
34
+ padding: $tooltip-padding-block $tooltip-padding-inline;
25
35
 
26
36
  color: theme.$text-inverse;
27
37
  }
@@ -29,6 +39,22 @@
29
39
 
30
40
  @mixin icon-tooltip {
31
41
  .#{$prefix}--icon-tooltip {
32
- padding: 3px spacing.$spacing-05;
42
+ @include custom-property.declaration(
43
+ 'tooltip-padding-block',
44
+ convert.rem(2px)
45
+ );
46
+ @include custom-property.declaration(
47
+ 'popover-caret-width',
48
+ convert.rem(8px)
49
+ );
50
+ @include custom-property.declaration(
51
+ 'popover-caret-height',
52
+ convert.rem(4px)
53
+ );
54
+ @include custom-property.declaration('popover-offset', convert.rem(8px));
55
+ }
56
+
57
+ .#{$prefix}--icon-tooltip .#{$prefix}--tooltip-content {
58
+ @include type.type-style('body-short-01');
33
59
  }
34
60
  }
@@ -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
+ }