Skip to content

Commit ca1c36a

Browse files
committed
Split RUIProvider into two
This commit splits `RUIProvider` into `TranslationsProvider` and `GlobalPropsProvider`. The reasons fo this change are: * Improve performance by reducing rerenders in cases when the context value change dynamically. * Make code more readable by splitting isolated functionality into isolated prividers.
1 parent 684d5ab commit ca1c36a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+334
-301
lines changed

src/components/Alert/Alert.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React, { useContext } from 'react';
3-
import {
4-
RUIContext,
5-
withGlobalProps,
6-
} from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
4+
import { TranslationsContext } from '../../providers/translations';
75
import { classNames } from '../../utils/classNames';
86
import { transferProps } from '../../utils/transferProps';
97
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
@@ -17,7 +15,7 @@ export const Alert = ({
1715
onClose,
1816
...restProps
1917
}) => {
20-
const { translations } = useContext(RUIContext);
18+
const translations = useContext(TranslationsContext);
2119

2220
return (
2321
<div

src/components/Alert/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Dark alert variant.
132132
```docoff-react-preview
133133
<Alert color="dark">
134134
<strong>Dark alert:</strong> Stands out on light backgrounds.
135+
{' '}
135136
<TextLink href="/" label="This is a link" />
136137
</Alert>
137138
```

src/components/Badge/Badge.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';

src/components/Button/Button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { useContext } from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';

src/components/ButtonGroup/ButtonGroup.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
22
import React, {
33
useMemo,
44
} from 'react';
5-
import { withGlobalProps } from '../../provider';
5+
import { withGlobalProps } from '../../providers/globalProps';
66
import { classNames } from '../../utils/classNames';
77
import { transferProps } from '../../utils/transferProps';
88
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';

src/components/Card/Card.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';

src/components/Card/CardBody.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { transferProps } from '../../utils/transferProps';
55
import styles from './Card.module.scss';
66

src/components/Card/CardFooter.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { withGlobalProps } from '../../provider';
43
import { transferProps } from '../../utils/transferProps';
4+
import { withGlobalProps } from '../../providers/globalProps';
55
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
66
import styles from './Card.module.scss';
77

src/components/CheckboxField/CheckboxField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { useContext } from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';

src/components/FileInputField/FileInputField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { useContext } from 'react';
3-
import { withGlobalProps } from '../../provider';
3+
import { withGlobalProps } from '../../providers/globalProps';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';

0 commit comments

Comments
 (0)