Skip to content

Commit 71d5a24

Browse files
committed
Merge remote-tracking branch 'origin/master' into error-boundary
2 parents 584ecd4 + 76df5a5 commit 71d5a24

File tree

15 files changed

+167
-8
lines changed

15 files changed

+167
-8
lines changed

config/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
'date-fns',
2121
// we ony use one function from date-fns
2222
'date-fns/distance_in_words_strict',
23+
'deepmerge',
2324
'prop-types',
2425
'react',
2526
'react-dom',

config/styleguide.config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"FloatingButton",
5858
"FloatingButtonGroup",
5959
"GlobalNavigation",
60+
"HideComponent",
6061
"Icon",
6162
"IconSprite",
6263
"Input",
@@ -76,6 +77,7 @@
7677
"name": "Higher Order Components",
7778
"directory": "hocs",
7879
"items": [
80+
"withHideComponent",
7981
"withTimeoutFallback",
8082
"withErrorBoundary",
8183
"withDisabledSSR"

docs/build/1.7c8e4385.js renamed to docs/build/1.768c9348.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build/bundle.b6b93daa.js renamed to docs/build/bundle.8d1f97e4.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-common</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik:400,700"></head><body><div id="rsg-root"></div><div id="app"></div><script src="build/bundle.b6b93daa.js"></script></body></html>
1+
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-common</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik:400,700"></head><body><div id="rsg-root"></div><div id="app"></div><script src="build/bundle.8d1f97e4.js"></script></body></html>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Hide:
2+
```js
3+
<HideComponent hide>Default</HideComponent>
4+
```
5+
6+
Display
7+
```js
8+
<HideComponent>Default</HideComponent>
9+
```
10+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Hide component tree 1`] = `
4+
<HideComponent
5+
hide={true}
6+
/>
7+
`;
8+
9+
exports[`Show component tree 1`] = `
10+
<HideComponent
11+
hide={false}
12+
>
13+
<div>
14+
test
15+
</div>
16+
</HideComponent>
17+
`;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import PropTypes from 'prop-types';
2+
3+
const HideComponent = ({ hide, children }) => {
4+
if (hide === true) {
5+
return false;
6+
}
7+
8+
return children;
9+
};
10+
11+
HideComponent.propTypes = {
12+
hide: PropTypes.bool,
13+
};
14+
15+
HideComponent.defaultProps = {
16+
hide: false,
17+
};
18+
19+
export default HideComponent;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { mount } from 'enzyme';
3+
4+
import HideComponent from './index';
5+
6+
test('Hide component tree', () => {
7+
const component = mount(
8+
<HideComponent hide>
9+
<div> test </div>
10+
</HideComponent>,
11+
);
12+
expect(component).toMatchSnapshot();
13+
});
14+
15+
test('Show component tree', () => {
16+
const component = mount(
17+
<HideComponent>
18+
<div> test </div>
19+
</HideComponent>,
20+
);
21+
expect(component).toMatchSnapshot();
22+
});

source/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export { default as List } from './List';
2929
export { default as Avatar } from './Avatar';
3030
export { default as AvatarStack } from './AvatarStack';
3131
export { default as ExpandableText } from './ExpandableText';
32+
export { default as HideComponent } from './HideComponent';
3233
export { default as Switch } from './Switch';
3334
export { default as Timeago } from './Timeago';
3435
export { default as SimpleLocalNavigation } from './SimpleLocalNavigation';

0 commit comments

Comments
 (0)