@carbon/styles 0.17.0 → 1.0.1

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 (100) hide show
  1. package/package.json +23 -10
  2. package/scss/__tests__/__snapshots__/colors-test.js.snap +404 -0
  3. package/scss/__tests__/__snapshots__/config-test.js.snap +44 -0
  4. package/scss/__tests__/__snapshots__/motion-test.js.snap +39 -0
  5. package/scss/__tests__/breakpoint-test.js +42 -0
  6. package/scss/__tests__/colors-test.js +28 -0
  7. package/scss/__tests__/config-test.js +53 -0
  8. package/scss/__tests__/grid-test.js +48 -0
  9. package/scss/__tests__/layer-test.js +82 -0
  10. package/scss/__tests__/motion-test.js +37 -0
  11. package/scss/__tests__/reset-test.js +28 -0
  12. package/scss/__tests__/theme-test.js +151 -0
  13. package/scss/__tests__/themes-test.js +36 -0
  14. package/scss/__tests__/type-test.js +77 -0
  15. package/scss/_breakpoint.scss +2 -1
  16. package/scss/_config.scss +9 -2
  17. package/scss/_reset.scss +5 -1
  18. package/scss/_spacing.scss +1 -1
  19. package/scss/_theme.scss +4 -4
  20. package/scss/_themes.scss +2 -1
  21. package/scss/components/__tests__/accordion-test.js +47 -0
  22. package/scss/components/__tests__/breadcrumb-test.js +27 -0
  23. package/scss/components/__tests__/button-test.js +71 -0
  24. package/scss/components/__tests__/checkbox-test.js +27 -0
  25. package/scss/components/__tests__/code-snippet-test.js +44 -0
  26. package/scss/components/__tests__/combo-box-test.js +27 -0
  27. package/scss/components/__tests__/content-switcher-test.js +27 -0
  28. package/scss/components/__tests__/copy-button-test.js +27 -0
  29. package/scss/components/__tests__/data-table-test.js +85 -0
  30. package/scss/components/__tests__/date-picker-test.js +26 -0
  31. package/scss/components/__tests__/dropdown-test.js +27 -0
  32. package/scss/components/__tests__/file-uploader.js +27 -0
  33. package/scss/components/__tests__/form-test.js +43 -0
  34. package/scss/components/__tests__/inline-loading-test.js +26 -0
  35. package/scss/components/__tests__/link-test.js +26 -0
  36. package/scss/components/__tests__/list-box-test.js +36 -0
  37. package/scss/components/__tests__/list-test.js +26 -0
  38. package/scss/components/__tests__/loading-test.js +26 -0
  39. package/scss/components/__tests__/menu-test.js +27 -0
  40. package/scss/components/__tests__/modal-test.js +27 -0
  41. package/scss/components/__tests__/multiselect-test.js +27 -0
  42. package/scss/components/__tests__/notification-test.js +49 -0
  43. package/scss/components/__tests__/number-input-test.js +27 -0
  44. package/scss/components/__tests__/overflow-menu-test.js +27 -0
  45. package/scss/components/__tests__/pagination-nav-test.js +26 -0
  46. package/scss/components/__tests__/pagination-test.js +26 -0
  47. package/scss/components/__tests__/progress-bar-test.js +26 -0
  48. package/scss/components/__tests__/progress-indicator-test.js +26 -0
  49. package/scss/components/__tests__/radio-button-test.js +25 -0
  50. package/scss/components/__tests__/search-test.js +25 -0
  51. package/scss/components/__tests__/select-test.js +26 -0
  52. package/scss/components/__tests__/skeleton-test.js +26 -0
  53. package/scss/components/__tests__/slider-test.js +26 -0
  54. package/scss/components/__tests__/structured-list-test.js +27 -0
  55. package/scss/components/__tests__/tabs-test.js +27 -0
  56. package/scss/components/__tests__/tag-test.js +25 -0
  57. package/scss/components/__tests__/text-area-test.js +26 -0
  58. package/scss/components/__tests__/text-input-test.js +26 -0
  59. package/scss/components/__tests__/tile-test.js +26 -0
  60. package/scss/components/__tests__/time-picker-test.js +26 -0
  61. package/scss/components/__tests__/toggle-test.js +27 -0
  62. package/scss/components/__tests__/tooltip-test.js +25 -0
  63. package/scss/components/__tests__/treeview-test.js +25 -0
  64. package/scss/components/__tests__/ui-shell-test.js +27 -0
  65. package/scss/components/accordion/_accordion.scss +1 -1
  66. package/scss/components/aspect-ratio/_aspect-ratio.scss +2 -2
  67. package/scss/components/breadcrumb/_breadcrumb.scss +1 -1
  68. package/scss/components/button/_button.scss +3 -9
  69. package/scss/components/button/_tokens.scss +1 -0
  70. package/scss/components/code-snippet/_code-snippet.scss +32 -47
  71. package/scss/components/content-switcher/_content-switcher.scss +0 -2
  72. package/scss/components/copy-button/_copy-button.scss +0 -59
  73. package/scss/components/dropdown/_dropdown.scss +0 -1
  74. package/scss/components/modal/_modal.scss +1 -1
  75. package/scss/components/notification/_actionable-notification.scss +58 -19
  76. package/scss/components/notification/_inline-notification.scss +9 -21
  77. package/scss/components/notification/_toast-notification.scss +29 -58
  78. package/scss/components/notification/_tokens.scss +2 -1
  79. package/scss/components/pagination/_unstable_pagination.scss +1 -1
  80. package/scss/components/progress-indicator/_progress-indicator.scss +5 -5
  81. package/scss/components/radio-button/_radio-button.scss +2 -10
  82. package/scss/components/tabs/_tabs.scss +1 -1
  83. package/scss/components/tag/_tokens.scss +1 -0
  84. package/scss/components/text-input/_text-input.scss +7 -22
  85. package/scss/components/tile/_tile.scss +60 -29
  86. package/scss/components/toggletip/_toggletip.scss +1 -2
  87. package/scss/fonts/__tests__/__snapshots__/fonts-test.js.snap +269 -0
  88. package/scss/fonts/__tests__/fonts-test.js +197 -0
  89. package/scss/fonts/_src.scss +42 -31
  90. package/scss/grid/_css-grid.scss +11 -0
  91. package/scss/grid/_flexbox.scss +1 -1
  92. package/scss/grid/_index.scss +7 -2
  93. package/scss/grid/_mixins.scss +9 -0
  94. package/scss/type/_reset.scss +1 -1
  95. package/scss/utilities/__tests__/custom-property-test.js +50 -0
  96. package/scss/utilities/_component-tokens.scss +2 -1
  97. package/scss/utilities/_convert.scss +2 -4
  98. package/scss/utilities/_high-contrast-mode.scss +2 -4
  99. package/docs/sass.md +0 -462
  100. package/scss/grid/_config.scss +0 -18
package/docs/sass.md DELETED
@@ -1,462 +0,0 @@
1
- # `@carbon/styles`
2
-
3
- <!-- prettier-ignore-start -->
4
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
5
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
6
- ## Table of Contents
7
-
8
- - [Overview](#overview)
9
- - [Files](#files)
10
- - [Breakpoint](#breakpoint)
11
- - [Colors](#colors)
12
- - [Config](#config)
13
- - [Feature Flags](#feature-flags)
14
- - [Grid](#grid)
15
- - [Using the grid](#using-the-grid)
16
- - [Classes provided](#classes-provided)
17
- - [Grid Mixins](#grid-mixins)
18
- - [Motion](#motion)
19
- - [Reset](#reset)
20
- - [Spacing](#spacing)
21
- - [Themes](#themes)
22
- - [Theme](#theme)
23
- - [Type](#type)
24
- - [Components](#components)
25
- - [Utilities](#utilities)
26
- - [Configuration](#configuration)
27
- - [`sass-loader`](#sass-loader)
28
- - [Parcel](#parcel)
29
- - [Vite](#vite)
30
-
31
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
32
- <!-- prettier-ignore-end -->
33
-
34
- ## Overview
35
-
36
- The `@carbon/styles` package provides the Sass files needed to include every
37
- style for the Carbon Design System. It includes entrypoints for themes, tokens,
38
- CSS helpers, components, and more.
39
-
40
- ### Files
41
-
42
- The following is a table of all files that are available to use. While there may
43
- be additional files that you can import from directly within the package, these
44
- are the public entrypoints that are maintained and follow semantic versioning
45
- between version updates.
46
-
47
- | File | Description |
48
- | :------------------------------------- | :--------------------------------------------------------- |
49
- | [`scss/breakpoint`](#breakpoint) | Helper functions and mixins for working with breakpoints |
50
- | [`scss/colors`](#colors) | Access colors from every swatch in the IBM Design Language |
51
- | [`scss/compat/`](#compatibility) | Helper themes and tokens for migrating from v10 to v11 |
52
- | [`scss/config`](#config) | Configure various options for the package |
53
- | [`scss/feature-flags`](#feature-flags) | Configure various feature flags for experiments |
54
- | [`scss/font-face`](#font-face) | Configure the IBM Plex font and languages |
55
- | [`scss/grid`](#grid) | Access and use the CSS Grid built-in to Carbon |
56
- | [`scss/motion`](#motion) | Helper function, mixins, and tokens for motion |
57
- | [`scss/reset`](#reset) | A CSS Reset |
58
- | [`scss/spacing`](#spacing) | Variables for the spacing scale |
59
- | [`scss/theme`](#theme) | Tokens for the current theme |
60
- | [`scss/themes`](#themes) | Reference the default themes from the Carbon Design System |
61
- | [`scss/type`](#type) | Type tokens and helpers |
62
- | [`scss/components/`](#components) | A directory containing component styles |
63
- | [`scss/utilities/`](#utilities) | A directory containing common CSS utilities |
64
-
65
- ## Breakpoint
66
-
67
- | Import | Filepath |
68
- | :--------------------------------------- | :---------------------- |
69
- | `@use '@carbon/styles/scss/breakpoint';` | `scss/_breakpoint.scss` |
70
-
71
- ## Colors
72
-
73
- The colors package will give you access to each swatch from the IBM Design
74
- Language. You can refer to any color by its swatch and grade.
75
-
76
- ```scss
77
- @use '@carbon/styles/scss/colors';
78
-
79
- .my-selector {
80
- background-color: colors.$blue-50;
81
- }
82
- ```
83
-
84
- | Import | Filepath |
85
- | :----------------------------------- | :------------------ |
86
- | `@use '@carbon/styles/scss/colors';` | `scss/_colors.scss` |
87
-
88
- To see all the colors available to be imported, checkout our
89
- [colors](https://github.com/carbon-design-system/carbon/tree/main/packages/colors)
90
- docs.
91
-
92
- ## Config
93
-
94
- | Import | Filepath |
95
- | :----------------------------------- | :------------------ |
96
- | `@use '@carbon/styles/scss/config';` | `scss/_config.scss` |
97
-
98
- ## Feature Flags
99
-
100
- | Import | Filepath |
101
- | :------------------------------------------ | :------------------------- |
102
- | `@use '@carbon/styles/scss/feature-flags';` | `scss/_feature-flags.scss` |
103
-
104
- ## Font Face
105
-
106
- | Import | Filepath |
107
- | :-------------------------------------- | :--------------------- |
108
- | `@use '@carbon/styles/scss/font-face';` | `scss/_font-face.scss` |
109
-
110
- ### Using IBM Plex
111
-
112
- By default, IBM Plex will be emitted when importing via the `@carbon/styles`
113
- main entrypoint or referencing the `font-face` file directly. If you do not want
114
- the font-face declarations to be emitted, you can set the `css--font-face` token
115
- to `false`:
116
-
117
- ```scss
118
- @use '@carbon/styles/scss/config' with (
119
- $css--font-face: false,
120
- );
121
- ```
122
-
123
- ## Grid
124
-
125
- | Import | Filepath |
126
- | :----------------------------------------- | :------------------------ |
127
- | `@use '@carbon/styles/scss/grid';` | `scss/grid/_index.scss` |
128
- | `@use '@carbon/styles/scss/grid/flexbox';` | `scss/grid/_flexbox.scss` |
129
-
130
- ### Using the grid
131
-
132
- This package `@forward`s the styles defined in the
133
- [`@carbon/grid`](https://github.com/carbon-design-system/carbon/tree/main/packages/grid)
134
- package. For full documentation, visit the
135
- [Sass Documentation](../../grid/docs/sass.md) for the package.
136
-
137
- To use the grid via `@carbon/styles`, it must be brought in directly or the grid
138
- specific style sheet must be imported:
139
-
140
- ```scss
141
- // All the grid styles are included through this central entrypoint
142
- @use '@carbon/styles';
143
-
144
- // Alternatively, the grid styles can be brought in on their own
145
- @use '@carbon/styles/scss/grid';
146
- ```
147
-
148
- By default, the emitted grid will be a CSS Grid based implementation. If you
149
- prefer to use flexbox version, you can configure the package by writing the
150
- following:
151
-
152
- ```scss
153
- @use '@carbon/styles' with (
154
- $use-flexbox-grid: true,
155
- );
156
- ```
157
-
158
- Or you can import the flexbox grid directly:
159
-
160
- ```scss
161
- @use '@carbon/styles/scss/grid/flexbox';
162
- ```
163
-
164
- ### Classes provided
165
-
166
- In either case, you will then have access to the grid classes and mixins
167
- available to build with the grid. There are two primitive class types to use in
168
- order to structure your application. They include:
169
-
170
- - `.#{$prefix}--css-grid` - defines the overall grid context and sets some
171
- useful attributes like width and margin
172
- - `.#{$prefix}--col-span-*` - used to define individual columns
173
-
174
- Additional class types are available for advanced usages such as subgrids,
175
- offset, alignment utilities, and breakpoint helpers to configure the grid at
176
- different viewport widths. For further information on these and others, see the
177
- [`@carbon/grid`](https://github.com/carbon-design-system/carbon/tree/main/packages/grid)
178
- package.
179
-
180
- As an example, here's how a 4 column grid could be configured with the default
181
- prefix:
182
-
183
- ```html
184
- <div class="cds--css-grid">
185
- <div class="cds--col-span-4"></div>
186
- <div class="cds--col-span-4"></div>
187
- <div class="cds--col-span-4"></div>
188
- <div class="cds--col-span-4"></div>
189
- </div>
190
- ```
191
-
192
- ## Motion
193
-
194
- The motion package provides helper functions, mixins, and duration tokens to add
195
- motion into your project.
196
-
197
- ```scss
198
- @use '@carbon/styles/scss/motion' as *;
199
-
200
- .my-selector {
201
- transition: transform $duration-fast-02 motion(standard, productive);
202
- }
203
- ```
204
-
205
- | Import | Filepath |
206
- | :----------------------------------- | :------------------ |
207
- | `@use '@carbon/styles/scss/motion';` | `scss/_motion.scss` |
208
-
209
- For more information, checkout our [motion](#todo) docs.
210
-
211
- ## Reset
212
-
213
- | Import | Filepath |
214
- | :---------------------------------- | :----------------- |
215
- | `@use '@carbon/styles/scss/reset';` | `scss/_reset.scss` |
216
-
217
- ## Spacing
218
-
219
- | Import | Filepath |
220
- | :------------------------------------ | :------------------- |
221
- | `@use '@carbon/styles/scss/spacing';` | `scss/_spacing.scss` |
222
-
223
- ## Themes
224
-
225
- | Import | Filepath |
226
- | :----------------------------------- | :------------------ |
227
- | `@use '@carbon/styles/scss/themes';` | `scss/_themes.scss` |
228
-
229
- This entrypoint re-exports the `themes` entrypoint from the `@carbon/themes`. it
230
- provides access to the theme variables built for the Carbon Design System.
231
-
232
- These theme variables can be used in the following way:
233
-
234
- ```scss
235
- @use '@carbon/styles/scss/themes';
236
-
237
- // themes.$white
238
- // themes.$g10
239
- // themes.$g90
240
- // themes.$g100
241
- ```
242
-
243
- ## Theme
244
-
245
- | Import | Filepath |
246
- | :---------------------------------- | :----------------- |
247
- | `@use '@carbon/styles/scss/theme';` | `scss/_theme.scss` |
248
-
249
- This entrypoint re-exports the `theme` entrypoint from the `@carbon/themes`.
250
- This entrypoint exports all of the design tokens as Sass Variables, as well as
251
- helpers for you to interact with the theme.
252
-
253
- To use a design token from this entrypoint, you can include the filepath and
254
- reference it as a variable.
255
-
256
- ```scss
257
- @use '@carbon/styles/scss/theme';
258
-
259
- body {
260
- background: theme.$background;
261
- }
262
- ```
263
-
264
- The value of the `theme.$background` token is a CSS Custom Property. For
265
- example, `theme.$background` would have the value `var(--cds-background)`. To
266
- get the value of a token, you will need to use the `theme.get` function
267
- described below.
268
-
269
- For a full list of tokens available, check out our
270
- [themes documentation](../../themes/docs/sass.md#tokens).
271
-
272
- There are also some helpers that you can use from this entrypoint. These
273
- include:
274
-
275
- - `theme.get` to get access to the value of a token from the theme
276
- - `theme.extend` to extend the current theme with new values
277
-
278
- You can use these in the following way:
279
-
280
- ```scss
281
- @use '@carbon/styles/scss/theme';
282
-
283
- @include theme.extend(
284
- (
285
- custom-token: #000000,
286
- )
287
- );
288
-
289
- .my-selector {
290
- background: rgba(theme.get('custom-token'), 0.1);
291
- }
292
- ```
293
-
294
- **Configuration**
295
-
296
- The `@carbon/styles/scss/theme` entrypoint can be configured with the following
297
- options:
298
-
299
- - `$theme` to set the current theme
300
- - `$fallback` to set the fallback theme. This value is used to get values of
301
- tokens if they are not defined in the current `$theme`
302
-
303
- ## Type
304
-
305
- The type package entrypoint allows you to specifically bring type tokens into
306
- your project. The type package includes various type tokens and mixins.
307
-
308
- ```scss
309
- @use '@carbon/styles/scss/type';
310
-
311
- .my-selector {
312
- @include type.style(type.$productive-heading-01);
313
- }
314
- ```
315
-
316
- | Import | Filepath |
317
- | :--------------------------------- | :---------------- |
318
- | `@use '@carbon/styles/scss/type';` | `scss/_type.scss` |
319
-
320
- For more information, check out our [type](#todo) docs.
321
-
322
- ## Components
323
-
324
- All of the styles for the components in the Carbon Design System live in the
325
- `scss/components` directory. You can include all of the styles for a component
326
- by including its entrypoint file. For a full list of component styles that you
327
- can import, check out the files table below.
328
-
329
- **Component tokens**
330
-
331
- In some situations, you may want to change the tokens for a specific component.
332
- To do so you will need to configure the module and provide the tokens you would
333
- like to see changed. For example, if you wanted to change the component token
334
- `button-separator` for `button` you would do the following:
335
-
336
- ```scss
337
- @use '@carbon/styles/scss/components/button' with (
338
- $button-separator: #e4e4e4,
339
- );
340
- ```
341
-
342
- **Files**
343
-
344
- | Component | Import | File |
345
- | :-------- | :------------------------------------------------- | :---------------------------------------------------------- |
346
- | Accordion | `@use '@carbon/styles/scss/components/accordion';` | [`scss/components/accordion`](../scss/components/accordion) |
347
-
348
- ## Utilities
349
-
350
- **Files**
351
-
352
- | Import | Description |
353
- | :---------------------------------------------------- | :---------- |
354
- | `@use '@carbon/styles/scss/utilities/focus-outline';` | |
355
-
356
- ## Compatibility
357
-
358
- | Import | Filepath |
359
- | :------------------------------------------ | :------------------------- |
360
- | `@use '@carbon/styles/scss/compat/themes';` | `scss/compat/_themes.scss` |
361
- | `@use '@carbon/styles/scss/compat/theme';` | `scss/compat/_theme.scss` |
362
-
363
- The compatibility entrypoints for themes and theme provide access to the v10
364
- tokens along with the v11 tokens. To make sure that the tokens that you're using
365
- from v10 have the correct value in v11, you will need to include the theme that
366
- you're using from `scss/compat/themes` and set that as your theme.
367
-
368
- ```scss
369
- @use '@carbon/styles/scss/compat/themes' as compat;
370
- @use '@carbon/styles/scss/compat/theme' with (
371
- $theme: compat.$g100,
372
- );
373
- ```
374
-
375
- It's important that you specify the `$fallback` theme as a value from the
376
- `scss/themes` entrypoint. This will guarantee that all tokens that you are using
377
- from v11 will match the theme of the tokens that you are using from v10.
378
-
379
- You can directly reference a token from the `scss/compat/theme` entrypoint. This
380
- entrypoint will also re-export all available v11 tokens and mixins from
381
- `scss/theme`.
382
-
383
- ```scss
384
- @use '@carbon/styles/scss/compat/theme';
385
-
386
- body {
387
- // You can use both v10 and v11 tokens
388
- background: theme.$background;
389
- color: theme.$text-01;
390
- }
391
- ```
392
-
393
- _Note: all tokens from v10 are deprecated in v11. They will be removed in the
394
- next major release of Carbon_
395
-
396
- ## Configuration
397
-
398
- You will need to configure Sass to be able to lookup packages from your
399
- `node_modules` folder. To do this, use the `includePaths` option and set its
400
- value to an array of locations where Sass should look to find `node_modules`
401
- folders.
402
-
403
- For most teams, this configuration will look like:
404
-
405
- ```json
406
- {
407
- "includePaths": ["node_modules"]
408
- }
409
- ```
410
-
411
- For bundler specific solutions, check out the sections below for your bundler of
412
- choice. If you can't find what you're looking for, please make an
413
- [issue](https://github.com/carbon-design-system/carbon/issues/new/choose) and
414
- we'll try to get instructions for it added!
415
-
416
- ### `sass-loader`
417
-
418
- [Link](https://www.npmjs.com/package/sass-loader)
419
-
420
- Update your `webpack.config.js` that uses `sass-loader` with the following
421
- options passed into `sassOptions`:
422
-
423
- ```js
424
- {
425
- loader: 'sass-loader',
426
- options: {
427
- sassOptions: {
428
- includePaths: ['node_modules'],
429
- },
430
- },
431
- }
432
- ```
433
-
434
- ### Parcel
435
-
436
- [Link](https://www.npmjs.com/package/parcel)
437
-
438
- Create a `.sassrc` file with the following configuration:
439
-
440
- ```json
441
- {
442
- "includePaths": ["node_modules"]
443
- }
444
- ```
445
-
446
- ### Vite
447
-
448
- [Link](https://vitejs.dev/)
449
-
450
- Create a `vite.config.js` file with the following configuration:
451
-
452
- ```js
453
- export default {
454
- css: {
455
- preprocessorOptions: {
456
- scss: {
457
- includePaths: ['node_modules'],
458
- },
459
- },
460
- },
461
- };
462
- ```
@@ -1,18 +0,0 @@
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
- @forward '@carbon/grid'
10
- show css-grid,
11
- flex-grid,
12
- $grid-gutter,
13
- $grid-gutter-condensed,
14
- $grid-breakpoints
15
- with (
16
- $prefix: config.$prefix !default,
17
- $flex-grid-columns: config.$flex-grid-columns !default
18
- );