@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
@@ -123,7 +123,7 @@ $radio-border-width: 1px !default;
123
123
  }
124
124
 
125
125
  .#{$prefix}--radio-button:disabled + .#{$prefix}--radio-button__label {
126
- color: $button-disabled;
126
+ color: $text-disabled;
127
127
  cursor: not-allowed;
128
128
  }
129
129
 
@@ -133,10 +133,11 @@ $radio-border-width: 1px !default;
133
133
  .#{$prefix}--radio-button:disabled:checked
134
134
  + .#{$prefix}--radio-button__label
135
135
  .#{$prefix}--radio-button__appearance {
136
- border-color: $border-disabled;
136
+ // Disabled radio button, checkbox fix #10913
137
+ border-color: $icon-disabled;
137
138
 
138
139
  &::before {
139
- background-color: $button-disabled;
140
+ background-color: $text-disabled;
140
141
  }
141
142
  }
142
143
 
@@ -62,7 +62,7 @@
62
62
  transition: outline $duration-fast-01 motion(standard, productive);
63
63
 
64
64
  &:hover {
65
- background-color: $background-hover;
65
+ background-color: $field-hover;
66
66
  }
67
67
 
68
68
  // Hide default select arrow in IE10+
@@ -89,7 +89,7 @@
89
89
 
90
90
  &:disabled,
91
91
  &:hover:disabled {
92
- border-bottom-color: $border-disabled;
92
+ border-bottom-color: transparent;
93
93
  background-color: $field;
94
94
  color: $text-disabled;
95
95
  cursor: not-allowed;
@@ -101,8 +101,6 @@
101
101
  max-height: rem(32px);
102
102
  }
103
103
 
104
- // TODO V11: Remove xl selector
105
- .#{$prefix}--select-input--xl,
106
104
  .#{$prefix}--select-input--lg {
107
105
  height: rem(48px);
108
106
  max-height: rem(48px);
@@ -115,7 +113,7 @@
115
113
 
116
114
  .#{$prefix}--select-input__wrapper[data-invalid] .#{$prefix}--select-input,
117
115
  .#{$prefix}--select--warning .#{$prefix}--select-input {
118
- padding-right: carbon--mini-units(9);
116
+ padding-right: $spacing-10;
119
117
  }
120
118
 
121
119
  .#{$prefix}--select-input:disabled ~ .#{$prefix}--select__arrow {
@@ -123,15 +121,15 @@
123
121
  }
124
122
 
125
123
  .#{$prefix}--select--light .#{$prefix}--select-input {
126
- background-color: $field-02;
124
+ background-color: $field;
127
125
 
128
126
  &:hover {
129
- background-color: $background-hover;
127
+ background-color: $field-hover;
130
128
  }
131
129
 
132
130
  &:disabled,
133
131
  &:hover:disabled {
134
- background-color: $field-02;
132
+ background-color: $field;
135
133
  color: $text-disabled;
136
134
  cursor: not-allowed;
137
135
  }
@@ -178,7 +176,7 @@
178
176
  optgroup.#{$prefix}--select-optgroup,
179
177
  .#{$prefix}--select-option {
180
178
  // For the options to show in IE11
181
- background-color: $background-hover;
179
+ background-color: $layer-hover;
182
180
  color: $text-primary;
183
181
 
184
182
  &:disabled {
@@ -65,6 +65,10 @@ $icon-tab-size: custom-property.get-var('icon-tab-size', rem(40px));
65
65
  }
66
66
  }
67
67
 
68
+ .#{$prefix}--tabs__nav {
69
+ display: flex;
70
+ }
71
+
68
72
  //-----------------------------
69
73
  // Overflow Nav Buttons
70
74
  //-----------------------------
@@ -0,0 +1,142 @@
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
+ * @jest-environment node
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const { SassRenderer } = require('@carbon/test-utils/scss');
13
+ const css = require('css');
14
+
15
+ const { render } = SassRenderer.create(__dirname);
16
+
17
+ const fonts = [
18
+ 'mono',
19
+ 'sans-arabic',
20
+ 'sans-devanagari',
21
+ 'sans-hebrew',
22
+ 'sans-thai-looped',
23
+ 'sans-thai',
24
+ 'sans',
25
+ 'serif',
26
+ ];
27
+ const weights = [
28
+ 'thin',
29
+ 'extralight',
30
+ 'light',
31
+ 'regular',
32
+ 'text',
33
+ 'medium',
34
+ 'semibold',
35
+ 'bold',
36
+ ];
37
+
38
+ describe('@carbon/styles/scss/fonts', () => {
39
+ it('should emit default fonts, weights, and styles', async () => {
40
+ const { result } = await render(`@use '../' as fonts;`);
41
+ const { stylesheet } = css.parse(result.css.toString());
42
+ const atRules = stylesheet.rules.filter((rule) => {
43
+ return rule.type === 'font-face';
44
+ });
45
+ const emitted = new Map();
46
+
47
+ for (const rule of atRules) {
48
+ const fontFamily = rule.declarations
49
+ .find((declaration) => {
50
+ return declaration.property === 'font-family';
51
+ })
52
+ .value.replace(/['"]/g, '');
53
+
54
+ if (!emitted.has(fontFamily)) {
55
+ emitted.set(fontFamily, {
56
+ weights: new Set(),
57
+ styles: new Set(),
58
+ });
59
+ }
60
+
61
+ const entry = emitted.get(fontFamily);
62
+
63
+ for (const declaration of rule.declarations) {
64
+ if (declaration.property === 'font-weight') {
65
+ entry.weights.add(declaration.value);
66
+ }
67
+
68
+ if (declaration.property === 'font-style') {
69
+ entry.styles.add(declaration.value);
70
+ }
71
+ }
72
+ }
73
+
74
+ expect(emitted.has('IBM Plex Mono')).toBe(true);
75
+ const mono = emitted.get('IBM Plex Mono');
76
+ expect(mono.weights).toEqual(new Set(['300', '400', '600']));
77
+ expect(mono.styles).toEqual(new Set(['normal', 'italic']));
78
+
79
+ expect(emitted.has('IBM Plex Sans')).toBe(true);
80
+ expect(emitted.get('IBM Plex Sans').weights).toEqual(
81
+ new Set(['300', '400', '600'])
82
+ );
83
+ expect(emitted.get('IBM Plex Sans').styles).toEqual(
84
+ new Set(['normal', 'italic'])
85
+ );
86
+
87
+ expect(emitted.has('IBM Plex Serif')).toBe(true);
88
+ expect(emitted.get('IBM Plex Serif').weights).toEqual(
89
+ new Set(['300', '400', '600'])
90
+ );
91
+ expect(emitted.get('IBM Plex Serif').styles).toEqual(
92
+ new Set(['normal', 'italic'])
93
+ );
94
+ });
95
+
96
+ it('should emit no @font-face blocks if $css--font-face is false', async () => {
97
+ const { result } = await render(`
98
+ @use '../../config' with (
99
+ $css--font-face: false,
100
+ );
101
+ @use '../' as fonts;
102
+ `);
103
+ expect(result.css.toString()).toBe('');
104
+ });
105
+
106
+ it('should not emit fonts set to false', async () => {
107
+ const { result } = await render(`
108
+ @use '../' as fonts with (
109
+ $fonts: (
110
+ IBM-Plex-Mono: false,
111
+ IBM-Plex-Sans: false,
112
+ IBM-Plex-Serif: false,
113
+ ),
114
+ );
115
+ `);
116
+ expect(result.css.toString()).toBe('');
117
+ });
118
+
119
+ describe.each(fonts)('scss/fonts/_%s.scss', (font) => {
120
+ it('should export all font weights as mixins', async () => {
121
+ const weightMixins = weights.map((weight) => {
122
+ return `$_: get('${weight}', meta.mixin-exists('${weight}', '${font}'));`;
123
+ });
124
+
125
+ const { unwrap } = await render(`
126
+ @use 'sass:meta';
127
+ @use '../${font}';
128
+
129
+ ${weightMixins.join('\n')}
130
+ $_: get('all', meta.mixin-exists('all', '${font}'));
131
+ $_: get('default', meta.mixin-exists('default', '${font}'));
132
+ `);
133
+
134
+ for (const weight of weights) {
135
+ expect(unwrap(weight)).toBe(true);
136
+ }
137
+
138
+ expect(unwrap('all')).toBe(true);
139
+ expect(unwrap('default')).toBe(true);
140
+ });
141
+ });
142
+ });
@@ -5,18 +5,14 @@
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  //
7
7
 
8
- @use 'config';
9
-
8
+ @use '../config';
10
9
  @forward '@carbon/grid'
11
10
  show css-grid,
12
- subgrid,
13
11
  flex-grid,
14
12
  $grid-gutter,
15
13
  $grid-gutter-condensed,
16
14
  $grid-breakpoints
17
15
  with (
18
- $prefix: config.$prefix,
19
- $flex-grid-columns: config.$flex-grid-columns,
16
+ $prefix: config.$prefix !default,
17
+ $flex-grid-columns: config.$flex-grid-columns !default
20
18
  );
21
-
22
- @use '@carbon/grid';
@@ -0,0 +1,11 @@
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
+ @forward 'config';
9
+ @use '@carbon/grid';
10
+
11
+ @include grid.flex-grid();
@@ -0,0 +1,16 @@
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
+ @forward 'config';
9
+ @use '@carbon/grid';
10
+ @use '../config';
11
+
12
+ @if config.$use-flexbox-grid == true {
13
+ @include grid.flex-grid();
14
+ } @else {
15
+ @include grid.css-grid();
16
+ }
@@ -5,7 +5,7 @@
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  //
7
7
 
8
- @use 'config';
8
+ @use '../config';
9
9
  @forward '@carbon/type' show
10
10
  // Mixins
11
11
  reset,
@@ -0,0 +1,8 @@
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
+ @forward '@carbon/type/scss/modules/reset';
@@ -0,0 +1,50 @@
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
+ * @jest-environment node
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const { SassRenderer } = require('@carbon/test-utils/scss');
13
+ const css = require('css');
14
+
15
+ const { render } = SassRenderer.create(__dirname);
16
+
17
+ describe('scss/utilities/custom-property', () => {
18
+ it('should support getting the property name from a value', async () => {
19
+ const { unwrap } = await render(`
20
+ @use '../../config' with (
21
+ $prefix: 'cds',
22
+ );
23
+ @use '../custom-property';
24
+
25
+ $_: get('name', custom-property.get-name('test'));
26
+ `);
27
+ expect(unwrap('name')).toBe('--cds-test');
28
+ });
29
+
30
+ it('should support emitting a declaration for a CSS Custom Property', async () => {
31
+ const { result } = await render(`
32
+ @use '../../config' with (
33
+ $prefix: 'cds',
34
+ );
35
+ @use '../custom-property';
36
+
37
+ .test {
38
+ @include custom-property.declaration(test, #000000);
39
+ }
40
+ `);
41
+ const { stylesheet } = css.parse(result.css.toString());
42
+ const selector = stylesheet.rules.find((rule) => {
43
+ return rule.selectors.includes('.test');
44
+ });
45
+ const [declaration] = selector.declarations;
46
+
47
+ expect(declaration.property).toBe('--cds-test');
48
+ expect(declaration.value).toBe('#000000');
49
+ });
50
+ });