wix-style-react
Version:
171 lines (168 loc) • 5.18 kB
JavaScript
import React from 'react';
import { storiesOf } from '@storybook/react';
import WixStyleReactProvider from '../WixStyleReactProvider';
import Card from '.';
import Button from '../Button';
import CloseButton from '../CloseButton';
import Text from '../Text';
import EmptyState from '../EmptyState';
import { Layout, Cell } from '../Layout';
var reduceSpacingTests = [{
describe: 'content size',
its: [{
it: 'none',
props: {
contentSize: undefined
}
}, {
it: 'medium',
props: {
contentSize: 'medium'
}
}, {
it: 'large',
props: {
contentSize: 'large'
}
}]
}];
var tests = [{
describe: 'subtitle',
its: [{
it: 'ellipsis with suffix',
props: {
suffix: /*#__PURE__*/React.createElement(Button, {
onClick: function onClick() {
return alert('Clicked');
},
size: "small"
}, "Click"),
subtitle: /*#__PURE__*/React.createElement(Text, {
ellipsis: true
}, ' ', "1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with")
}
}, {
it: 'ellipsis without suffix',
props: {
subtitle: /*#__PURE__*/React.createElement(Text, {
ellipsis: true
}, ' ', "1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with")
}
}, {
it: 'short',
props: {
suffix: /*#__PURE__*/React.createElement(Button, {
onClick: function onClick() {
return alert('Clicked');
},
size: "small",
theme: "fullblue"
}, "Click"),
subtitle: /*#__PURE__*/React.createElement(Text, null, "I am short subtitle")
}
}]
}, {
describe: 'controls',
its: [{
it: 'close button',
props: {
controls: /*#__PURE__*/React.createElement(CloseButton, null)
}
}, {
it: 'none',
props: {
controls: undefined
}
}]
}, {
describe: 'card style',
its: [{
it: 'hideOverflow',
props: {
hideOverflow: true
}
}, {
it: 'stretchVertically',
props: {
stretchVertically: true
}
}, {
it: 'showShadow',
props: {
showShadow: true
}
}]
}].concat(reduceSpacingTests, [{
describe: 'content empty state',
its: [{
it: 'with empty state',
props: {
childrenContent: /*#__PURE__*/React.createElement(EmptyState, {
title: "You don't have any items yet",
subtitle: "Create your product item in an easy & fast way to display it on your site",
theme: "section"
})
}
}, {
it: 'without empty state',
props: {
childrenContent: 'hello'
}
}]
}]);
var CardTest = function CardTest(props) {
return /*#__PURE__*/React.createElement("div", {
style: {
background: '#F0F4F7',
padding: 30
}
}, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Cell, {
span: 6
}, /*#__PURE__*/React.createElement(Card, {
controls: props.controls,
hideOverflow: props.hideOverflow,
stretchVertically: props.stretchVertically,
showShadow: props.showShadow
}, /*#__PURE__*/React.createElement(Card.Header, {
title: "Card header",
subtitle: props.subtitle,
suffix: props.suffix
}), /*#__PURE__*/React.createElement(Card.Divider, null), /*#__PURE__*/React.createElement(Card.Content, {
size: props.contentSize
}, props.childrenContent ? props.childrenContent : 'sdf')))));
};
export var runTests = function runTests() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
testWithTheme: function testWithTheme(i) {
return i;
}
},
themeName = _ref.themeName,
testWithTheme = _ref.testWithTheme;
tests.forEach(function (_ref2) {
var describe = _ref2.describe,
its = _ref2.its;
its.forEach(function (_ref3) {
var it = _ref3.it,
props = _ref3.props;
storiesOf("".concat(themeName ? "".concat(themeName, "|") : '', "Card").concat(describe ? '/' + describe : ''), module).add(it, function () {
return testWithTheme( /*#__PURE__*/React.createElement(CardTest, props));
});
});
});
};
reduceSpacingTests.forEach(function (_ref4) {
var describe = _ref4.describe,
its = _ref4.its;
its.forEach(function (_ref5) {
var it = _ref5.it,
props = _ref5.props;
storiesOf("Layout And Spacing| Card/".concat(describe), module).add(it, function () {
return /*#__PURE__*/React.createElement(WixStyleReactProvider, {
features: {
reducedSpacingAndImprovedLayout: true
}
}, /*#__PURE__*/React.createElement(CardTest, props));
});
});
});