@carbon/themes 10.37.0 → 10.39.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/README.md +7 -0
- package/docs/sass.md +96 -0
- package/index.scss +1 -1
- package/package.json +10 -7
- package/scss/modules/_config.scss +8 -0
- package/scss/modules/_theme.scss +22 -18
- package/scss/modules/_themes.scss +1 -0
- package/scss/modules/generated/_themes.scss +406 -567
- package/scss/modules/generated/_tokens.scss +300 -219
- package/src/next/g10.js +267 -0
- package/src/next/g100.js +270 -0
- package/src/next/g90.js +269 -0
- package/src/next/index.js +21 -0
- package/src/next/tokens/TokenFormat.js +51 -0
- package/src/next/tokens/index.js +3 -1
- package/src/next/tokens/v11TokenGroup.js +4 -4
- package/src/next/white.js +269 -0
package/README.md
CHANGED
|
@@ -93,11 +93,18 @@ import {
|
|
|
93
93
|
} from '@carbon/themes';
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
## 📖 API Documentation
|
|
97
|
+
|
|
98
|
+
If you're looking for `@carbon/themes` API documentation, check out:
|
|
99
|
+
|
|
100
|
+
- [Sass](./docs/sass.md)
|
|
101
|
+
|
|
96
102
|
## 📚 Examples
|
|
97
103
|
|
|
98
104
|
If you're looking for more examples on how to use `@carbon/themes`, we have some
|
|
99
105
|
examples that you can check out:
|
|
100
106
|
|
|
107
|
+
- [preview-v11](./examples/preview-v11)
|
|
101
108
|
- [sass-modules](./examples/sass-modules)
|
|
102
109
|
|
|
103
110
|
## 🙌 Contributing
|
package/docs/sass.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# `@carbon/themes`
|
|
2
|
+
|
|
3
|
+
_Note: this documentation is used with the next version of `@carbon/themes`
|
|
4
|
+
which uses Sass Modules. It will not work in the current stable version of this
|
|
5
|
+
package_
|
|
6
|
+
|
|
7
|
+
<!-- prettier-ignore-start -->
|
|
8
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
9
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [FAQ](#faq)
|
|
14
|
+
- [Why are the themes not exported in `@carbon/themes`?](#why-are-the-themes-not-exported-in-carbonthemes)
|
|
15
|
+
|
|
16
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
17
|
+
<!-- prettier-ignore-end -->
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
There are several entrypoints that you can use with `@carbon/themes`, including:
|
|
22
|
+
|
|
23
|
+
| Filename | Description |
|
|
24
|
+
| -------------------------------------------- | ------------------------------------------------------ |
|
|
25
|
+
| `@use '@carbon/themes';` | Package entrypoint |
|
|
26
|
+
| `@use '@carbon/themes/scss/modules/config';` | Specify config options for the package |
|
|
27
|
+
| `@use '@carbon/themes/scss/modules/themes';` | Theme definitions for white, g10, g90, and g100 |
|
|
28
|
+
| `@use '@carbon/themes/scss/modules/theme';` | Set the current theme, get token values from the theme |
|
|
29
|
+
| `@use '@carbon/themes/scss/modules/tokens';` | Access theme tokens |
|
|
30
|
+
|
|
31
|
+
_Note: the white, g10, g90, and g100 themes are only available in the
|
|
32
|
+
`scss/modules/themes` file and are not re-exported in `@carbon/themes`. To learn
|
|
33
|
+
more, checkout our [FAQ](#why-are-the-themes-not-exported-in-carbonthemes)._
|
|
34
|
+
|
|
35
|
+
You can bring in `@carbon/themes` by using `@use`:
|
|
36
|
+
|
|
37
|
+
```scss
|
|
38
|
+
@use '@carbon/themes';
|
|
39
|
+
|
|
40
|
+
.my-component {
|
|
41
|
+
// Use tokens from the theme, this will map to a CSS Custom Property
|
|
42
|
+
color: themes.$token-01;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:root {
|
|
46
|
+
// Emit CSS Custom Properties for the current theme
|
|
47
|
+
@include themes.theme();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Get the value of a specific token
|
|
51
|
+
$custom-variable: rgba(themes.get('token-01'), 0.25);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can configure the current theme with the `$theme` option:
|
|
55
|
+
|
|
56
|
+
```scss
|
|
57
|
+
@use '@carbon/themes/scss/modules/themes';
|
|
58
|
+
@use '@carbon/themes' with (
|
|
59
|
+
$theme: themes.$g100,
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
You can also extend the theme with your own custom tokens:
|
|
64
|
+
|
|
65
|
+
```scss
|
|
66
|
+
@use '@carbon/themes/scss/modules/themes';
|
|
67
|
+
@use '@carbon/themes' with (
|
|
68
|
+
$fallback: themes.$g100,
|
|
69
|
+
$theme: (
|
|
70
|
+
token-01: #000000,
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tokens
|
|
76
|
+
|
|
77
|
+
TODO
|
|
78
|
+
|
|
79
|
+
## FAQ
|
|
80
|
+
|
|
81
|
+
### Why are the themes not exported in `@carbon/themes`?
|
|
82
|
+
|
|
83
|
+
In order to support `@use '@carbon/themes' with` in Sass Modules, unfortunately
|
|
84
|
+
we cannot re-export the themes available in `scss/modules/themes`. If we
|
|
85
|
+
implemented the entrypoint at `@carbon/themes` to re-export that module, then
|
|
86
|
+
Sass would not compile when doing the following:
|
|
87
|
+
|
|
88
|
+
```scss
|
|
89
|
+
@use '@carbon/themes/scss/modules/themes';
|
|
90
|
+
@use '@carbon/themes' with (
|
|
91
|
+
$theme: themes.$g100,
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This is because the `scss/modules/themes` file will have been initialized twice
|
|
96
|
+
which is not allowed in the Sass Module system.
|
package/index.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/themes",
|
|
3
3
|
"description": "Themes for applying color in the Carbon Design System",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.39.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -26,16 +26,18 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"ci-check": "carbon-cli check \"scss/**/*.scss\" -i \"**/generated/**\"",
|
|
28
28
|
"clean": "rimraf es lib umd scss/generated",
|
|
29
|
-
"build": "yarn clean && carbon-cli bundle src/index.js --name CarbonThemes && node tasks/build.js && carbon-cli check \"scss/*.scss\""
|
|
29
|
+
"build": "yarn clean && carbon-cli bundle src/index.js --name CarbonThemes && babel-node --presets '@babel/preset-env' tasks/build.js && carbon-cli check \"scss/*.scss\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@carbon/colors": "^10.
|
|
33
|
-
"@carbon/layout": "^10.
|
|
34
|
-
"@carbon/type": "^10.
|
|
32
|
+
"@carbon/colors": "^10.29.0",
|
|
33
|
+
"@carbon/layout": "^10.28.0",
|
|
34
|
+
"@carbon/type": "^10.32.0",
|
|
35
35
|
"color": "^3.1.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
38
|
+
"@babel/node": "^7.14.2",
|
|
39
|
+
"@babel/preset-env": "^7.14.2",
|
|
40
|
+
"@carbon/cli": "^10.26.0",
|
|
39
41
|
"@carbon/cli-reporter": "^10.5.0",
|
|
40
42
|
"@carbon/scss-generator": "^10.13.0",
|
|
41
43
|
"@carbon/test-utils": "^10.16.0",
|
|
@@ -46,5 +48,6 @@
|
|
|
46
48
|
"node-sass": "^4.13.1",
|
|
47
49
|
"rimraf": "^3.0.0"
|
|
48
50
|
},
|
|
49
|
-
"
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"gitHead": "388008d11f2996c262303445a2e26453cbda9261"
|
|
50
53
|
}
|
package/scss/modules/_theme.scss
CHANGED
|
@@ -7,18 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
@use 'sass:map';
|
|
9
9
|
@use 'sass:meta';
|
|
10
|
+
@use 'config';
|
|
10
11
|
@use 'themes';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/// Specify the fallback theme, used as a catch-all for tokens that you may not
|
|
14
|
+
/// have defined in your custom theme
|
|
15
|
+
$fallback: themes.$white !default;
|
|
14
16
|
|
|
15
|
-
///
|
|
16
|
-
///
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/// Specify the current theme. This can override existing tokens, or add new
|
|
18
|
+
/// tokens. If you are adding new tokens, it's recommended that you set the
|
|
19
|
+
/// fallback for your current theme
|
|
20
|
+
$theme: () !default;
|
|
21
|
+
$theme: map.merge($fallback, $theme);
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
/// Include the CSS Custom Properties for the active theme or a given theme on
|
|
24
|
+
/// a selector
|
|
25
|
+
@mixin theme($active-theme: $theme, $component-tokens...) {
|
|
26
|
+
@each $token, $value in $active-theme {
|
|
22
27
|
@include -custom-property($token, $value);
|
|
23
28
|
}
|
|
24
29
|
|
|
@@ -27,21 +32,20 @@ $-custom-property-prefix: 'cds';
|
|
|
27
32
|
@include -custom-property($token, $value);
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
@content;
|
|
32
|
-
|
|
33
|
-
$theme: $parent-theme !global;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
///
|
|
37
|
-
/// @
|
|
38
|
-
@
|
|
39
|
-
$theme
|
|
37
|
+
/// Retrieve the value for the given $token from the current $theme
|
|
38
|
+
/// @param {String} $token
|
|
39
|
+
@function get($token) {
|
|
40
|
+
@if map.has-key($theme, $token) {
|
|
41
|
+
@return map.get($theme, $token);
|
|
42
|
+
}
|
|
43
|
+
@error "Unable to find token: #{$token} in current $theme";
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/// @access private
|
|
43
47
|
/// @group @carbon/themes
|
|
44
|
-
@mixin -custom-property($name, $value
|
|
48
|
+
@mixin -custom-property($name, $value) {
|
|
45
49
|
@if meta.type-of($value) == map {
|
|
46
50
|
@each $property, $property-value in $value {
|
|
47
51
|
// Only support one-level of depth for values that are maps. This is to
|
|
@@ -51,6 +55,6 @@ $-custom-property-prefix: 'cds';
|
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
} @else {
|
|
54
|
-
--#{
|
|
58
|
+
--#{config.$prefix}-#{$name}: #{$value};
|
|
55
59
|
}
|
|
56
60
|
}
|