@hixme-ui/theme
Advanced tools
Comparing version 1.19.2 to 1.20.0
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _GlobalStylesContainer = require('./GlobalStylesContainer'); | ||
var _GlobalStylesContainer2 = _interopRequireDefault(_GlobalStylesContainer); | ||
var _index = require('./index'); | ||
@@ -32,8 +36,14 @@ | ||
var children = _ref.children, | ||
props = (0, _objectWithoutProperties3.default)(_ref, ['children']); | ||
withGlobal = _ref.withGlobal, | ||
props = (0, _objectWithoutProperties3.default)(_ref, ['children', 'withGlobal']); | ||
var output = withGlobal ? _react2.default.createElement( | ||
_GlobalStylesContainer2.default, | ||
null, | ||
children | ||
) : children; | ||
return _react2.default.createElement( | ||
_styledComponents.ThemeProvider, | ||
{ theme: props.theme || _index2.default }, | ||
children | ||
output | ||
); | ||
@@ -44,7 +54,9 @@ } | ||
children: _propTypes2.default.element.isRequired, | ||
theme: _propTypes2.default.object | ||
theme: _propTypes2.default.object, | ||
withGlobal: _propTypes2.default.bool | ||
}; | ||
HUIThemeProvider.defaultProps = { | ||
theme: _index2.default | ||
theme: _index2.default, | ||
withGlobal: false | ||
}; | ||
@@ -51,0 +63,0 @@ |
{ | ||
"name": "@hixme-ui/theme", | ||
"version": "1.19.2", | ||
"version": "1.20.0", | ||
"description": "hixme-ui theme", | ||
@@ -79,2 +79,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"normalize.css": "^8.0.0", | ||
"styled-components": "^2.3.3" | ||
@@ -81,0 +82,0 @@ }, |
@@ -32,1 +32,16 @@ # Theme | ||
``` | ||
### withGlobal prop | ||
The HUI was built with some global settings, including the [normalize CSS](https://necolas.github.io/normalize.css/). These global styles are not set by default and are enabled by adding the `withGlobal` property on the ThemeProvider. | ||
```javascript | ||
const App = ({ children }) => ( | ||
<ThemeProvider withGlobal> | ||
{children} | ||
</ThemeProvider> | ||
) | ||
``` | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { ThemeProvider } from 'styled-components' | ||
import GlobalStylesContainer from './GlobalStylesContainer' | ||
import theme from './index' | ||
export default function HUIThemeProvider({ children, ...props }) { | ||
export default function HUIThemeProvider({ children, withGlobal, ...props }) { | ||
const output = withGlobal ? | ||
(<GlobalStylesContainer> | ||
{children} | ||
</GlobalStylesContainer>) : children | ||
return ( | ||
<ThemeProvider theme={props.theme || theme}> | ||
{children} | ||
{output} | ||
</ThemeProvider> | ||
@@ -17,2 +22,3 @@ ) | ||
theme: PropTypes.object, | ||
withGlobal: PropTypes.bool, | ||
} | ||
@@ -22,2 +28,3 @@ | ||
theme, | ||
withGlobal: false, | ||
} | ||
@@ -24,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46065
12
570
47
4
3
+ Addednormalize.css@^8.0.0
+ Addednormalize.css@8.0.1(transitive)