@gympass/yoga 7.40.3 → 7.41.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.
- package/cjs/Dialog/web/Dialog.js +0 -2
- package/cjs/Heading/Heading.theme.js +6 -4
- package/cjs/Heading/web/BackButton.js +15 -4
- package/cjs/Heading/web/Heading.js +5 -3
- package/cjs/Heading/web/RightButton.js +20 -5
- package/cjs/Heading/web/StyledHeading.js +1 -1
- package/cjs/Input/web/Field.js +1 -1
- package/cjs/Menu/Menu.theme.js +53 -0
- package/cjs/Menu/index.js +20 -0
- package/cjs/Menu/web/Menu.js +55 -0
- package/cjs/Menu/web/Menu.test.js +123 -0
- package/cjs/Menu/web/MenuAction.js +26 -0
- package/cjs/Menu/web/MenuItem.js +80 -0
- package/cjs/Menu/web/MenuList.js +56 -0
- package/cjs/Theme/theme/theme.js +3 -0
- package/cjs/hooks/index.js +8 -0
- package/cjs/hooks/useKeyPress.js +40 -0
- package/cjs/index.js +4 -0
- package/esm/Dialog/web/Dialog.js +0 -2
- package/esm/Heading/Heading.theme.js +6 -4
- package/esm/Heading/web/BackButton.js +13 -4
- package/esm/Heading/web/Heading.js +5 -3
- package/esm/Heading/web/RightButton.js +14 -5
- package/esm/Heading/web/StyledHeading.js +1 -1
- package/esm/Input/web/Field.js +1 -1
- package/esm/Menu/Menu.theme.js +47 -0
- package/esm/Menu/index.js +8 -0
- package/esm/Menu/web/Menu.js +45 -0
- package/esm/Menu/web/Menu.test.js +115 -0
- package/esm/Menu/web/MenuAction.js +16 -0
- package/esm/Menu/web/MenuItem.js +63 -0
- package/esm/Menu/web/MenuList.js +39 -0
- package/esm/Theme/theme/theme.js +2 -0
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useKeyPress.js +32 -0
- package/esm/index.js +2 -1
- package/package.json +3 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useKeyPress = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var useKeyPress = function useKeyPress(targetKey) {
|
|
9
|
+
var _useState = (0, _react.useState)(false),
|
|
10
|
+
keyPressed = _useState[0],
|
|
11
|
+
setKeyPressed = _useState[1];
|
|
12
|
+
|
|
13
|
+
(0, _react.useEffect)(function () {
|
|
14
|
+
function downHandler(_ref) {
|
|
15
|
+
var key = _ref.key;
|
|
16
|
+
|
|
17
|
+
if (key === targetKey) {
|
|
18
|
+
setKeyPressed(true);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function upHandler(_ref2) {
|
|
23
|
+
var key = _ref2.key;
|
|
24
|
+
|
|
25
|
+
if (key === targetKey) {
|
|
26
|
+
setKeyPressed(false);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
window.addEventListener('keydown', downHandler);
|
|
31
|
+
window.addEventListener('keyup', upHandler);
|
|
32
|
+
return function () {
|
|
33
|
+
window.removeEventListener('keydown', downHandler);
|
|
34
|
+
window.removeEventListener('keyup', upHandler);
|
|
35
|
+
};
|
|
36
|
+
}, [targetKey]);
|
|
37
|
+
return keyPressed;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.useKeyPress = useKeyPress;
|
package/cjs/index.js
CHANGED
|
@@ -115,6 +115,10 @@ var _Header = _interopRequireDefault(require("./Header"));
|
|
|
115
115
|
|
|
116
116
|
exports.Header = _Header["default"];
|
|
117
117
|
|
|
118
|
+
var _Menu = _interopRequireDefault(require("./Menu"));
|
|
119
|
+
|
|
120
|
+
exports.Menu = _Menu["default"];
|
|
121
|
+
|
|
118
122
|
var _Banner = _interopRequireDefault(require("./Banner"));
|
|
119
123
|
|
|
120
124
|
exports.Banner = _Banner["default"];
|
package/esm/Dialog/web/Dialog.js
CHANGED
|
@@ -5,12 +5,14 @@ var Heading = function Heading(_ref) {
|
|
|
5
5
|
background: colors.white,
|
|
6
6
|
padding: {
|
|
7
7
|
vertical: spacing.small,
|
|
8
|
-
horizontal: spacing.huge
|
|
8
|
+
horizontal: spacing.huge,
|
|
9
|
+
horizontalMobile: spacing.medium
|
|
9
10
|
},
|
|
10
|
-
height:
|
|
11
|
+
height: spacing.xxxlarge,
|
|
11
12
|
button: {
|
|
12
|
-
width:
|
|
13
|
-
height: spacing.
|
|
13
|
+
width: spacing.large,
|
|
14
|
+
height: spacing.large,
|
|
15
|
+
marginRight: spacing.medium
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
18
|
};
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
var _excluded = ["onClick"];
|
|
2
2
|
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
3
5
|
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); }
|
|
4
6
|
|
|
5
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; }
|
|
6
8
|
|
|
9
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
+
|
|
7
11
|
import React from 'react';
|
|
12
|
+
import styled from 'styled-components';
|
|
8
13
|
import PropTypes from 'prop-types';
|
|
9
14
|
import { ArrowLeft } from '@gympass/yoga-icons';
|
|
10
15
|
import Button from '../../Button';
|
|
16
|
+
var ButtonIcon = styled(Button.Icon)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref) {
|
|
17
|
+
var heading = _ref.theme.yoga.components.heading;
|
|
18
|
+
return "\n width: " + heading.button.width + "px;\n height: " + heading.button.height + "px;\n ";
|
|
19
|
+
});
|
|
11
20
|
|
|
12
|
-
var BackButton = function BackButton(
|
|
13
|
-
var onClick =
|
|
14
|
-
props = _objectWithoutPropertiesLoose(
|
|
21
|
+
var BackButton = function BackButton(_ref2) {
|
|
22
|
+
var onClick = _ref2.onClick,
|
|
23
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
15
24
|
|
|
16
|
-
return /*#__PURE__*/React.createElement(
|
|
25
|
+
return /*#__PURE__*/React.createElement(ButtonIcon, _extends({}, props, {
|
|
17
26
|
icon: ArrowLeft,
|
|
18
27
|
inverted: true,
|
|
19
28
|
onClick: onClick
|
|
@@ -11,9 +11,9 @@ var Heading = function Heading(_ref) {
|
|
|
11
11
|
var backButton = null;
|
|
12
12
|
var title = null;
|
|
13
13
|
var rightButtons = [];
|
|
14
|
-
if (!children) throw new Error('Heading needs at least one child');
|
|
15
14
|
|
|
16
15
|
var defineComponent = function defineComponent(child) {
|
|
16
|
+
if (!child) return;
|
|
17
17
|
if (child.type.displayName === Title.displayName) title = child;
|
|
18
18
|
if (child.type.displayName === BackButton.displayName) backButton = child;
|
|
19
19
|
if (child.type.displayName === RightButton.displayName) rightButtons.push(child);
|
|
@@ -37,7 +37,9 @@ var Heading = function Heading(_ref) {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
Heading.propTypes = {
|
|
40
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
40
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
41
|
+
};
|
|
42
|
+
Heading.defaultProps = {
|
|
43
|
+
children: undefined
|
|
41
44
|
};
|
|
42
|
-
Heading.defaultProps = {};
|
|
43
45
|
export default Heading;
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
var _excluded = ["onClick", "icon"];
|
|
2
2
|
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
3
5
|
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); }
|
|
4
6
|
|
|
5
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; }
|
|
6
8
|
|
|
9
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
+
|
|
7
11
|
import React from 'react';
|
|
12
|
+
import styled, { css } from 'styled-components';
|
|
8
13
|
import PropTypes from 'prop-types';
|
|
9
14
|
import Button from '../../Button';
|
|
15
|
+
var ButtonIcon = styled(Button.Icon)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", ";\n"])), function (_ref) {
|
|
16
|
+
var heading = _ref.theme.yoga.components.heading;
|
|
17
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n width: ", "px;\n height: ", "px;\n\n :not(:last-of-type) {\n margin-right: ", "px;\n }\n "])), heading.button.width, heading.button.height, heading.button.marginRight);
|
|
18
|
+
});
|
|
10
19
|
|
|
11
|
-
var RightButton = function RightButton(
|
|
12
|
-
var onClick =
|
|
13
|
-
icon =
|
|
14
|
-
props = _objectWithoutPropertiesLoose(
|
|
20
|
+
var RightButton = function RightButton(_ref2) {
|
|
21
|
+
var onClick = _ref2.onClick,
|
|
22
|
+
icon = _ref2.icon,
|
|
23
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
15
24
|
|
|
16
|
-
return /*#__PURE__*/React.createElement(
|
|
25
|
+
return /*#__PURE__*/React.createElement(ButtonIcon, _extends({}, props, {
|
|
17
26
|
icon: icon,
|
|
18
27
|
inverted: true,
|
|
19
28
|
onClick: onClick
|
|
@@ -5,7 +5,7 @@ function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.s
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
var StyledHeading = styled.header(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref) {
|
|
7
7
|
var heading = _ref.theme.yoga.components.heading;
|
|
8
|
-
return "\n background: " + heading.background + ";\n padding: " + heading.padding.vertical + "px;\n width: 100%;\n min-height: " + heading.height + "px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n @media(min-width: 769px) {\n padding: " + heading.padding.vertical + "px " + heading.padding.horizontal + "px;\n }\n ";
|
|
8
|
+
return "\n background: " + heading.background + ";\n padding: " + heading.padding.vertical + "px " + heading.padding.horizontalMobile + "px;\n width: 100%;\n min-height: " + heading.height + "px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n @media(min-width: 769px) {\n padding: " + heading.padding.vertical + "px " + heading.padding.horizontal + "px;\n }\n ";
|
|
9
9
|
});
|
|
10
10
|
export var Button = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref2) {
|
|
11
11
|
var heading = _ref2.theme.yoga.components.heading;
|
package/esm/Input/web/Field.js
CHANGED
|
@@ -21,6 +21,6 @@ var Field = styled.input(_templateObject2 || (_templateObject2 = _taggedTemplate
|
|
|
21
21
|
colors = _ref2$theme$yoga.colors,
|
|
22
22
|
baseFont = _ref2$theme$yoga.baseFont,
|
|
23
23
|
input = _ref2$theme$yoga.components.input;
|
|
24
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n height: ", "px;\n padding-top: ", "px;\n padding-right: ", "px;\n padding-bottom: ", "px;\n padding-left: ", "px;\n\n color: ", ";\n font-family: ", ", sans-serif;\n font-size: ", "px;\n font-weight: ", ";\n\n &:focus {\n color: ", ";\n\n & ~ legend {\n max-width: max-content;\n transition-property: max-width;\n transition-duration: ", "ms;\n }\n\n & ~ label {\n ", "\n\n font-weight: ", ";\n color: ", ";\n }\n\n &::placeholder {\n color: ", ";\n }\n }\n\n &:disabled {\n cursor: not-allowed;\n color: ", ";\n text-fill-color: ", ";\n opacity: 1;\n }\n\n ", "\n\n ", "\n "])), input.height, input.padding.top, cleanable ? ICON_SIZE + input.padding.right * 2 : input.padding.right, input.padding.bottom, input.padding.left, input.font.color.focus, baseFont.family, input.font.size, input.font.weight, input.font.color.focus, transition.duration[1], labelTransition, input.label.font.weight, error ? "" + colors.feedback.attention[1] : "" + colors.text.primary, input.label.color["default"], colors.text.disabled, colors.text.disabled, placeholder && label ? css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n &::placeholder {\n color: transparent;\n }\n "]))) : css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n &::placeholder {\n color: ", ";\n }\n "])), input.label.color["default"]), value && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n & ~ legend {\n max-width: max-content;\n }\n\n & ~ label {\n color: ", ";\n ", "\n }\n "])), error ? "" + colors.feedback.attention[1] : '', labelTransition));
|
|
24
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n height: ", "px;\n padding-top: ", "px;\n padding-right: ", "px;\n padding-bottom: ", "px;\n padding-left: ", "px;\n\n color: ", ";\n font-family: ", ", sans-serif;\n font-size: ", "px;\n font-weight: ", ";\n\n &:focus {\n color: ", ";\n\n & ~ legend {\n max-width: max-content;\n transition-property: max-width;\n transition-duration: ", "ms;\n }\n\n & ~ label {\n ", "\n\n font-weight: ", ";\n color: ", ";\n }\n\n &::placeholder {\n color: ", ";\n }\n }\n\n &:disabled {\n cursor: not-allowed;\n color: ", ";\n -webkit-text-fill-color: ", ";\n opacity: 1;\n }\n\n ", "\n\n ", "\n "])), input.height, input.padding.top, cleanable ? ICON_SIZE + input.padding.right * 2 : input.padding.right, input.padding.bottom, input.padding.left, input.font.color.focus, baseFont.family, input.font.size, input.font.weight, input.font.color.focus, transition.duration[1], labelTransition, input.label.font.weight, error ? "" + colors.feedback.attention[1] : "" + colors.text.primary, input.label.color["default"], colors.text.disabled, colors.text.disabled, placeholder && label ? css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n &::placeholder {\n color: transparent;\n }\n "]))) : css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n &::placeholder {\n color: ", ";\n }\n "])), input.label.color["default"]), value && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n & ~ legend {\n max-width: max-content;\n }\n\n & ~ label {\n color: ", ";\n ", "\n }\n "])), error ? "" + colors.feedback.attention[1] : '', labelTransition));
|
|
25
25
|
});
|
|
26
26
|
export default Field;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var Menu = function Menu(_ref) {
|
|
2
|
+
var spacing = _ref.spacing,
|
|
3
|
+
radii = _ref.radii,
|
|
4
|
+
colors = _ref.colors,
|
|
5
|
+
fontWeights = _ref.fontWeights;
|
|
6
|
+
return {
|
|
7
|
+
border: {
|
|
8
|
+
radius: radii.small
|
|
9
|
+
},
|
|
10
|
+
width: {
|
|
11
|
+
min: 176,
|
|
12
|
+
max: 280
|
|
13
|
+
},
|
|
14
|
+
margin: {
|
|
15
|
+
"default": spacing.small,
|
|
16
|
+
medium: spacing.medium,
|
|
17
|
+
xxsmall: spacing.xxsmall
|
|
18
|
+
},
|
|
19
|
+
padding: {
|
|
20
|
+
horizontal: spacing.small,
|
|
21
|
+
vertical: spacing.xxsmall
|
|
22
|
+
},
|
|
23
|
+
backgroundColor: {
|
|
24
|
+
white: colors.white,
|
|
25
|
+
disabled: colors.elements.backgroundAndDisabled
|
|
26
|
+
},
|
|
27
|
+
text: {
|
|
28
|
+
"default": {
|
|
29
|
+
color: colors.text.primary
|
|
30
|
+
},
|
|
31
|
+
active: {
|
|
32
|
+
color: colors.primary
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
color: colors.text.disabled
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
font: {
|
|
39
|
+
weight: fontWeights.medium
|
|
40
|
+
},
|
|
41
|
+
icon: {
|
|
42
|
+
disabled: colors.elements.selectionAndIcons
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default Menu;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Root as MenuRoot } from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import { bool, node } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
var Menu = function Menu(_ref) {
|
|
6
|
+
var children = _ref.children,
|
|
7
|
+
onMouseHover = _ref.onMouseHover;
|
|
8
|
+
|
|
9
|
+
var _React$useState = React.useState(false),
|
|
10
|
+
isOpen = _React$useState[0],
|
|
11
|
+
setIsOpen = _React$useState[1];
|
|
12
|
+
|
|
13
|
+
function handleOpenMenu() {
|
|
14
|
+
setIsOpen(!isOpen);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!onMouseHover) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(MenuRoot, {
|
|
19
|
+
sideOffset: 5,
|
|
20
|
+
modal: false
|
|
21
|
+
}, children);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
onMouseEnter: handleOpenMenu,
|
|
26
|
+
onMouseLeave: handleOpenMenu
|
|
27
|
+
}, /*#__PURE__*/React.createElement(MenuRoot, {
|
|
28
|
+
sideOffset: 5,
|
|
29
|
+
modal: false,
|
|
30
|
+
defaultOpen: true,
|
|
31
|
+
open: isOpen
|
|
32
|
+
}, children));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Menu.propTypes = {
|
|
36
|
+
children: node.isRequired,
|
|
37
|
+
|
|
38
|
+
/** when mouse hover menu open as deafault is true */
|
|
39
|
+
onMouseHover: bool
|
|
40
|
+
};
|
|
41
|
+
Menu.defaultProps = {
|
|
42
|
+
onMouseHover: true
|
|
43
|
+
};
|
|
44
|
+
Menu.displayName = 'Menu';
|
|
45
|
+
export default Menu;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { FlagArgentina, FlagBrazil, FlagChile, HomeFilled, MenuList } from '@gympass/yoga-icons';
|
|
4
|
+
import { ThemeProvider, Menu, Button } from '../..';
|
|
5
|
+
describe('<Menu />', function () {
|
|
6
|
+
it('should match snapshot in default Menu', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
8
|
+
icon: MenuList
|
|
9
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, null, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
10
|
+
container = _render.container;
|
|
11
|
+
|
|
12
|
+
expect(container).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
it('should match snapshot Menu.Item with icon', function () {
|
|
15
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
16
|
+
icon: MenuList
|
|
17
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
18
|
+
icon: FlagBrazil
|
|
19
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
20
|
+
icon: FlagArgentina
|
|
21
|
+
}, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
22
|
+
icon: FlagChile
|
|
23
|
+
}, "Item 3"))))),
|
|
24
|
+
container = _render2.container;
|
|
25
|
+
|
|
26
|
+
expect(container).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should match snapshot Menu.Item with link', function () {
|
|
29
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
30
|
+
icon: MenuList
|
|
31
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
32
|
+
href: "http://www.gympass.com",
|
|
33
|
+
target: "blank"
|
|
34
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
35
|
+
href: "http://www.gympass.com",
|
|
36
|
+
target: "blank"
|
|
37
|
+
}, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
38
|
+
href: "http://www.gympass.com",
|
|
39
|
+
target: "blank"
|
|
40
|
+
}, "Item 3"))))),
|
|
41
|
+
container = _render3.container;
|
|
42
|
+
|
|
43
|
+
expect(container).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
it('should match snapshot Menu.Item with active', function () {
|
|
46
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
47
|
+
icon: MenuList
|
|
48
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
49
|
+
active: true
|
|
50
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
51
|
+
container = _render4.container;
|
|
52
|
+
|
|
53
|
+
expect(container).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
it('should match snapshot Menu.Item with disabled', function () {
|
|
56
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
57
|
+
icon: MenuList
|
|
58
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
59
|
+
disabled: true
|
|
60
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
61
|
+
container = _render5.container;
|
|
62
|
+
|
|
63
|
+
expect(container).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('should match snapshot Menu.Item with disabled and icon', function () {
|
|
66
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
67
|
+
icon: MenuList
|
|
68
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
69
|
+
icon: HomeFilled,
|
|
70
|
+
disabled: true
|
|
71
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
72
|
+
container = _render6.container;
|
|
73
|
+
|
|
74
|
+
expect(container).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
it('should match snapshot Menu with a onMouseHover props false', function () {
|
|
77
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, {
|
|
78
|
+
onMouseHover: false
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
80
|
+
icon: MenuList
|
|
81
|
+
})), /*#__PURE__*/React.createElement(Menu.List, null, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
82
|
+
icon: HomeFilled,
|
|
83
|
+
disabled: true
|
|
84
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
85
|
+
container = _render7.container;
|
|
86
|
+
|
|
87
|
+
expect(container).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
it('should match snapshot Menu with an align props start', function () {
|
|
90
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
91
|
+
icon: MenuList
|
|
92
|
+
})), /*#__PURE__*/React.createElement(Menu.List, {
|
|
93
|
+
align: "start"
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
95
|
+
icon: HomeFilled,
|
|
96
|
+
disabled: true
|
|
97
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
98
|
+
container = _render8.container;
|
|
99
|
+
|
|
100
|
+
expect(container).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
it('should match snapshot Menu with an align props end', function () {
|
|
103
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Action, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
104
|
+
icon: MenuList
|
|
105
|
+
})), /*#__PURE__*/React.createElement(Menu.List, {
|
|
106
|
+
align: "end"
|
|
107
|
+
}, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
108
|
+
icon: HomeFilled,
|
|
109
|
+
disabled: true
|
|
110
|
+
}, "Item 1"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 2"), /*#__PURE__*/React.createElement(Menu.Item, null, "Item 3"))))),
|
|
111
|
+
container = _render9.container;
|
|
112
|
+
|
|
113
|
+
expect(container).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Trigger as MenuActionRoot } from '@radix-ui/react-dropdown-menu';
|
|
3
|
+
import { node } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
var MenuAction = function MenuAction(_ref) {
|
|
6
|
+
var children = _ref.children;
|
|
7
|
+
return /*#__PURE__*/React.createElement(MenuActionRoot, {
|
|
8
|
+
asChild: true
|
|
9
|
+
}, children);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
MenuAction.propTypes = {
|
|
13
|
+
children: node.isRequired
|
|
14
|
+
};
|
|
15
|
+
MenuAction.displayName = 'Menu.Action';
|
|
16
|
+
export default MenuAction;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var _excluded = ["icon", "href", "active", "disabled", "children"];
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
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); }
|
|
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
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
+
|
|
11
|
+
import React, { forwardRef } from 'react';
|
|
12
|
+
import { Item as MenuItemRoot } from '@radix-ui/react-dropdown-menu';
|
|
13
|
+
import { oneOfType, func, node, string, bool } from 'prop-types';
|
|
14
|
+
import styled from 'styled-components';
|
|
15
|
+
var StyledMenuItem = styled.li(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n ", "\n"])), function (_ref) {
|
|
16
|
+
var active = _ref.active,
|
|
17
|
+
disabled = _ref.disabled,
|
|
18
|
+
menu = _ref.theme.yoga.components.menu;
|
|
19
|
+
return "\n margin-right: auto;\n padding: " + menu.padding.vertical + "px " + menu.padding.horizontal + "px;\n\n width: 100%;\n cursor: pointer;\n text-decoration: none;\n color: " + menu.text["default"].color + ";\n\n " + (active ? "\n font-weight: " + menu.font.weight + ";\n color: " + menu.text.active.color + "\n " : '') + "\n\n " + (disabled ? "\n color: " + menu.text.disabled.color + ";\n pointer-events: none;\n\n svg {\n fill: " + menu.text.disabled.color + ";\n opacity: 0.5;\n }\n\n cursor: not-allowed;\n " : '') + "\n\n svg {\n margin-right: " + menu.margin["default"] + "px;\n fill: " + menu.icon.disabled + ";\n }\n\n &:focus {\n outline: none;\n background: " + menu.backgroundColor.disabled + ";\n }\n\n &:hover {\n background: " + menu.backgroundColor.disabled + ";\n }\n\n &:first-child {\n margin-top: " + menu.margin.xxsmall + "px;\n }\n\n &:last-child {\n margin-bottom: " + menu.margin.xxsmall + "px;\n }\n ";
|
|
20
|
+
});
|
|
21
|
+
var MenuItem = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
22
|
+
var Icon = _ref2.icon,
|
|
23
|
+
href = _ref2.href,
|
|
24
|
+
active = _ref2.active,
|
|
25
|
+
disabled = _ref2.disabled,
|
|
26
|
+
children = _ref2.children,
|
|
27
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
28
|
+
|
|
29
|
+
var finalProps = _extends({}, rest);
|
|
30
|
+
|
|
31
|
+
if (href) {
|
|
32
|
+
finalProps.as = 'a';
|
|
33
|
+
finalProps.href = href;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return /*#__PURE__*/React.createElement(MenuItemRoot, {
|
|
37
|
+
disabled: disabled,
|
|
38
|
+
asChild: true
|
|
39
|
+
}, /*#__PURE__*/React.createElement(StyledMenuItem, _extends({
|
|
40
|
+
active: active,
|
|
41
|
+
disabled: disabled,
|
|
42
|
+
ref: ref
|
|
43
|
+
}, finalProps), Icon && /*#__PURE__*/React.createElement(Icon, {
|
|
44
|
+
width: 20,
|
|
45
|
+
height: 20
|
|
46
|
+
}), children));
|
|
47
|
+
});
|
|
48
|
+
MenuItem.propTypes = {
|
|
49
|
+
/** The icon of menu item */
|
|
50
|
+
icon: oneOfType([node, func]),
|
|
51
|
+
children: node.isRequired,
|
|
52
|
+
href: string,
|
|
53
|
+
disabled: bool,
|
|
54
|
+
active: bool
|
|
55
|
+
};
|
|
56
|
+
MenuItem.defaultProps = {
|
|
57
|
+
icon: undefined,
|
|
58
|
+
href: undefined,
|
|
59
|
+
disabled: false,
|
|
60
|
+
active: false
|
|
61
|
+
};
|
|
62
|
+
MenuItem.displayName = 'Menu.Item';
|
|
63
|
+
export default MenuItem;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { Content as MenuListRoot } from '@radix-ui/react-dropdown-menu';
|
|
8
|
+
import { node, string } from 'prop-types';
|
|
9
|
+
import Box from '../../Box';
|
|
10
|
+
var StyledMenuList = styled(MenuListRoot)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n align-items: center;\n ", "\n"])), function (_ref) {
|
|
11
|
+
var _ref$theme$yoga = _ref.theme.yoga,
|
|
12
|
+
menu = _ref$theme$yoga.components.menu,
|
|
13
|
+
elevations = _ref$theme$yoga.elevations;
|
|
14
|
+
return "\n margin: " + menu.margin["default"] + "px 0;\n padding: 0;\n min-width: " + menu.width.min + "px;\n max-width: " + menu.width.max + "px;\n border-radius: " + menu.border.radius + "px;\n\n background-color: " + menu.backgroundColor.white + ";\n box-shadow: " + elevations.small + "\n ";
|
|
15
|
+
});
|
|
16
|
+
var MenuList = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
17
|
+
var children = _ref2.children,
|
|
18
|
+
align = _ref2.align;
|
|
19
|
+
return /*#__PURE__*/React.createElement(StyledMenuList, {
|
|
20
|
+
asChild: true,
|
|
21
|
+
sideOffset: 2,
|
|
22
|
+
alignOffset: -5,
|
|
23
|
+
align: align
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
25
|
+
as: "ul",
|
|
26
|
+
ref: ref
|
|
27
|
+
}, children));
|
|
28
|
+
});
|
|
29
|
+
MenuList.propTypes = {
|
|
30
|
+
children: node.isRequired,
|
|
31
|
+
|
|
32
|
+
/** Align Menu is a alignement that menu will appear on the screen | start | center | end */
|
|
33
|
+
align: string
|
|
34
|
+
};
|
|
35
|
+
MenuList.defaultProps = {
|
|
36
|
+
align: 'start'
|
|
37
|
+
};
|
|
38
|
+
MenuList.displayName = 'Menu.List';
|
|
39
|
+
export default MenuList;
|
package/esm/Theme/theme/theme.js
CHANGED
|
@@ -22,6 +22,7 @@ import _componentThemes_Heading$Heading from "./../../Heading/Heading.theme.js";
|
|
|
22
22
|
import _componentThemes_Icon$Icon from "./../../Icon/Icon.theme.js";
|
|
23
23
|
import _componentThemes_Input$Input from "./../../Input/Input.theme.js";
|
|
24
24
|
import _componentThemes_List$List from "./../../List/List.theme.js";
|
|
25
|
+
import _componentThemes_Menu$Menu from "./../../Menu/Menu.theme.js";
|
|
25
26
|
import _componentThemes_Progress$Progress from "./../../Progress/Progress.theme.js";
|
|
26
27
|
import _componentThemes_RadioGroup$RadioGroup from "./../../RadioGroup/RadioGroup.theme.js";
|
|
27
28
|
import _componentThemes_Rating$Rating from "./../../Rating/Rating.theme.js";
|
|
@@ -53,6 +54,7 @@ var componentThemes = {
|
|
|
53
54
|
Icon$Icon: _componentThemes_Icon$Icon,
|
|
54
55
|
Input$Input: _componentThemes_Input$Input,
|
|
55
56
|
List$List: _componentThemes_List$List,
|
|
57
|
+
Menu$Menu: _componentThemes_Menu$Menu,
|
|
56
58
|
Progress$Progress: _componentThemes_Progress$Progress,
|
|
57
59
|
RadioGroup$RadioGroup: _componentThemes_RadioGroup$RadioGroup,
|
|
58
60
|
Rating$Rating: _componentThemes_Rating$Rating,
|
package/esm/hooks/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './usePortal';
|
|
1
|
+
export * from './usePortal';
|
|
2
|
+
export * from './useKeyPress';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
export var useKeyPress = function useKeyPress(targetKey) {
|
|
3
|
+
var _useState = useState(false),
|
|
4
|
+
keyPressed = _useState[0],
|
|
5
|
+
setKeyPressed = _useState[1];
|
|
6
|
+
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
function downHandler(_ref) {
|
|
9
|
+
var key = _ref.key;
|
|
10
|
+
|
|
11
|
+
if (key === targetKey) {
|
|
12
|
+
setKeyPressed(true);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function upHandler(_ref2) {
|
|
17
|
+
var key = _ref2.key;
|
|
18
|
+
|
|
19
|
+
if (key === targetKey) {
|
|
20
|
+
setKeyPressed(false);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
window.addEventListener('keydown', downHandler);
|
|
25
|
+
window.addEventListener('keyup', upHandler);
|
|
26
|
+
return function () {
|
|
27
|
+
window.removeEventListener('keydown', downHandler);
|
|
28
|
+
window.removeEventListener('keyup', upHandler);
|
|
29
|
+
};
|
|
30
|
+
}, [targetKey]);
|
|
31
|
+
return keyPressed;
|
|
32
|
+
};
|
package/esm/index.js
CHANGED
|
@@ -24,7 +24,8 @@ import BottomSheet from './BottomSheet';
|
|
|
24
24
|
import Dialog from './Dialog';
|
|
25
25
|
import Divider from './Divider';
|
|
26
26
|
import Header from './Header';
|
|
27
|
+
import Menu from './Menu';
|
|
27
28
|
import Banner from './Banner';
|
|
28
29
|
import Heading from './Heading';
|
|
29
30
|
import Feedback from './Feedback';
|
|
30
|
-
export { ThemeProvider, FontLoader, createTheme, yogaTheme, theme, Button, List, Checkbox, RadioGroup, Slider, Card, PlanCard, Stepper, Container, Row, Col, Hide, Text, Rating, EventCard, Tag, Input, Progress, Dropdown, TextArea, AutoComplete, Icon, Chips, Box, Snackbar, Avatar, BottomSheet, Dialog, Divider, Header, Banner, Heading, Feedback };
|
|
31
|
+
export { ThemeProvider, FontLoader, createTheme, yogaTheme, theme, Button, List, Checkbox, RadioGroup, Slider, Card, PlanCard, Stepper, Container, Row, Col, Hide, Text, Rating, EventCard, Tag, Input, Progress, Dropdown, TextArea, AutoComplete, Icon, Chips, Box, Snackbar, Avatar, BottomSheet, Dialog, Divider, Header, Menu, Banner, Heading, Feedback };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.41.1",
|
|
4
4
|
"description": "Gympass component library",
|
|
5
5
|
"main": "./cjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@gympass/yoga-system": "^0.10.2",
|
|
32
32
|
"@gympass/yoga-tokens": "^3.1.4",
|
|
33
33
|
"@ptomasroos/react-native-multi-slider": "^1.0.0",
|
|
34
|
+
"@radix-ui/react-dropdown-menu": "^0.1.6",
|
|
34
35
|
"downshift": "^5.0.0",
|
|
35
36
|
"lodash.get": "^4.4.2",
|
|
36
37
|
"prop-types": "^15.7.2",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"react": ">=16",
|
|
50
51
|
"styled-components": "^4.4.0"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "bd1d2ba8103093c7e7179bacfb4448ce4bef60ab",
|
|
53
54
|
"module": "./esm",
|
|
54
55
|
"private": false,
|
|
55
56
|
"react-native": "./cjs/index.native.js"
|