@hig/rich-text
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -8,3 +8,3 @@ import React, { Component } from 'react'; | ||
function stylesheet(themeData) { | ||
function stylesheet(props, themeData) { | ||
function typographyStyle(variant, margin) { | ||
@@ -23,2 +23,5 @@ return { | ||
var customStylesheet = props.stylesheet; | ||
var baseStyles = typographyStyle("body", "0 0 " + themeData["density.spacings.small"] + " 0"); | ||
@@ -76,5 +79,7 @@ | ||
return { | ||
var styles = { | ||
richText: _extends({}, baseStyles, listStyles, headerStyles, anchorStyles, paragraphStyles, boldStyles) | ||
}; | ||
return customStylesheet ? customStylesheet(styles, props, themeData) : styles; | ||
} | ||
@@ -119,3 +124,3 @@ | ||
var styles = stylesheet(resolvedRoles); | ||
var styles = stylesheet(_this2.props, resolvedRoles); | ||
return children ? React.createElement( | ||
@@ -147,3 +152,7 @@ "div", | ||
__html: PropTypes.string | ||
}) | ||
}), | ||
/** | ||
* Adds custom/overriding styles | ||
*/ | ||
stylesheet: PropTypes.func | ||
}; | ||
@@ -173,2 +182,9 @@ RichText.__docgenInfo = { | ||
"description": "HTML string to be rendered and styled with HIG typography rules" | ||
}, | ||
"stylesheet": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Adds custom/overriding styles" | ||
} | ||
@@ -175,0 +191,0 @@ } |
@@ -15,3 +15,3 @@ 'use strict'; | ||
function stylesheet(themeData) { | ||
function stylesheet(props, themeData) { | ||
function typographyStyle(variant, margin) { | ||
@@ -30,2 +30,5 @@ return { | ||
var customStylesheet = props.stylesheet; | ||
var baseStyles = typographyStyle("body", "0 0 " + themeData["density.spacings.small"] + " 0"); | ||
@@ -83,5 +86,7 @@ | ||
return { | ||
var styles = { | ||
richText: _extends({}, baseStyles, listStyles, headerStyles, anchorStyles, paragraphStyles, boldStyles) | ||
}; | ||
return customStylesheet ? customStylesheet(styles, props, themeData) : styles; | ||
} | ||
@@ -126,3 +131,3 @@ | ||
var styles = stylesheet(resolvedRoles); | ||
var styles = stylesheet(_this2.props, resolvedRoles); | ||
return children ? React__default.createElement( | ||
@@ -154,3 +159,7 @@ "div", | ||
__html: PropTypes.string | ||
}) | ||
}), | ||
/** | ||
* Adds custom/overriding styles | ||
*/ | ||
stylesheet: PropTypes.func | ||
}; | ||
@@ -180,2 +189,9 @@ RichText.__docgenInfo = { | ||
"description": "HTML string to be rendered and styled with HIG typography rules" | ||
}, | ||
"stylesheet": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Adds custom/overriding styles" | ||
} | ||
@@ -182,0 +198,0 @@ } |
@@ -0,1 +1,8 @@ | ||
# [@hig/rich-text-v1.2.0](https://github.com/Autodesk/hig/compare/@hig/rich-text@1.1.1...@hig/rich-text@1.2.0) (2021-02-24) | ||
### Features | ||
* add stylesheet prop ([891ba75](https://github.com/Autodesk/hig/commit/891ba75)) | ||
# [@hig/rich-text-v1.1.1](https://github.com/Autodesk/hig/compare/@hig/rich-text@1.1.0...@hig/rich-text@1.1.1) (2020-05-12) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/rich-text", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "HIG RichText", | ||
@@ -34,4 +34,4 @@ "author": "Autodesk Inc.", | ||
"peerDependencies": { | ||
"@hig/theme-context": "^3.0.0", | ||
"@hig/theme-data": "^2.16.0", | ||
"@hig/theme-context": "^3.0.1", | ||
"@hig/theme-data": "^2.19.3", | ||
"react": "^15.4.1 || ^16.3.2" | ||
@@ -38,0 +38,0 @@ }, |
@@ -32,1 +32,22 @@ # Rich Text | ||
Use the `className` prop to pass in a css class name to the outermost container of the component. The class name will also pass down to most of the other styled elements within the component. | ||
RichText also has a `stylesheet` prop that accepts a function wherein you can modify its styles. For instance | ||
```jsx | ||
import RichText from '@hig/rich-text'; | ||
function YourComponent() { | ||
// ... | ||
const customStylesheet = (styles, props, themeData) => ({ | ||
...styles, | ||
richText: { | ||
...styles.richText, | ||
color: themeData["colorScheme.status.error"] | ||
} | ||
}); | ||
return ( | ||
<RichText stylesheet={customStylesheet} /> | ||
); | ||
} | ||
``` |
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
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
19900
322
53