@onewelcome/react-lib-components 1.7.0 → 1.8.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/dist/Typography/Typography.d.ts +1 -1
- package/dist/_BaseStyling_/BaseStyling.d.ts +20 -0
- package/dist/react-lib-components.cjs.development.js +89 -64
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +89 -64
- package/dist/react-lib-components.esm.js.map +1 -1
- package/dist/util/helper.d.ts +2 -0
- package/package.json +3 -3
- package/src/Breadcrumbs/Breadcrumbs.module.scss +2 -2
- package/src/Button/Button.module.scss +14 -2
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -0
- package/src/DataGrid/DataGridHeader/DataGridHeader.module.scss +1 -1
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +1 -1
- package/src/Form/Fieldset/Fieldset.module.scss +8 -1
- package/src/Form/FileUpload/FileUpload.module.scss +2 -2
- package/src/Form/Input/Input.module.scss +9 -2
- package/src/Form/Select/Select.module.scss +26 -3
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +3 -1
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss +9 -1
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +11 -2
- package/src/Link/Link.module.scss +1 -1
- package/src/Notifications/Banner/Banner.module.scss +2 -2
- package/src/Pagination/Pagination.module.scss +1 -0
- package/src/Tabs/TabButton.module.scss +3 -3
- package/src/Tabs/Tabs.module.scss +1 -0
- package/src/Typography/Typography.module.scss +2 -2
- package/src/Typography/Typography.tsx +1 -1
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +17 -7
- package/src/_BaseStyling_/BaseStyling.tsx +67 -27
- package/src/mixins.module.scss +2 -2
- package/src/util/helper.test.tsx +34 -17
- package/src/util/helper.tsx +5 -0
- package/src/variables.scss +18 -0
package/src/util/helper.test.tsx
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
import React, { useCallback, useEffect, useState } from "react";
|
|
18
18
|
import { fireEvent, waitFor } from "@testing-library/dom";
|
|
19
19
|
import {
|
|
20
|
-
generateID,
|
|
21
|
-
filterProps,
|
|
22
20
|
debounce,
|
|
21
|
+
filterProps,
|
|
22
|
+
generateID,
|
|
23
|
+
remToPx,
|
|
23
24
|
throttle,
|
|
24
25
|
areArraysDifferent,
|
|
25
26
|
getValueByPath,
|
|
@@ -84,11 +85,11 @@ describe("debounce function", () => {
|
|
|
84
85
|
|
|
85
86
|
window.addEventListener("resize", debounce(debouncedFunction, 200));
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
fireEvent.resize(window);
|
|
89
|
+
fireEvent.resize(window);
|
|
90
|
+
fireEvent.resize(window);
|
|
91
|
+
fireEvent.resize(window);
|
|
92
|
+
fireEvent.resize(window);
|
|
92
93
|
|
|
93
94
|
await waitFor(() => expect(debouncedFunction).toHaveBeenCalledTimes(1));
|
|
94
95
|
});
|
|
@@ -158,16 +159,16 @@ describe("throttling works", () => {
|
|
|
158
159
|
|
|
159
160
|
render(<ExampleComponent throttledFunction={exampleFunction} />);
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
fireEvent.resize(window);
|
|
163
|
+
fireEvent.resize(window);
|
|
164
|
+
fireEvent.resize(window);
|
|
165
|
+
fireEvent.resize(window);
|
|
166
|
+
fireEvent.resize(window);
|
|
167
|
+
fireEvent.resize(window);
|
|
168
|
+
fireEvent.resize(window);
|
|
169
|
+
fireEvent.resize(window);
|
|
170
|
+
fireEvent.resize(window);
|
|
171
|
+
fireEvent.resize(window);
|
|
171
172
|
|
|
172
173
|
expect(exampleFunction).not.toHaveBeenCalledTimes(1);
|
|
173
174
|
expect(exampleFunction).not.toHaveBeenCalledTimes(10);
|
|
@@ -320,3 +321,19 @@ describe("verifies if isEqual returns the correct value", () => {
|
|
|
320
321
|
expect(res).toBe(false);
|
|
321
322
|
});
|
|
322
323
|
});
|
|
324
|
+
|
|
325
|
+
describe("pixel to rem function works", () => {
|
|
326
|
+
document.documentElement.style.setProperty("font-size", "16px");
|
|
327
|
+
|
|
328
|
+
it.each([
|
|
329
|
+
[1, 16],
|
|
330
|
+
[1.25, 20],
|
|
331
|
+
[1.5, 24],
|
|
332
|
+
[1.75, 28],
|
|
333
|
+
[2, 32]
|
|
334
|
+
])("%p rem equals %p px when font-size is 16px", async (rem: number, px: number) => {
|
|
335
|
+
const result = remToPx(rem);
|
|
336
|
+
|
|
337
|
+
expect(result).toBe(px);
|
|
338
|
+
});
|
|
339
|
+
});
|
package/src/util/helper.tsx
CHANGED
|
@@ -176,3 +176,8 @@ export const getValueByPath = (obj: { [key: string]: any }, path: string): any =
|
|
|
176
176
|
return res[prop];
|
|
177
177
|
}, obj);
|
|
178
178
|
};
|
|
179
|
+
|
|
180
|
+
/** Source: https://stackoverflow.com/a/42769683/5084110 */
|
|
181
|
+
export const remToPx = (rem: number): number => {
|
|
182
|
+
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
183
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 OneWelcome B.V.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
$form-element-horizontal-padding-mobile: 1rem;
|
|
18
|
+
$form-element-horizontal-padding-desktop: 1.25rem;
|