@sb1/ffe-cards-react 4.0.7 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/CardBase.js +3 -1
- package/es/IconCard/IconCard.js +3 -1
- package/es/ImageCard/ImageCard.js +3 -1
- package/es/TextCard/TextCard.js +3 -1
- package/es/components/CardName.js +3 -1
- package/es/components/ComponentBase.js +3 -1
- package/es/components/Subtext.js +3 -1
- package/es/components/Text.js +3 -1
- package/es/components/Title.js +3 -1
- package/es/index.js +0 -2
- package/lib/CardBase.js +3 -1
- package/lib/IconCard/IconCard.js +6 -4
- package/lib/ImageCard/ImageCard.js +6 -4
- package/lib/TextCard/TextCard.js +6 -4
- package/lib/components/CardName.js +3 -1
- package/lib/components/ComponentBase.js +3 -1
- package/lib/components/Subtext.js +3 -1
- package/lib/components/Text.js +3 -1
- package/lib/components/Title.js +3 -1
- package/lib/index.js +6 -22
- package/package.json +8 -10
- package/CHANGELOG.md +0 -488
- package/es/CardBase.spec.js +0 -27
- package/es/IconCard/IconCard.spec.js +0 -56
- package/es/ImageCard/ImageCard.spec.js +0 -50
- package/es/LinkCard.js +0 -86
- package/es/LinkCard.spec.js +0 -99
- package/es/ProductCard.js +0 -57
- package/es/ProductCard.spec.js +0 -67
- package/es/TextCard/TextCard.spec.js +0 -33
- package/lib/CardBase.spec.js +0 -34
- package/lib/IconCard/IconCard.spec.js +0 -65
- package/lib/ImageCard/ImageCard.spec.js +0 -59
- package/lib/LinkCard.js +0 -98
- package/lib/LinkCard.spec.js +0 -105
- package/lib/ProductCard.js +0 -69
- package/lib/ProductCard.spec.js +0 -73
- package/lib/TextCard/TextCard.spec.js +0 -41
package/es/LinkCard.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
|
|
5
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
-
|
|
7
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import { bool, func, node, number as numberType, oneOf, oneOfType, string, elementType } from 'prop-types';
|
|
11
|
-
import classNames from 'classnames';
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated This card comes with an outdated design. Use one of the new cards instead.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
var LinkCard = function LinkCard(props) {
|
|
17
|
-
var center = props.center,
|
|
18
|
-
className = props.className,
|
|
19
|
-
details = props.details,
|
|
20
|
-
ElementType = props.elementType,
|
|
21
|
-
heading = props.heading,
|
|
22
|
-
icon = props.icon,
|
|
23
|
-
number = props.number,
|
|
24
|
-
plain = props.plain,
|
|
25
|
-
size = props.size,
|
|
26
|
-
status = props.status,
|
|
27
|
-
subHeading = props.subHeading,
|
|
28
|
-
rest = _objectWithoutProperties(props, ["center", "className", "details", "elementType", "heading", "icon", "number", "plain", "size", "status", "subHeading"]);
|
|
29
|
-
|
|
30
|
-
return /*#__PURE__*/React.createElement(ElementType, _extends({
|
|
31
|
-
className: classNames('ffe-link-card', {
|
|
32
|
-
'ffe-link-card--center': center
|
|
33
|
-
}, _defineProperty({}, "ffe-link-card--".concat(size), !!size), {
|
|
34
|
-
'ffe-link-card--plain': plain
|
|
35
|
-
}, className)
|
|
36
|
-
}, rest), status && /*#__PURE__*/React.createElement("div", {
|
|
37
|
-
className: "ffe-link-card__status"
|
|
38
|
-
}, status), icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
39
|
-
className: classNames('ffe-link-card__icon', icon.props.className)
|
|
40
|
-
}), number && /*#__PURE__*/React.createElement("span", {
|
|
41
|
-
className: "ffe-link-card__number"
|
|
42
|
-
}, number), heading && /*#__PURE__*/React.createElement("p", {
|
|
43
|
-
className: "ffe-link-card__heading"
|
|
44
|
-
}, heading), subHeading && /*#__PURE__*/React.createElement("p", {
|
|
45
|
-
className: "ffe-link-card__sub-heading"
|
|
46
|
-
}, subHeading), details && /*#__PURE__*/React.createElement("p", {
|
|
47
|
-
className: "ffe-link-card__details"
|
|
48
|
-
}, details));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
LinkCard.defaultProps = {
|
|
52
|
-
elementType: 'a'
|
|
53
|
-
};
|
|
54
|
-
LinkCard.propTypes = {
|
|
55
|
-
/** Center the card's content horizontally */
|
|
56
|
-
center: bool,
|
|
57
|
-
className: string,
|
|
58
|
-
|
|
59
|
-
/** Bottom text - should only be used with `size="large"` */
|
|
60
|
-
details: node,
|
|
61
|
-
|
|
62
|
-
/** The element to render the card as. Typically `'a'`, `Link` or `'button'` */
|
|
63
|
-
elementType: oneOfType([func, string, elementType]),
|
|
64
|
-
|
|
65
|
-
/** Text shown at the top */
|
|
66
|
-
heading: string,
|
|
67
|
-
|
|
68
|
-
/** A rendered icon - will be sized appropriately */
|
|
69
|
-
icon: node,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* An enumerating number, typically to show which "step" a card represents. Should be used only when `plain` is true
|
|
73
|
-
*/
|
|
74
|
-
number: numberType,
|
|
75
|
-
|
|
76
|
-
/** Optional size modifiers */
|
|
77
|
-
size: oneOf(['medium', 'large']),
|
|
78
|
-
|
|
79
|
-
/** Make less "clickable" - works well with specifying `number` prop */
|
|
80
|
-
plain: bool,
|
|
81
|
-
|
|
82
|
-
/** Status text displayed at the top of the card with a 1 second delay */
|
|
83
|
-
status: string,
|
|
84
|
-
subHeading: string
|
|
85
|
-
};
|
|
86
|
-
export default LinkCard;
|
package/es/LinkCard.spec.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import LinkCard from './LinkCard';
|
|
4
|
-
|
|
5
|
-
var getWrapper = function getWrapper(props) {
|
|
6
|
-
return shallow( /*#__PURE__*/React.createElement(LinkCard, props));
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe('<LinkCard />', function () {
|
|
10
|
-
it('renders without exploding', function () {
|
|
11
|
-
var wrapper = getWrapper();
|
|
12
|
-
expect(wrapper.length).toBe(1);
|
|
13
|
-
});
|
|
14
|
-
it('renders correct size classes', function () {
|
|
15
|
-
var mediumWrapper = getWrapper({
|
|
16
|
-
size: 'medium'
|
|
17
|
-
});
|
|
18
|
-
expect(mediumWrapper.hasClass('ffe-link-card--medium')).toBe(true);
|
|
19
|
-
var largeWrapper = getWrapper({
|
|
20
|
-
size: 'large'
|
|
21
|
-
});
|
|
22
|
-
expect(largeWrapper.hasClass('ffe-link-card--large')).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
it('renders correct modifier classes', function () {
|
|
25
|
-
var wrapper = getWrapper({
|
|
26
|
-
center: true,
|
|
27
|
-
plain: true
|
|
28
|
-
});
|
|
29
|
-
expect(wrapper.hasClass('ffe-link-card--center')).toBe(true);
|
|
30
|
-
expect(wrapper.hasClass('ffe-link-card--plain')).toBe(true);
|
|
31
|
-
});
|
|
32
|
-
it('renders status if provided', function () {
|
|
33
|
-
var wrapper = getWrapper({
|
|
34
|
-
status: 'Fornyelse'
|
|
35
|
-
});
|
|
36
|
-
expect(wrapper.find('.ffe-link-card__status').length).toBe(1);
|
|
37
|
-
expect(wrapper.find('.ffe-link-card__status').text()).toBe('Fornyelse');
|
|
38
|
-
});
|
|
39
|
-
it('renders icon if provided', function () {
|
|
40
|
-
var wrapper = getWrapper({
|
|
41
|
-
icon: /*#__PURE__*/React.createElement("svg", {
|
|
42
|
-
className: "some-icon"
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
expect(wrapper.find('.ffe-link-card__icon').length).toBe(1);
|
|
46
|
-
expect(wrapper.find('.ffe-link-card__icon').hasClass('some-icon')).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it('renders heading if provided', function () {
|
|
49
|
-
var wrapper = getWrapper({
|
|
50
|
-
heading: 'Heading'
|
|
51
|
-
});
|
|
52
|
-
expect(wrapper.find('.ffe-link-card__heading').length).toBe(1);
|
|
53
|
-
expect(wrapper.find('.ffe-link-card__heading').text()).toBe('Heading');
|
|
54
|
-
});
|
|
55
|
-
it('renders sub-heading if provided', function () {
|
|
56
|
-
var wrapper = getWrapper({
|
|
57
|
-
subHeading: 'Sub-heading'
|
|
58
|
-
});
|
|
59
|
-
expect(wrapper.find('.ffe-link-card__sub-heading').length).toBe(1);
|
|
60
|
-
expect(wrapper.find('.ffe-link-card__sub-heading').text()).toBe('Sub-heading');
|
|
61
|
-
});
|
|
62
|
-
it('renders details if provided', function () {
|
|
63
|
-
var wrapper = getWrapper({
|
|
64
|
-
details: 'Details'
|
|
65
|
-
});
|
|
66
|
-
expect(wrapper.find('.ffe-link-card__details').length).toBe(1);
|
|
67
|
-
expect(wrapper.find('.ffe-link-card__details').text()).toBe('Details');
|
|
68
|
-
});
|
|
69
|
-
it('renders number if provided', function () {
|
|
70
|
-
var wrapper = getWrapper({
|
|
71
|
-
number: 1337
|
|
72
|
-
});
|
|
73
|
-
expect(wrapper.find('.ffe-link-card__number').length).toBe(1);
|
|
74
|
-
expect(wrapper.find('.ffe-link-card__number').text()).toBe('1337');
|
|
75
|
-
});
|
|
76
|
-
it('passes props as expected', function () {
|
|
77
|
-
var wrapper = getWrapper({
|
|
78
|
-
role: 'button',
|
|
79
|
-
className: 'kerfuffle'
|
|
80
|
-
});
|
|
81
|
-
expect(wrapper.find('.ffe-link-card').hasClass('kerfuffle')).toBe(true);
|
|
82
|
-
expect(wrapper.find('.ffe-link-card').prop('role')).toBe('button');
|
|
83
|
-
});
|
|
84
|
-
it('overrides the element if provided', function () {
|
|
85
|
-
var buttonWrapper = getWrapper({
|
|
86
|
-
elementType: 'button'
|
|
87
|
-
});
|
|
88
|
-
expect(buttonWrapper.is('button')).toBe(true);
|
|
89
|
-
|
|
90
|
-
var SampleComponent = function SampleComponent(props) {
|
|
91
|
-
return /*#__PURE__*/React.createElement("a", props);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var componentWrapper = getWrapper({
|
|
95
|
-
elementType: SampleComponent
|
|
96
|
-
});
|
|
97
|
-
expect(componentWrapper.is('SampleComponent')).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
});
|
package/es/ProductCard.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
|
|
5
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { oneOfType, node, func, string, elementType } from 'prop-types';
|
|
9
|
-
import classNames from 'classnames';
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated This card comes with an outdated design. Use one of the new cards instead.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
var ProductCard = function ProductCard(props) {
|
|
15
|
-
var className = props.className,
|
|
16
|
-
details = props.details,
|
|
17
|
-
ElementType = props.elementType,
|
|
18
|
-
heading = props.heading,
|
|
19
|
-
icon = props.icon,
|
|
20
|
-
status = props.status,
|
|
21
|
-
rest = _objectWithoutProperties(props, ["className", "details", "elementType", "heading", "icon", "status"]);
|
|
22
|
-
|
|
23
|
-
return /*#__PURE__*/React.createElement(ElementType, _extends({
|
|
24
|
-
className: classNames('ffe-product-card', className)
|
|
25
|
-
}, rest), status && /*#__PURE__*/React.createElement("div", {
|
|
26
|
-
className: "ffe-product-card__status"
|
|
27
|
-
}, status), icon && /*#__PURE__*/React.cloneElement(icon, {
|
|
28
|
-
className: classNames('ffe-product-card__icon', icon.props.className)
|
|
29
|
-
}), heading && /*#__PURE__*/React.createElement("p", {
|
|
30
|
-
className: "ffe-product-card__heading"
|
|
31
|
-
}, heading), details && /*#__PURE__*/React.createElement("p", {
|
|
32
|
-
className: "ffe-product-card__details"
|
|
33
|
-
}, details));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
ProductCard.defaultProps = {
|
|
37
|
-
elementType: 'div'
|
|
38
|
-
};
|
|
39
|
-
ProductCard.propTypes = {
|
|
40
|
-
className: string,
|
|
41
|
-
|
|
42
|
-
/** Bottom text - should only be used with `size="large"` */
|
|
43
|
-
details: node,
|
|
44
|
-
|
|
45
|
-
/** The element to render the card as. */
|
|
46
|
-
elementType: oneOfType([func, string, elementType]),
|
|
47
|
-
|
|
48
|
-
/** Text shown at the top */
|
|
49
|
-
heading: string,
|
|
50
|
-
|
|
51
|
-
/** A rendered icon - will be sized appropriately */
|
|
52
|
-
icon: node,
|
|
53
|
-
|
|
54
|
-
/** Status text displayed at the top of the card with a 1 second delay */
|
|
55
|
-
status: string
|
|
56
|
-
};
|
|
57
|
-
export default ProductCard;
|
package/es/ProductCard.spec.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import ProductCard from './ProductCard';
|
|
4
|
-
|
|
5
|
-
var getWrapper = function getWrapper(props) {
|
|
6
|
-
return shallow( /*#__PURE__*/React.createElement(ProductCard, props));
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe('<ProductCard />', function () {
|
|
10
|
-
it('renders without exploding', function () {
|
|
11
|
-
var wrapper = getWrapper();
|
|
12
|
-
expect(wrapper.length).toBe(1);
|
|
13
|
-
});
|
|
14
|
-
it('renders status if provided', function () {
|
|
15
|
-
var wrapper = getWrapper({
|
|
16
|
-
status: 'Fornyelse'
|
|
17
|
-
});
|
|
18
|
-
expect(wrapper.find('.ffe-product-card__status').length).toBe(1);
|
|
19
|
-
expect(wrapper.find('.ffe-product-card__status').text()).toBe('Fornyelse');
|
|
20
|
-
});
|
|
21
|
-
it('renders icon if provided', function () {
|
|
22
|
-
var wrapper = getWrapper({
|
|
23
|
-
icon: /*#__PURE__*/React.createElement("svg", {
|
|
24
|
-
className: "some-icon"
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
expect(wrapper.find('.ffe-product-card__icon').length).toBe(1);
|
|
28
|
-
expect(wrapper.find('.ffe-product-card__icon').hasClass('some-icon')).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it('renders heading if provided', function () {
|
|
31
|
-
var wrapper = getWrapper({
|
|
32
|
-
heading: 'Heading'
|
|
33
|
-
});
|
|
34
|
-
expect(wrapper.find('.ffe-product-card__heading').length).toBe(1);
|
|
35
|
-
expect(wrapper.find('.ffe-product-card__heading').text()).toBe('Heading');
|
|
36
|
-
});
|
|
37
|
-
it('renders details if provided', function () {
|
|
38
|
-
var wrapper = getWrapper({
|
|
39
|
-
details: 'Details'
|
|
40
|
-
});
|
|
41
|
-
expect(wrapper.find('.ffe-product-card__details').length).toBe(1);
|
|
42
|
-
expect(wrapper.find('.ffe-product-card__details').text()).toBe('Details');
|
|
43
|
-
});
|
|
44
|
-
it('passes props as expected', function () {
|
|
45
|
-
var wrapper = getWrapper({
|
|
46
|
-
role: 'button',
|
|
47
|
-
className: 'kerfuffle'
|
|
48
|
-
});
|
|
49
|
-
expect(wrapper.find('.ffe-product-card').hasClass('kerfuffle')).toBe(true);
|
|
50
|
-
expect(wrapper.find('.ffe-product-card').prop('role')).toBe('button');
|
|
51
|
-
});
|
|
52
|
-
it('overrides the element if provided', function () {
|
|
53
|
-
var buttonWrapper = getWrapper({
|
|
54
|
-
elementType: 'button'
|
|
55
|
-
});
|
|
56
|
-
expect(buttonWrapper.is('button')).toBe(true);
|
|
57
|
-
|
|
58
|
-
var SampleComponent = function SampleComponent(props) {
|
|
59
|
-
return /*#__PURE__*/React.createElement("a", props);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
var componentWrapper = getWrapper({
|
|
63
|
-
elementType: SampleComponent
|
|
64
|
-
});
|
|
65
|
-
expect(componentWrapper.is('SampleComponent')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import TextCard from './TextCard';
|
|
4
|
-
import { Text } from '../components';
|
|
5
|
-
|
|
6
|
-
var getWrapper = function getWrapper(props) {
|
|
7
|
-
return shallow( /*#__PURE__*/React.createElement(TextCard, props));
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
var children = /*#__PURE__*/React.createElement("div", null, "Hello world");
|
|
11
|
-
describe('TextCard', function () {
|
|
12
|
-
it('should render correct class and children', function () {
|
|
13
|
-
var wrapper = getWrapper({
|
|
14
|
-
children: children
|
|
15
|
-
});
|
|
16
|
-
expect(wrapper.hasClass('ffe-text-card')).toBe(true);
|
|
17
|
-
expect(wrapper.find('.ffe-text-card').children().first().getElement()).toEqual(children);
|
|
18
|
-
});
|
|
19
|
-
it('should render children as a function', function () {
|
|
20
|
-
var wrapper = getWrapper({
|
|
21
|
-
children: function children(Components) {
|
|
22
|
-
return /*#__PURE__*/React.createElement(Components.Text, null, "Hello world");
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
expect(wrapper.find(Text).exists()).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
it('should render my custom class', function () {
|
|
28
|
-
var wrapper = getWrapper({
|
|
29
|
-
className: 'my-custom-class'
|
|
30
|
-
});
|
|
31
|
-
expect(wrapper.hasClass('my-custom-class')).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/lib/CardBase.spec.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
|
|
5
|
-
var _enzyme = require("enzyme");
|
|
6
|
-
|
|
7
|
-
var _CardBase = _interopRequireDefault(require("./CardBase"));
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
var getWrapper = function getWrapper(props) {
|
|
12
|
-
return (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_CardBase.default, props));
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var children = /*#__PURE__*/_react.default.createElement("div", null, "Hello world");
|
|
16
|
-
|
|
17
|
-
describe('CardBase', function () {
|
|
18
|
-
it('should render a div element with correct class and children inside', function () {
|
|
19
|
-
var wrapper = getWrapper({
|
|
20
|
-
children: children
|
|
21
|
-
});
|
|
22
|
-
expect(wrapper.find('div').exists()).toBe(true);
|
|
23
|
-
expect(wrapper.hasClass('ffe-card-base')).toBe(true);
|
|
24
|
-
expect(wrapper.find('.ffe-card-base').children().first().getElement()).toEqual(children);
|
|
25
|
-
});
|
|
26
|
-
it('should render my custom element and custom class', function () {
|
|
27
|
-
var wrapper = getWrapper({
|
|
28
|
-
className: 'my-custom-class',
|
|
29
|
-
element: 'article'
|
|
30
|
-
});
|
|
31
|
-
expect(wrapper.find('article').exists()).toBe(true);
|
|
32
|
-
expect(wrapper.hasClass('my-custom-class')).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
|
|
5
|
-
var _enzyme = require("enzyme");
|
|
6
|
-
|
|
7
|
-
var _IconCard = _interopRequireDefault(require("./IconCard"));
|
|
8
|
-
|
|
9
|
-
var _sparegrisIkon = _interopRequireDefault(require("../../../ffe-icons-react/lib/sparegris-ikon"));
|
|
10
|
-
|
|
11
|
-
var _components = require("../components");
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
|
-
|
|
17
|
-
var getWrapper = function getWrapper(props) {
|
|
18
|
-
return (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_IconCard.default, _extends({
|
|
19
|
-
icon: /*#__PURE__*/_react.default.createElement(_sparegrisIkon.default, null)
|
|
20
|
-
}, props)));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
var children = /*#__PURE__*/_react.default.createElement("div", null, "Hello world");
|
|
24
|
-
|
|
25
|
-
describe('IconCard', function () {
|
|
26
|
-
it('should render correct class and contain a div with body class', function () {
|
|
27
|
-
var wrapper = getWrapper({
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
30
|
-
expect(wrapper.hasClass('ffe-icon-card')).toBe(true);
|
|
31
|
-
expect(wrapper.find('.ffe-icon-card__body').exists()).toBe(true);
|
|
32
|
-
expect(wrapper.find('.ffe-icon-card__body').children().first().getElement()).toEqual(children);
|
|
33
|
-
});
|
|
34
|
-
it('should render icon, with an added class', function () {
|
|
35
|
-
var wrapper = getWrapper({
|
|
36
|
-
icon: /*#__PURE__*/_react.default.createElement(_sparegrisIkon.default, {
|
|
37
|
-
className: "my-custom-class"
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
expect(wrapper.find(_sparegrisIkon.default).hasClass('ffe-icon-card__icon')).toBe(true);
|
|
41
|
-
expect(wrapper.find(_sparegrisIkon.default).hasClass('my-custom-class')).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
it('should add modifying classes when modifiers are given', function () {
|
|
44
|
-
var wrapper = getWrapper({
|
|
45
|
-
condensed: true,
|
|
46
|
-
greyCharcoal: true
|
|
47
|
-
});
|
|
48
|
-
expect(wrapper.hasClass('ffe-icon-card--condensed')).toBe(true);
|
|
49
|
-
expect(wrapper.hasClass('ffe-icon-card--grey-charcoal')).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it('should render children as a function', function () {
|
|
52
|
-
var wrapper = getWrapper({
|
|
53
|
-
children: function children(Components) {
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement(Components.Text, null, "Hello world");
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
expect(wrapper.find(_components.Text).exists()).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
it('should render my custom class', function () {
|
|
60
|
-
var wrapper = getWrapper({
|
|
61
|
-
className: 'my-custom-class'
|
|
62
|
-
});
|
|
63
|
-
expect(wrapper.hasClass('my-custom-class')).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
|
|
5
|
-
var _enzyme = require("enzyme");
|
|
6
|
-
|
|
7
|
-
var _ImageCard = _interopRequireDefault(require("./ImageCard"));
|
|
8
|
-
|
|
9
|
-
var _components = require("../components");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
14
|
-
|
|
15
|
-
var image = /*#__PURE__*/_react.default.createElement("img", {
|
|
16
|
-
alt: ""
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var getWrapper = function getWrapper(props) {
|
|
20
|
-
return (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_ImageCard.default, _extends({}, props, {
|
|
21
|
-
image: image
|
|
22
|
-
})));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var children = /*#__PURE__*/_react.default.createElement("div", null, "Hello world");
|
|
26
|
-
|
|
27
|
-
describe('ImageCard', function () {
|
|
28
|
-
it('should render correct class and contain a div with image class', function () {
|
|
29
|
-
var wrapper = getWrapper();
|
|
30
|
-
expect(wrapper.hasClass('ffe-image-card')).toBe(true);
|
|
31
|
-
expect(wrapper.find('div.ffe-image-card__image').exists()).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
it('should render image and overlay alongside each other', function () {
|
|
34
|
-
var wrapper = getWrapper();
|
|
35
|
-
var imageEl = wrapper.find('.ffe-image-card__image');
|
|
36
|
-
expect(imageEl.children().first().hasClass('ffe-image-card__image__overlay')).toBe(true);
|
|
37
|
-
expect(imageEl.children().last().getElement()).toEqual(image);
|
|
38
|
-
});
|
|
39
|
-
it('should render children inside a div with body class', function () {
|
|
40
|
-
var wrapper = getWrapper({
|
|
41
|
-
children: children
|
|
42
|
-
});
|
|
43
|
-
expect(wrapper.find('.ffe-image-card__body').children().first().getElement()).toEqual(children);
|
|
44
|
-
});
|
|
45
|
-
it('should render children as a function', function () {
|
|
46
|
-
var wrapper = getWrapper({
|
|
47
|
-
children: function children(Components) {
|
|
48
|
-
return /*#__PURE__*/_react.default.createElement(Components.Text, null, "Hello world");
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
expect(wrapper.find(_components.Text).exists()).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
it('should render my custom class', function () {
|
|
54
|
-
var wrapper = getWrapper({
|
|
55
|
-
className: 'my-custom-class'
|
|
56
|
-
});
|
|
57
|
-
expect(wrapper.hasClass('my-custom-class')).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
});
|
package/lib/LinkCard.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = require("prop-types");
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
-
|
|
18
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
-
|
|
22
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated This card comes with an outdated design. Use one of the new cards instead.
|
|
26
|
-
*/
|
|
27
|
-
var LinkCard = function LinkCard(props) {
|
|
28
|
-
var center = props.center,
|
|
29
|
-
className = props.className,
|
|
30
|
-
details = props.details,
|
|
31
|
-
ElementType = props.elementType,
|
|
32
|
-
heading = props.heading,
|
|
33
|
-
icon = props.icon,
|
|
34
|
-
number = props.number,
|
|
35
|
-
plain = props.plain,
|
|
36
|
-
size = props.size,
|
|
37
|
-
status = props.status,
|
|
38
|
-
subHeading = props.subHeading,
|
|
39
|
-
rest = _objectWithoutProperties(props, ["center", "className", "details", "elementType", "heading", "icon", "number", "plain", "size", "status", "subHeading"]);
|
|
40
|
-
|
|
41
|
-
return /*#__PURE__*/_react.default.createElement(ElementType, _extends({
|
|
42
|
-
className: (0, _classnames.default)('ffe-link-card', {
|
|
43
|
-
'ffe-link-card--center': center
|
|
44
|
-
}, _defineProperty({}, "ffe-link-card--".concat(size), !!size), {
|
|
45
|
-
'ffe-link-card--plain': plain
|
|
46
|
-
}, className)
|
|
47
|
-
}, rest), status && /*#__PURE__*/_react.default.createElement("div", {
|
|
48
|
-
className: "ffe-link-card__status"
|
|
49
|
-
}, status), icon && /*#__PURE__*/_react.default.cloneElement(icon, {
|
|
50
|
-
className: (0, _classnames.default)('ffe-link-card__icon', icon.props.className)
|
|
51
|
-
}), number && /*#__PURE__*/_react.default.createElement("span", {
|
|
52
|
-
className: "ffe-link-card__number"
|
|
53
|
-
}, number), heading && /*#__PURE__*/_react.default.createElement("p", {
|
|
54
|
-
className: "ffe-link-card__heading"
|
|
55
|
-
}, heading), subHeading && /*#__PURE__*/_react.default.createElement("p", {
|
|
56
|
-
className: "ffe-link-card__sub-heading"
|
|
57
|
-
}, subHeading), details && /*#__PURE__*/_react.default.createElement("p", {
|
|
58
|
-
className: "ffe-link-card__details"
|
|
59
|
-
}, details));
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
LinkCard.defaultProps = {
|
|
63
|
-
elementType: 'a'
|
|
64
|
-
};
|
|
65
|
-
LinkCard.propTypes = {
|
|
66
|
-
/** Center the card's content horizontally */
|
|
67
|
-
center: _propTypes.bool,
|
|
68
|
-
className: _propTypes.string,
|
|
69
|
-
|
|
70
|
-
/** Bottom text - should only be used with `size="large"` */
|
|
71
|
-
details: _propTypes.node,
|
|
72
|
-
|
|
73
|
-
/** The element to render the card as. Typically `'a'`, `Link` or `'button'` */
|
|
74
|
-
elementType: (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.string, _propTypes.elementType]),
|
|
75
|
-
|
|
76
|
-
/** Text shown at the top */
|
|
77
|
-
heading: _propTypes.string,
|
|
78
|
-
|
|
79
|
-
/** A rendered icon - will be sized appropriately */
|
|
80
|
-
icon: _propTypes.node,
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* An enumerating number, typically to show which "step" a card represents. Should be used only when `plain` is true
|
|
84
|
-
*/
|
|
85
|
-
number: _propTypes.number,
|
|
86
|
-
|
|
87
|
-
/** Optional size modifiers */
|
|
88
|
-
size: (0, _propTypes.oneOf)(['medium', 'large']),
|
|
89
|
-
|
|
90
|
-
/** Make less "clickable" - works well with specifying `number` prop */
|
|
91
|
-
plain: _propTypes.bool,
|
|
92
|
-
|
|
93
|
-
/** Status text displayed at the top of the card with a 1 second delay */
|
|
94
|
-
status: _propTypes.string,
|
|
95
|
-
subHeading: _propTypes.string
|
|
96
|
-
};
|
|
97
|
-
var _default = LinkCard;
|
|
98
|
-
exports.default = _default;
|