@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
57 lines (53 loc) • 1.6 kB
JavaScript
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import LibraryContextInit from "./LibraryContextInit";
import { getLibraryConfig } from "./Config";
const LibraryContextProvider = _ref => {
let {
isReducedMotion,
direction,
coloredTagVariant,
hasTagColorInheritedToText,
shouldIndicateSwitchState,
shouldStrikeThroughDisabledButton,
children
} = _ref;
const [value, setValue] = useState({
isReducedMotion,
direction,
coloredTagVariant,
hasTagColorInheritedToText,
shouldIndicateSwitchState,
shouldStrikeThroughDisabledButton
});
function setGlobalContext(key, data) {
if (value[key] != data) {
setValue({ ...value,
[]: data
});
}
}
return /*#__PURE__*/React.createElement(LibraryContextInit.Provider, {
value: { ...value,
setGlobalContext
}
}, children);
};
LibraryContextProvider.propTypes = {
children: PropTypes.node.isRequired,
isReducedMotion: PropTypes.bool,
coloredTagVariant: PropTypes.oneOf(['bold', 'subtle', 'minimal']),
hasTagColorInheritedToText: PropTypes.bool,
direction: PropTypes.string,
shouldIndicateSwitchState: PropTypes.bool,
shouldStrikeThroughDisabledButton: PropTypes.bool
};
LibraryContextProvider.defaultProps = {
isReducedMotion: getLibraryConfig('isReducedMotion'),
direction: getLibraryConfig('direction'),
coloredTagVariant: 'bold',
hasTagColorInheritedToText: true,
shouldIndicateSwitchState: false,
shouldStrikeThroughDisabledButton: false
};
export default LibraryContextProvider;