@carbon/styles 0.16.0-rc.0 → 0.16.2

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