@instructure/ui-color-picker 9.2.1-snapshot-2 → 9.2.1-snapshot-4

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 (54) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/es/ColorContrast/__new-tests__/ColorContrast.test.js +176 -0
  3. package/es/ColorIndicator/__new-tests__/ColorIndicator.test.js +66 -0
  4. package/es/ColorMixer/__new-tests__/ColorMixer.test.js +469 -0
  5. package/es/ColorPicker/__new-tests__/ColorPicker.test.js +502 -0
  6. package/es/ColorPreset/__new-tests__/ColorPreset.test.js +167 -0
  7. package/lib/ColorContrast/__new-tests__/ColorContrast.test.js +179 -0
  8. package/lib/ColorIndicator/__new-tests__/ColorIndicator.test.js +67 -0
  9. package/lib/ColorMixer/__new-tests__/ColorMixer.test.js +472 -0
  10. package/lib/ColorPicker/__new-tests__/ColorPicker.test.js +503 -0
  11. package/lib/ColorPreset/__new-tests__/ColorPreset.test.js +170 -0
  12. package/package.json +29 -25
  13. package/src/ColorContrast/__new-tests__/ColorContrast.test.tsx +237 -0
  14. package/src/ColorIndicator/__new-tests__/ColorIndicator.test.tsx +71 -0
  15. package/src/ColorMixer/__new-tests__/ColorMixer.test.tsx +624 -0
  16. package/src/ColorPicker/__new-tests__/ColorPicker.test.tsx +626 -0
  17. package/src/ColorPreset/__new-tests__/ColorPreset.test.tsx +205 -0
  18. package/tsconfig.build.json +2 -2
  19. package/tsconfig.build.tsbuildinfo +1 -1
  20. package/types/ColorContrast/__new-tests__/ColorContrast.test.d.ts +2 -0
  21. package/types/ColorContrast/__new-tests__/ColorContrast.test.d.ts.map +1 -0
  22. package/types/ColorIndicator/__new-tests__/ColorIndicator.test.d.ts +2 -0
  23. package/types/ColorIndicator/__new-tests__/ColorIndicator.test.d.ts.map +1 -0
  24. package/types/ColorMixer/__new-tests__/ColorMixer.test.d.ts +2 -0
  25. package/types/ColorMixer/__new-tests__/ColorMixer.test.d.ts.map +1 -0
  26. package/types/ColorPicker/__new-tests__/ColorPicker.test.d.ts +2 -0
  27. package/types/ColorPicker/__new-tests__/ColorPicker.test.d.ts.map +1 -0
  28. package/types/ColorPreset/__new-tests__/ColorPreset.test.d.ts +2 -0
  29. package/types/ColorPreset/__new-tests__/ColorPreset.test.d.ts.map +1 -0
  30. package/es/ColorContrast/ColorContrastLocator.js +0 -51
  31. package/es/ColorIndicator/ColorIndicatorLocator.js +0 -39
  32. package/es/ColorMixer/ColorMixerLocator.js +0 -45
  33. package/es/ColorPicker/ColorPickerLocator.js +0 -112
  34. package/es/ColorPreset/ColorPresetLocator.js +0 -70
  35. package/lib/ColorContrast/ColorContrastLocator.js +0 -57
  36. package/lib/ColorIndicator/ColorIndicatorLocator.js +0 -45
  37. package/lib/ColorMixer/ColorMixerLocator.js +0 -52
  38. package/lib/ColorPicker/ColorPickerLocator.js +0 -119
  39. package/lib/ColorPreset/ColorPresetLocator.js +0 -78
  40. package/src/ColorContrast/ColorContrastLocator.ts +0 -51
  41. package/src/ColorIndicator/ColorIndicatorLocator.ts +0 -41
  42. package/src/ColorMixer/ColorMixerLocator.ts +0 -47
  43. package/src/ColorPicker/ColorPickerLocator.ts +0 -124
  44. package/src/ColorPreset/ColorPresetLocator.ts +0 -75
  45. package/types/ColorContrast/ColorContrastLocator.d.ts +0 -2692
  46. package/types/ColorContrast/ColorContrastLocator.d.ts.map +0 -1
  47. package/types/ColorIndicator/ColorIndicatorLocator.d.ts +0 -577
  48. package/types/ColorIndicator/ColorIndicatorLocator.d.ts.map +0 -1
  49. package/types/ColorMixer/ColorMixerLocator.d.ts +0 -597
  50. package/types/ColorMixer/ColorMixerLocator.d.ts.map +0 -1
  51. package/types/ColorPicker/ColorPickerLocator.d.ts +0 -5543
  52. package/types/ColorPicker/ColorPickerLocator.d.ts.map +0 -1
  53. package/types/ColorPreset/ColorPresetLocator.d.ts +0 -2
  54. package/types/ColorPreset/ColorPresetLocator.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [9.2.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-2) (2024-07-10)
6
+ ## [9.2.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v9.2.0...v9.2.1-snapshot-4) (2024-07-12)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-color-picker
9
9
 
@@ -0,0 +1,176 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react';
26
+ import { render } from '@testing-library/react';
27
+ import { vi } from 'vitest';
28
+ import '@testing-library/jest-dom';
29
+
30
+ // eslint-disable-next-line no-restricted-imports
31
+ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests';
32
+ import { runAxeCheck } from '@instructure/ui-axe-check';
33
+ import { contrast } from '@instructure/ui-color-utils';
34
+ import { ColorContrast } from '../';
35
+ import ColorContrastExamples from '../__examples__/ColorContrast.examples';
36
+ const testColors = {
37
+ firstColor: '#FF0000',
38
+ secondColor: '#FFFF00'
39
+ };
40
+ const testLabels = {
41
+ label: 'Color Contrast Ratio',
42
+ successLabel: 'PASS',
43
+ failureLabel: 'FAIL',
44
+ normalTextLabel: 'Normal text',
45
+ largeTextLabel: 'Large text',
46
+ graphicsTextLabel: 'Graphics text',
47
+ firstColorLabel: 'Background',
48
+ secondColorLabel: 'Foreground'
49
+ };
50
+ describe('<ColorContrast />', () => {
51
+ describe('elementRef prop', () => {
52
+ it('should provide ref', async () => {
53
+ const elementRef = vi.fn();
54
+ const _render = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testColors, testLabels, {
55
+ elementRef: elementRef
56
+ }))),
57
+ container = _render.container;
58
+ expect(elementRef).toHaveBeenCalledWith(container.firstChild);
59
+ });
60
+ });
61
+ describe('labels are displayed:', () => {
62
+ Object.entries(testLabels).forEach(([label, text]) => {
63
+ it(label, async () => {
64
+ const _render2 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testColors, testLabels))),
65
+ container = _render2.container;
66
+ expect(container).toHaveTextContent(text);
67
+ });
68
+ });
69
+ });
70
+ describe('should calculate contrast correctly', () => {
71
+ it('on opaque colors', async () => {
72
+ const color1 = '#fff';
73
+ const color2 = '#088';
74
+ const _render3 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testLabels, {
75
+ firstColor: color1,
76
+ secondColor: color2
77
+ }))),
78
+ container = _render3.container;
79
+ const contrastResult = contrast(color1, color2, 2);
80
+ expect(container).toHaveTextContent(contrastResult + ':1');
81
+ });
82
+ it('on transparent colors', async () => {
83
+ const color1 = '#fff';
84
+ const color2 = '#00888880';
85
+ const _render4 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testLabels, {
86
+ firstColor: color1,
87
+ secondColor: color2
88
+ }))),
89
+ container = _render4.container;
90
+
91
+ // this is the result of a complicated "blended color" calculation
92
+ // in the component, not simple `contrast()` check
93
+ expect(container).toHaveTextContent('2:1');
94
+ });
95
+ });
96
+ describe('withoutColorPreview prop', () => {
97
+ it('should be false by default, should display preview', async () => {
98
+ const _render5 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testColors, testLabels))),
99
+ container = _render5.container;
100
+ const preview = container.querySelector("[class$='-colorContrast__colorPreview']");
101
+ expect(preview).toBeInTheDocument();
102
+ });
103
+ it('should hide preview', async () => {
104
+ const _render6 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testColors, testLabels, {
105
+ withoutColorPreview: true
106
+ }))),
107
+ container = _render6.container;
108
+ const preview = container.querySelector("[class$='-colorContrast__colorPreview']");
109
+ expect(preview).not.toBeInTheDocument();
110
+ });
111
+ });
112
+ describe('contrast check', () => {
113
+ const checkContrastPills = (title, firstColor, secondColor, expectedResult) => {
114
+ describe(title, () => {
115
+ it(`normal text should ${expectedResult.normal.toLowerCase()}`, async () => {
116
+ const _render7 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testLabels, {
117
+ firstColor: firstColor,
118
+ secondColor: secondColor
119
+ }))),
120
+ container = _render7.container;
121
+ expect(container).toHaveTextContent(expectedResult.normal);
122
+ });
123
+ it(`large text should ${expectedResult.large.toLowerCase()}`, async () => {
124
+ const _render8 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testLabels, {
125
+ firstColor: firstColor,
126
+ secondColor: secondColor
127
+ }))),
128
+ container = _render8.container;
129
+ expect(container).toHaveTextContent(expectedResult.large);
130
+ });
131
+ it(`graphics should ${expectedResult.graphics.toLowerCase()}`, async () => {
132
+ const _render9 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testLabels, {
133
+ firstColor: firstColor,
134
+ secondColor: secondColor
135
+ }))),
136
+ container = _render9.container;
137
+ expect(container).toHaveTextContent(expectedResult.graphics);
138
+ });
139
+ });
140
+ };
141
+ checkContrastPills('on x < 3 contrast', '#fff', '#aaa', {
142
+ normal: 'FAIL',
143
+ large: 'FAIL',
144
+ graphics: 'FAIL'
145
+ });
146
+ checkContrastPills('on small 3 < x < 4.5 contrast', '#fff', '#0c89bf', {
147
+ normal: 'FAIL',
148
+ large: 'PASS',
149
+ graphics: 'PASS'
150
+ });
151
+ checkContrastPills('on small x > 4.5 contrast', '#fff', '#333', {
152
+ normal: 'PASS',
153
+ large: 'PASS',
154
+ graphics: 'PASS'
155
+ });
156
+ });
157
+ describe('should be accessible', () => {
158
+ it('a11y', async () => {
159
+ const _render10 = render( /*#__PURE__*/React.createElement(ColorContrast, Object.assign({}, testColors, testLabels))),
160
+ container = _render10.container;
161
+ const axeCheck = await runAxeCheck(container);
162
+ expect(axeCheck).toBe(true);
163
+ });
164
+ describe('with generated examples', () => {
165
+ const generatedComponents = generateA11yTests(ColorContrast, ColorContrastExamples);
166
+ it.each(generatedComponents)('should be accessible with example: $description', async ({
167
+ content
168
+ }) => {
169
+ const _render11 = render(content),
170
+ container = _render11.container;
171
+ const axeCheck = await runAxeCheck(container);
172
+ expect(axeCheck).toBe(true);
173
+ });
174
+ });
175
+ });
176
+ });
@@ -0,0 +1,66 @@
1
+ var _ColorIndicator;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import React from 'react';
27
+ import { render } from '@testing-library/react';
28
+ import { vi } from 'vitest';
29
+ import '@testing-library/jest-dom';
30
+
31
+ // eslint-disable-next-line no-restricted-imports
32
+ import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests';
33
+ import { runAxeCheck } from '@instructure/ui-axe-check';
34
+ import { ColorIndicator } from '../';
35
+ import ColorIndicatorExamples from '../__examples__/ColorIndicator.examples';
36
+ describe('<ColorIndicator />', () => {
37
+ describe('elementRef prop', () => {
38
+ it('should provide ref', async () => {
39
+ const elementRef = vi.fn();
40
+ const _render = render( /*#__PURE__*/React.createElement(ColorIndicator, {
41
+ elementRef: elementRef
42
+ })),
43
+ container = _render.container;
44
+ expect(elementRef).toHaveBeenCalledWith(container.firstChild);
45
+ });
46
+ });
47
+ describe('should be accessible', () => {
48
+ it('a11y', async () => {
49
+ const _render2 = render(_ColorIndicator || (_ColorIndicator = /*#__PURE__*/React.createElement(ColorIndicator, null))),
50
+ container = _render2.container;
51
+ const axeCheck = await runAxeCheck(container);
52
+ expect(axeCheck).toBe(true);
53
+ });
54
+ describe('with generated examples', () => {
55
+ const generatedComponents = generateA11yTests(ColorIndicator, ColorIndicatorExamples);
56
+ it.each(generatedComponents)('should be accessible with example: $description', async ({
57
+ content
58
+ }) => {
59
+ const _render3 = render(content),
60
+ container = _render3.container;
61
+ const axeCheck = await runAxeCheck(container);
62
+ expect(axeCheck).toBe(true);
63
+ });
64
+ });
65
+ });
66
+ });