Skip to content

Commit f95b50f

Browse files
authored
feat: add ability to share html-reporter components with its plugins (#407)
1 parent 89a216b commit f95b50f

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,48 @@ directory.
270270
```
271271

272272
In the example you can also see another convenient properties:
273+
- `pluginName` - plugin name;
273274
- `actions` - the html-reporter **Redux** actions;
274275
- `selectors` - the memoized html-reporter selectors which created using **reselect** library
275276
- `pluginConfig` - plugin configuration.
276277

278+
Available dependencies:
279+
- `react`
280+
- `redux`
281+
- `react-redux`
282+
- `lodash`
283+
- `prop-types`
284+
- `classnames`
285+
- `semantic-ui-react`
286+
- `react-markdown`
287+
- `reduce-reducers`
288+
- `immer`
289+
- `reselect`
290+
- `axios`
291+
292+
Available components:
293+
- `components`
294+
- `<Details />` - component which allows users to toggle the display of content.
295+
Example of usage:
296+
```js
297+
// ... inside your react component
298+
render() {
299+
return <Details
300+
title='Some title'
301+
content='Some content' // content that will appear when you click on the title
302+
extendClassNames='some_class_name' // ability to add own css-classes to component
303+
onClick={() => console.log('clicked')} // ability to add handler
304+
/>
305+
}
306+
```
307+
308+
, where:
309+
310+
* **title** (required) `String|JSX.Element` - title that describes information hidden underneath.
311+
* **content** (required) `Function|String|Array<String>|JSX.Element` - content that will appear after click on the title.
312+
* **extendClassNames** (optional) `String|Array<String>` - ability to add own css classes to the component.
313+
* **onClick** (optional) `Function` - handler that will be called when the title is clicked.
314+
277315
#### Extension points
278316

279317
Extension points - places within the report UI that are available to extend with React components with the help of [html-reporter plugins](#html-reporter-plugins).

lib/static/modules/load-plugin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import immer from 'immer';
1111
import * as reselect from 'reselect';
1212
import axios from 'axios';
1313
import * as selectors from './selectors';
14+
import Details from '../components/details';
1415

1516
const whitelistedDeps = {
1617
'react': React,
@@ -24,7 +25,10 @@ const whitelistedDeps = {
2425
'reduce-reducers': reduceReducers,
2526
'immer': immer,
2627
'reselect': reselect,
27-
'axios': axios
28+
'axios': axios,
29+
'components': {
30+
Details
31+
}
2832
};
2933

3034
// It's expected that in the plugin code there is a

0 commit comments

Comments
 (0)