@gympass/yoga 7.82.1 → 7.83.1

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.
@@ -34,35 +34,46 @@ var List = _styledComponents["default"].ul(_templateObject2 || (_templateObject2
34
34
 
35
35
  exports.List = List;
36
36
 
37
- var IconWrapper = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n display: flex;\n margin-right: ", "px;\n"])), cardweb.plan.list.item.icon.margin.right);
37
+ var IconWrapper = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-right: ", "px;\n min-height: ", "px;\n"])), cardweb.plan.list.item.icon.margin.right, function (props) {
38
+ return props.theme.yoga.spacing.medium;
39
+ });
38
40
 
39
41
  var Item = _styledComponents["default"].li(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n :not(:last-child) {\n margin-bottom: ", "px;\n }\n"])), card.plan.list.item.margin.bottom);
40
42
 
41
- var Wrapper = (0, _styledComponents["default"])(_Box["default"])(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n display: flex;\n min-width: 0;\n align-items: center;\n\n ", "\n\n svg {\n flex-shrink: 0;\n }\n"])), function (props) {
42
- return props.as === 'button' && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n border: none;\n padding: 0;\n background: transparent;\n cursor: pointer;\n "])));
43
+ var Wrapper = (0, _styledComponents["default"])(_Box["default"])(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n width: 100%;\n\n ", "\n\n svg {\n flex-shrink: 0;\n }\n"])), function (props) {
44
+ return props.as === 'button' && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n border: none;\n padding: 0;\n background: transparent;\n cursor: pointer;\n text-align: start;\n "])));
45
+ });
46
+ var ItemText = (0, _styledComponents["default"])(_Text["default"].Small)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n\n color: ", ";\n\n ", "\n"])), card.plan.list.item.font.color, function (props) {
47
+ return props.truncate && truncateStyle;
43
48
  });
44
- var ItemText = (0, _styledComponents["default"])(_Text["default"].Small)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n\n color: ", ";\n\n ", "\n"])), card.plan.list.item.font.color, truncateStyle);
45
49
 
46
50
  var Button = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n display: block;\n padding: 0;\n margin-top: ", "px;\n\n width: 100%;\n\n letter-spacing: normal;\n\n background-color: transparent;\n border: none;\n\n font-family: ", ";\n font-size: ", "px;\n font-weight: ", ";\n color: ", ";\n\n cursor: pointer;\n text-decoration: none;\n text-align: left;\n outline: none;\n\n ", "\n"])), card.plan.list.button.margin.top, _themeReader["default"].baseFont.family, card.plan.list.button.font.size, card.plan.list.button.font.weight, card.plan.list.button.font.color, truncateStyle);
47
51
 
48
- var ListItem = (0, _styledComponents.withTheme)(function (_ref) {
49
- var text = _ref.text,
50
- Icon = _ref.icon,
51
- buttonProps = _ref.buttonProps,
52
- yogaTheme = _ref.theme,
53
- onClick = _ref.onClick;
52
+ var ListItem = (0, _styledComponents.withTheme)(function (props) {
53
+ var text = props.text,
54
+ truncate = props.truncate,
55
+ Icon = props.icon,
56
+ buttonProps = props.buttonProps,
57
+ yogaTheme = props.theme,
58
+ children = props.children,
59
+ onClick = props.onClick;
54
60
  var wrapperProps = onClick ? {
55
61
  as: 'button',
56
62
  type: 'button',
57
63
  onClick: onClick
58
64
  } : {};
59
- return /*#__PURE__*/_react["default"].createElement(Item, null, /*#__PURE__*/_react["default"].createElement(Wrapper, wrapperProps, Icon && /*#__PURE__*/_react["default"].createElement(IconWrapper, null, /*#__PURE__*/(0, _react.isValidElement)(Icon) ? Icon : /*#__PURE__*/_react["default"].createElement(Icon, {
65
+ return /*#__PURE__*/_react["default"].createElement(Item, null, /*#__PURE__*/_react["default"].createElement(Wrapper, wrapperProps, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
66
+ display: "flex",
67
+ alignItems: "flex-start",
68
+ width: "100%"
69
+ }, Icon && /*#__PURE__*/_react["default"].createElement(IconWrapper, null, /*#__PURE__*/(0, _react.isValidElement)(Icon) ? Icon : /*#__PURE__*/_react["default"].createElement(Icon, {
60
70
  width: 16,
61
71
  height: 16,
62
72
  fill: yogaTheme.yoga.colors.text.primary
63
73
  })), /*#__PURE__*/_react["default"].createElement(ItemText, {
64
- as: "span"
65
- }, text)), Boolean(Object.keys(buttonProps).length) && /*#__PURE__*/_react["default"].createElement(Button, buttonProps));
74
+ as: "span",
75
+ truncate: truncate
76
+ }, text)), children), Boolean(Object.keys(buttonProps).length) && /*#__PURE__*/_react["default"].createElement(Button, buttonProps));
66
77
  });
67
78
  exports.ListItem = ListItem;
68
79
  List.displayName = 'PlanCard.List';
@@ -79,10 +90,14 @@ ListItem.propTypes = {
79
90
  buttonProps: (0, _propTypes.shape)({}),
80
91
 
81
92
  /** if provided makes the item clickable */
82
- onClick: _propTypes.func
93
+ onClick: _propTypes.func,
94
+ children: _propTypes.node,
95
+ truncate: _propTypes.bool
83
96
  };
84
97
  ListItem.defaultProps = {
98
+ truncate: true,
85
99
  icon: undefined,
86
100
  buttonProps: {},
87
- onClick: undefined
101
+ onClick: undefined,
102
+ children: undefined
88
103
  };
@@ -4,7 +4,7 @@ function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.s
4
4
 
5
5
  import React, { isValidElement } from 'react';
6
6
  import styled, { css, withTheme } from 'styled-components';
7
- import { string, node, shape, oneOfType, func } from 'prop-types';
7
+ import { string, node, shape, oneOfType, func, bool } from 'prop-types';
8
8
  import Text from '../../../Text';
9
9
  import theme from '../../../Theme/helpers/themeReader';
10
10
  import Box from '../../../Box';
@@ -13,31 +13,42 @@ var _theme$components = theme.components,
13
13
  cardweb = _theme$components.cardweb;
14
14
  var truncateStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])));
15
15
  var List = styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n margin: ", "px 0 0;\n padding: 0;\n\n list-style: none;\n"])), cardweb.plan.list.margin.top);
16
- var IconWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n display: flex;\n margin-right: ", "px;\n"])), cardweb.plan.list.item.icon.margin.right);
16
+ var IconWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n margin-right: ", "px;\n min-height: ", "px;\n"])), cardweb.plan.list.item.icon.margin.right, function (props) {
17
+ return props.theme.yoga.spacing.medium;
18
+ });
17
19
  var Item = styled.li(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n :not(:last-child) {\n margin-bottom: ", "px;\n }\n"])), card.plan.list.item.margin.bottom);
18
- var Wrapper = styled(Box)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n display: flex;\n min-width: 0;\n align-items: center;\n\n ", "\n\n svg {\n flex-shrink: 0;\n }\n"])), function (props) {
19
- return props.as === 'button' && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n border: none;\n padding: 0;\n background: transparent;\n cursor: pointer;\n "])));
20
+ var Wrapper = styled(Box)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n width: 100%;\n\n ", "\n\n svg {\n flex-shrink: 0;\n }\n"])), function (props) {
21
+ return props.as === 'button' && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n border: none;\n padding: 0;\n background: transparent;\n cursor: pointer;\n text-align: start;\n "])));
22
+ });
23
+ var ItemText = styled(Text.Small)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n\n color: ", ";\n\n ", "\n"])), card.plan.list.item.font.color, function (props) {
24
+ return props.truncate && truncateStyle;
20
25
  });
21
- var ItemText = styled(Text.Small)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n display: inline-block;\n height: 100%;\n vertical-align: middle;\n\n color: ", ";\n\n ", "\n"])), card.plan.list.item.font.color, truncateStyle);
22
26
  var Button = styled.button(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n display: block;\n padding: 0;\n margin-top: ", "px;\n\n width: 100%;\n\n letter-spacing: normal;\n\n background-color: transparent;\n border: none;\n\n font-family: ", ";\n font-size: ", "px;\n font-weight: ", ";\n color: ", ";\n\n cursor: pointer;\n text-decoration: none;\n text-align: left;\n outline: none;\n\n ", "\n"])), card.plan.list.button.margin.top, theme.baseFont.family, card.plan.list.button.font.size, card.plan.list.button.font.weight, card.plan.list.button.font.color, truncateStyle);
23
- var ListItem = withTheme(function (_ref) {
24
- var text = _ref.text,
25
- Icon = _ref.icon,
26
- buttonProps = _ref.buttonProps,
27
- yogaTheme = _ref.theme,
28
- onClick = _ref.onClick;
27
+ var ListItem = withTheme(function (props) {
28
+ var text = props.text,
29
+ truncate = props.truncate,
30
+ Icon = props.icon,
31
+ buttonProps = props.buttonProps,
32
+ yogaTheme = props.theme,
33
+ children = props.children,
34
+ onClick = props.onClick;
29
35
  var wrapperProps = onClick ? {
30
36
  as: 'button',
31
37
  type: 'button',
32
38
  onClick: onClick
33
39
  } : {};
34
- return /*#__PURE__*/React.createElement(Item, null, /*#__PURE__*/React.createElement(Wrapper, wrapperProps, Icon && /*#__PURE__*/React.createElement(IconWrapper, null, /*#__PURE__*/isValidElement(Icon) ? Icon : /*#__PURE__*/React.createElement(Icon, {
40
+ return /*#__PURE__*/React.createElement(Item, null, /*#__PURE__*/React.createElement(Wrapper, wrapperProps, /*#__PURE__*/React.createElement(Box, {
41
+ display: "flex",
42
+ alignItems: "flex-start",
43
+ width: "100%"
44
+ }, Icon && /*#__PURE__*/React.createElement(IconWrapper, null, /*#__PURE__*/isValidElement(Icon) ? Icon : /*#__PURE__*/React.createElement(Icon, {
35
45
  width: 16,
36
46
  height: 16,
37
47
  fill: yogaTheme.yoga.colors.text.primary
38
48
  })), /*#__PURE__*/React.createElement(ItemText, {
39
- as: "span"
40
- }, text)), Boolean(Object.keys(buttonProps).length) && /*#__PURE__*/React.createElement(Button, buttonProps));
49
+ as: "span",
50
+ truncate: truncate
51
+ }, text)), children), Boolean(Object.keys(buttonProps).length) && /*#__PURE__*/React.createElement(Button, buttonProps));
41
52
  });
42
53
  List.displayName = 'PlanCard.List';
43
54
  ListItem.displayName = 'PlanCard.ListItem';
@@ -53,11 +64,15 @@ ListItem.propTypes = {
53
64
  buttonProps: shape({}),
54
65
 
55
66
  /** if provided makes the item clickable */
56
- onClick: func
67
+ onClick: func,
68
+ children: node,
69
+ truncate: bool
57
70
  };
58
71
  ListItem.defaultProps = {
72
+ truncate: true,
59
73
  icon: undefined,
60
74
  buttonProps: {},
61
- onClick: undefined
75
+ onClick: undefined,
76
+ children: undefined
62
77
  };
63
78
  export { List, ListItem };
@@ -0,0 +1,32 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
+ import React from 'react';
4
+ import { render, screen } from '@testing-library/react';
5
+ import ThemeProvider from '../../../Theme';
6
+ import { ListItem } from './List';
7
+ var text = '2.900 gyms and studios';
8
+
9
+ function setup(props) {
10
+ render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(ListItem, _extends({
11
+ text: text
12
+ }, props))));
13
+ }
14
+
15
+ describe('<ListItem />', function () {
16
+ it('should display text truncated', function () {
17
+ setup();
18
+ expect(screen.getByText(text)).toMatchSnapshot();
19
+ });
20
+ it('should not display text truncated when truncate prop is false', function () {
21
+ setup({
22
+ truncate: false
23
+ });
24
+ expect(screen.getByText(text)).toMatchSnapshot();
25
+ });
26
+ it('should display children element', function () {
27
+ setup({
28
+ children: /*#__PURE__*/React.createElement("ul", null)
29
+ });
30
+ expect(screen.getByRole('list')).toBeInTheDocument();
31
+ });
32
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.82.1",
3
+ "version": "7.83.1",
4
4
  "description": "Gympass component library",
5
5
  "main": "./cjs",
6
6
  "sideEffects": false,
@@ -55,7 +55,7 @@
55
55
  "react-native": "0.72.3",
56
56
  "styled-components": "^4.4.0"
57
57
  },
58
- "gitHead": "d36f81a8328b12473195f27b2a6bc70f1c98b9de",
58
+ "gitHead": "4cbae54a4a40e7081461982b3e17fc70be057349",
59
59
  "module": "./esm",
60
60
  "types": "./typings/index.d.ts",
61
61
  "private": false,