@gympass/yoga 7.37.0 → 7.38.0
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/AutoComplete/web/AutoComplete.test.js +152 -0
- package/cjs/Avatar/native/Avatar.test.js +1 -0
- package/cjs/Avatar/web/Avatar.test.js +72 -0
- package/cjs/Banner/native/Banner.test.js +1 -0
- package/cjs/Banner/web/Banner.test.js +121 -0
- package/cjs/BottomSheet/web/BottomSheet.test.js +46 -0
- package/cjs/Box/native/Box.test.js +1 -0
- package/cjs/Box/web/Box.test.js +23 -0
- package/cjs/Button/native/Button.test.js +1 -0
- package/cjs/Button/web/Button.test.js +778 -0
- package/cjs/Card/Card.native.theme.js +9 -7
- package/cjs/Card/Card.theme.js +1 -1
- package/cjs/Card/Card.web.theme.js +8 -6
- package/cjs/Card/native/Card/Card.test.js +1 -0
- package/cjs/Card/native/EventCard/EventCard.test.js +1 -0
- package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +1 -0
- package/cjs/Card/native/PlanCard/Actions.js +1 -1
- package/cjs/Card/native/PlanCard/Content.js +1 -1
- package/cjs/Card/native/PlanCard/PlanCard.test.js +1 -0
- package/cjs/Card/web/Card/Card.test.js +22 -0
- package/cjs/Card/web/EventCard/EventCard.test.js +35 -0
- package/cjs/Card/web/PlanCard/Actions.js +1 -1
- package/cjs/Card/web/PlanCard/Content.js +28 -32
- package/cjs/Card/web/PlanCard/PlanCard.test.js +95 -0
- package/cjs/Checkbox/native/Checkbox.test.js +1 -0
- package/cjs/Checkbox/native/Switch.test.js +1 -0
- package/cjs/Checkbox/web/Checkbox.test.js +161 -0
- package/cjs/Checkbox/web/Switch.test.js +65 -0
- package/cjs/Chips/native/Chips.test.js +1 -0
- package/cjs/Chips/web/Chips.test.js +138 -0
- package/cjs/Dialog/web/Dialog.test.js +70 -0
- package/cjs/Divider/native/Divider.test.js +1 -0
- package/cjs/Divider/web/Divider.test.js +36 -0
- package/cjs/Dropdown/native/Backdrop.test.js +1 -0
- package/cjs/Dropdown/native/Dropdown.test.js +1 -0
- package/cjs/Dropdown/web/Dropdown.test.js +102 -0
- package/cjs/Feedback/web/Feedback.test.js +89 -0
- package/cjs/Grid/web/Col.test.js +56 -0
- package/cjs/Grid/web/Container.test.js +22 -0
- package/cjs/Grid/web/Hide.test.js +39 -0
- package/cjs/Grid/web/Row.test.js +22 -0
- package/cjs/Header/web/Header.test.js +44 -0
- package/cjs/Heading/web/Heading.test.js +55 -0
- package/cjs/Heading/web/RightButton.js +1 -1
- package/cjs/Icon/native/Icon.test.js +1 -0
- package/cjs/Icon/web/Icon.test.js +53 -0
- package/cjs/Input/native/Email.test.js +1 -0
- package/cjs/Input/native/Input.test.js +1 -0
- package/cjs/Input/native/Number.test.js +1 -0
- package/cjs/Input/native/Password.test.js +1 -0
- package/cjs/Input/native/Tel.test.js +1 -0
- package/cjs/Input/web/Email.test.js +20 -0
- package/cjs/Input/web/Field.js +1 -1
- package/cjs/Input/web/Input.test.js +161 -0
- package/cjs/Input/web/Number.test.js +20 -0
- package/cjs/Input/web/Password.test.js +103 -0
- package/cjs/Input/web/Tel.test.js +20 -0
- package/cjs/List/native/List.test.js +1 -0
- package/cjs/List/web/List.test.js +69 -0
- package/cjs/Progress/native/Progress.test.js +1 -0
- package/cjs/Progress/web/Progress.test.js +229 -0
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +1 -0
- package/cjs/RadioGroup/native/Radio/Radio.test.js +1 -0
- package/cjs/RadioGroup/native/RadioGroup.test.js +1 -0
- package/cjs/RadioGroup/web/Button/RadioButton.test.js +132 -0
- package/cjs/RadioGroup/web/Radio/Radio.test.js +119 -0
- package/cjs/RadioGroup/web/RadioGroup.test.js +93 -0
- package/cjs/Rating/native/Rating.test.js +1 -0
- package/cjs/Rating/web/Rating.test.js +201 -0
- package/cjs/Result/native/Result.test.js +1 -0
- package/cjs/Slider/native/Slider.test.js +1 -0
- package/cjs/Slider/web/Slider.test.js +95 -0
- package/cjs/Snackbar/native/Snackbar.test.js +1 -0
- package/cjs/Snackbar/web/Snackbar.test.js +135 -0
- package/cjs/Stepper/native/Stepper.test.js +1 -0
- package/cjs/Stepper/web/Stepper.test.js +75 -0
- package/cjs/Tag/native/Tag.test.js +1 -0
- package/cjs/Tag/web/Tag.test.js +87 -0
- package/cjs/Text/native/Text.test.js +1 -0
- package/cjs/Text/sharedTextStyle.js +1 -1
- package/cjs/Text/textStyle.android.js +1 -1
- package/cjs/Text/textStyle.ios.js +1 -1
- package/cjs/Text/textStyle.web.js +1 -1
- package/cjs/Text/web/Text.test.js +157 -0
- package/cjs/TextArea/native/TextArea.test.js +1 -0
- package/cjs/TextArea/web/TextArea.test.js +18 -0
- package/cjs/Theme/Provider/web/FontLoader.test.js +19 -0
- package/cjs/Theme/Provider/web/GlobalStyle.test.js +27 -0
- package/cjs/Theme/helpers/themeReader/native/native.test.js +1 -0
- package/cjs/Theme/helpers/themeReader/web/web.test.js +54 -0
- package/esm/AutoComplete/web/AutoComplete.test.js +135 -0
- package/esm/Avatar/index.native.js +4 -0
- package/esm/Avatar/native/Avatar.js +96 -0
- package/esm/Avatar/native/Avatar.test.js +46 -0
- package/esm/Avatar/native/AvatarCircle.js +24 -0
- package/esm/Avatar/web/Avatar.test.js +63 -0
- package/esm/Banner/index.native.js +2 -0
- package/esm/Banner/native/Banner.js +128 -0
- package/esm/Banner/native/Banner.test.js +103 -0
- package/esm/Banner/native/index.js +2 -0
- package/esm/Banner/web/Banner.test.js +109 -0
- package/esm/BottomSheet/web/BottomSheet.test.js +33 -0
- package/esm/Box/index.native.js +2 -0
- package/esm/Box/native/Box.js +4 -0
- package/esm/Box/native/Box.test.js +16 -0
- package/esm/Box/native/index.js +2 -0
- package/esm/Box/web/Box.test.js +16 -0
- package/esm/Button/index.native.js +8 -0
- package/esm/Button/native/Button.js +110 -0
- package/esm/Button/native/Button.test.js +475 -0
- package/esm/Button/native/Icon.js +82 -0
- package/esm/Button/native/Link.js +35 -0
- package/esm/Button/native/Text.js +74 -0
- package/esm/Button/native/withTouchable.js +63 -0
- package/esm/Button/web/Button.test.js +764 -0
- package/esm/Card/Card.native.theme.js +9 -7
- package/esm/Card/Card.theme.js +1 -1
- package/esm/Card/Card.web.theme.js +8 -6
- package/esm/Card/index.native.js +2 -0
- package/esm/Card/native/Card/Actions.js +12 -0
- package/esm/Card/native/Card/Card.js +92 -0
- package/esm/Card/native/Card/Card.test.js +15 -0
- package/esm/Card/native/Card/Content.js +8 -0
- package/esm/Card/native/Card/Header.js +8 -0
- package/esm/Card/native/Card/index.js +8 -0
- package/esm/Card/native/EventCard/EventCard.js +169 -0
- package/esm/Card/native/EventCard/EventCard.test.js +65 -0
- package/esm/Card/native/EventCard/index.js +2 -0
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +17 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +66 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +39 -0
- package/esm/Card/native/GymCard/CheckIn/Content.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/Header.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/index.js +2 -0
- package/esm/Card/native/GymCard/index.js +5 -0
- package/esm/Card/native/PlanCard/Actions.js +24 -0
- package/esm/Card/native/PlanCard/Content.js +75 -0
- package/esm/Card/native/PlanCard/List.js +73 -0
- package/esm/Card/native/PlanCard/PlanCard.js +54 -0
- package/esm/Card/native/PlanCard/PlanCard.test.js +84 -0
- package/esm/Card/native/PlanCard/Subtitle.js +15 -0
- package/esm/Card/native/PlanCard/Tag.js +33 -0
- package/esm/Card/native/PlanCard/index.js +15 -0
- package/esm/Card/native/index.js +5 -0
- package/esm/Card/web/Card/Card.test.js +14 -0
- package/esm/Card/web/EventCard/EventCard.test.js +27 -0
- package/esm/Card/web/PlanCard/Actions.js +1 -1
- package/esm/Card/web/PlanCard/Content.js +25 -30
- package/esm/Card/web/PlanCard/PlanCard.test.js +85 -0
- package/esm/Checkbox/index.native.js +3 -0
- package/esm/Checkbox/native/Checkbox.js +179 -0
- package/esm/Checkbox/native/Checkbox.test.js +115 -0
- package/esm/Checkbox/native/Switch.js +115 -0
- package/esm/Checkbox/native/Switch.test.js +54 -0
- package/esm/Checkbox/native/index.js +3 -0
- package/esm/Checkbox/web/Checkbox.test.js +153 -0
- package/esm/Checkbox/web/Switch.test.js +56 -0
- package/esm/Chips/index.native.js +2 -0
- package/esm/Chips/native/Chips.js +104 -0
- package/esm/Chips/native/Chips.test.js +134 -0
- package/esm/Chips/native/Counter.js +20 -0
- package/esm/Chips/native/index.js +2 -0
- package/esm/Chips/web/Chips.test.js +128 -0
- package/esm/Dialog/web/Dialog.test.js +54 -0
- package/esm/Divider/index.native.js +2 -0
- package/esm/Divider/native/Divider.js +29 -0
- package/esm/Divider/native/Divider.test.js +29 -0
- package/esm/Divider/native/index.js +2 -0
- package/esm/Divider/web/Divider.test.js +29 -0
- package/esm/Dropdown/index.native.js +2 -0
- package/esm/Dropdown/native/Backdrop.js +93 -0
- package/esm/Dropdown/native/Backdrop.test.js +26 -0
- package/esm/Dropdown/native/Dropdown.js +142 -0
- package/esm/Dropdown/native/Dropdown.test.js +78 -0
- package/esm/Dropdown/native/Options.android.js +66 -0
- package/esm/Dropdown/native/Options.ios.js +71 -0
- package/esm/Dropdown/native/index.js +2 -0
- package/esm/Dropdown/web/Dropdown.test.js +93 -0
- package/esm/Feedback/web/Feedback.test.js +83 -0
- package/esm/Grid/web/Col.test.js +48 -0
- package/esm/Grid/web/Container.test.js +14 -0
- package/esm/Grid/web/Hide.test.js +31 -0
- package/esm/Grid/web/Row.test.js +14 -0
- package/esm/Header/web/Header.test.js +34 -0
- package/esm/Heading/web/Heading.test.js +45 -0
- package/esm/Heading/web/RightButton.js +1 -1
- package/esm/Icon/index.native.js +2 -0
- package/esm/Icon/native/Icon.test.js +47 -0
- package/esm/Icon/native/index.js +2 -0
- package/esm/Icon/web/Icon.test.js +47 -0
- package/esm/Input/index.native.js +6 -0
- package/esm/Input/native/Email.js +15 -0
- package/esm/Input/native/Email.test.js +13 -0
- package/esm/Input/native/Helper.js +62 -0
- package/esm/Input/native/Input.js +234 -0
- package/esm/Input/native/Input.test.js +181 -0
- package/esm/Input/native/Number.js +12 -0
- package/esm/Input/native/Number.test.js +13 -0
- package/esm/Input/native/Password.js +112 -0
- package/esm/Input/native/Password.test.js +125 -0
- package/esm/Input/native/Tel.js +14 -0
- package/esm/Input/native/Tel.test.js +13 -0
- package/esm/Input/native/index.js +6 -0
- package/esm/Input/web/Email.test.js +13 -0
- package/esm/Input/web/Field.js +1 -1
- package/esm/Input/web/Input.test.js +145 -0
- package/esm/Input/web/Number.test.js +13 -0
- package/esm/Input/web/Password.test.js +90 -0
- package/esm/Input/web/Tel.test.js +13 -0
- package/esm/List/index.native.js +3 -0
- package/esm/List/native/List.js +22 -0
- package/esm/List/native/List.test.js +106 -0
- package/esm/List/native/ListItem.js +51 -0
- package/esm/List/native/index.js +3 -0
- package/esm/List/web/List.test.js +62 -0
- package/esm/Progress/index.native.js +2 -0
- package/esm/Progress/native/Progress.js +103 -0
- package/esm/Progress/native/Progress.test.js +222 -0
- package/esm/Progress/native/index.js +2 -0
- package/esm/Progress/web/Progress.test.js +222 -0
- package/esm/RadioGroup/index.native.js +4 -0
- package/esm/RadioGroup/native/Button/RadioButton.js +64 -0
- package/esm/RadioGroup/native/Button/RadioButton.test.js +94 -0
- package/esm/RadioGroup/native/Radio/Radio.js +88 -0
- package/esm/RadioGroup/native/Radio/Radio.test.js +102 -0
- package/esm/RadioGroup/native/RadioGroup.js +66 -0
- package/esm/RadioGroup/native/RadioGroup.test.js +48 -0
- package/esm/RadioGroup/native/index.js +4 -0
- package/esm/RadioGroup/web/Button/RadioButton.test.js +121 -0
- package/esm/RadioGroup/web/Radio/Radio.test.js +108 -0
- package/esm/RadioGroup/web/RadioGroup.test.js +83 -0
- package/esm/Rating/index.native.js +2 -0
- package/esm/Rating/native/Rating.js +186 -0
- package/esm/Rating/native/Rating.test.js +121 -0
- package/esm/Rating/native/index.js +2 -0
- package/esm/Rating/web/Rating.test.js +184 -0
- package/esm/Result/index.native.js +8 -0
- package/esm/Result/native/Attendances.js +55 -0
- package/esm/Result/native/Details.js +97 -0
- package/esm/Result/native/Rate.js +35 -0
- package/esm/Result/native/Result.js +86 -0
- package/esm/Result/native/Result.test.js +107 -0
- package/esm/Result/native/ResultButton.js +13 -0
- package/esm/Result/native/Tags.js +41 -0
- package/esm/Result/native/TinyTextIcon.js +18 -0
- package/esm/Result/native/index.js +2 -0
- package/esm/Slider/index.native.js +2 -0
- package/esm/Slider/native/Label.js +19 -0
- package/esm/Slider/native/Marker.js +68 -0
- package/esm/Slider/native/Slider.js +156 -0
- package/esm/Slider/native/Slider.test.js +115 -0
- package/esm/Slider/native/Step.js +14 -0
- package/esm/Slider/native/Tooltip.js +90 -0
- package/esm/Slider/web/Slider.test.js +86 -0
- package/esm/Snackbar/index.native.js +2 -0
- package/esm/Snackbar/native/Snackbar.js +199 -0
- package/esm/Snackbar/native/Snackbar.test.js +100 -0
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +124 -0
- package/esm/Snackbar/native/index.js +2 -0
- package/esm/Snackbar/web/Snackbar.test.js +116 -0
- package/esm/Stepper/index.native.js +3 -0
- package/esm/Stepper/native/Dots.js +45 -0
- package/esm/Stepper/native/Line.js +35 -0
- package/esm/Stepper/native/Step.js +19 -0
- package/esm/Stepper/native/Stepper.js +52 -0
- package/esm/Stepper/native/Stepper.test.js +68 -0
- package/esm/Stepper/native/index.js +3 -0
- package/esm/Stepper/web/Stepper.test.js +67 -0
- package/esm/Tag/index.native.js +4 -0
- package/esm/Tag/native/Informative.js +71 -0
- package/esm/Tag/native/Tag.js +75 -0
- package/esm/Tag/native/Tag.test.js +92 -0
- package/esm/Tag/native/index.js +2 -0
- package/esm/Tag/web/Tag.test.js +79 -0
- package/esm/Text/index.native.js +16 -0
- package/esm/Text/native/Text.js +69 -0
- package/esm/Text/native/Text.test.js +149 -0
- package/esm/Text/native/index.js +2 -0
- package/esm/Text/sharedTextStyle.js +1 -1
- package/esm/Text/textStyle.android.js +1 -1
- package/esm/Text/textStyle.ios.js +1 -1
- package/esm/Text/textStyle.web.js +1 -1
- package/esm/Text/web/Text.test.js +149 -0
- package/esm/TextArea/index.native.js +2 -0
- package/esm/TextArea/native/TextArea.js +59 -0
- package/esm/TextArea/native/TextArea.test.js +11 -0
- package/esm/TextArea/native/index.js +2 -0
- package/esm/TextArea/web/TextArea.test.js +11 -0
- package/esm/Theme/Provider/index.native.js +2 -0
- package/esm/Theme/Provider/native/index.js +2 -0
- package/esm/Theme/Provider/web/FontLoader.test.js +11 -0
- package/esm/Theme/Provider/web/GlobalStyle.test.js +17 -0
- package/esm/Theme/helpers/themeReader/native/native.test.js +53 -0
- package/esm/Theme/helpers/themeReader/web/web.test.js +41 -0
- package/esm/Theme/index.native.js +5 -0
- package/esm/index.native.js +24 -0
- package/esm/shared/index.native.js +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
7
|
+
import { ThemeProvider, Snackbar } from '../..';
|
|
8
|
+
describe('<Snackbar />', function () {
|
|
9
|
+
jest.useRealTimers();
|
|
10
|
+
it('should match snapshot', function () {
|
|
11
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
12
|
+
open: true,
|
|
13
|
+
message: "Make wellbeing universal",
|
|
14
|
+
onClose: jest.fn()
|
|
15
|
+
}))),
|
|
16
|
+
container = _render.container;
|
|
17
|
+
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it('should render a minimal snackbar', function () {
|
|
21
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
22
|
+
open: true,
|
|
23
|
+
message: "Make wellbeing universal",
|
|
24
|
+
onClose: jest.fn()
|
|
25
|
+
})));
|
|
26
|
+
screen.getByRole('alert');
|
|
27
|
+
screen.getByRole('img');
|
|
28
|
+
screen.getByLabelText('success');
|
|
29
|
+
screen.getByText('Make wellbeing universal');
|
|
30
|
+
});
|
|
31
|
+
it('should not render an icon', function () {
|
|
32
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
33
|
+
open: true,
|
|
34
|
+
message: "Make wellbeing universal",
|
|
35
|
+
onClose: jest.fn(),
|
|
36
|
+
hideIcon: true
|
|
37
|
+
})));
|
|
38
|
+
expect(screen.queryByRole('img')).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
it('should render a custom action button', function () {
|
|
41
|
+
var onActionMock = jest.fn();
|
|
42
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
43
|
+
open: true,
|
|
44
|
+
message: "Make wellbeing universal",
|
|
45
|
+
onAction: onActionMock,
|
|
46
|
+
onClose: jest.fn(),
|
|
47
|
+
actionLabel: "Let's go"
|
|
48
|
+
})));
|
|
49
|
+
var button = screen.getByRole('button', {
|
|
50
|
+
name: /let's go/i
|
|
51
|
+
});
|
|
52
|
+
fireEvent.click(button);
|
|
53
|
+
expect(onActionMock).toHaveBeenCalledTimes(1);
|
|
54
|
+
});
|
|
55
|
+
it('should render a close button', function () {
|
|
56
|
+
var onCloseMock = jest.fn();
|
|
57
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
58
|
+
open: true,
|
|
59
|
+
message: "Make wellbeing universal",
|
|
60
|
+
onClose: onCloseMock
|
|
61
|
+
})));
|
|
62
|
+
var button = screen.getByRole('button');
|
|
63
|
+
fireEvent.click(button);
|
|
64
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
65
|
+
});
|
|
66
|
+
it('should close after timeout', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
67
|
+
var onCloseMock;
|
|
68
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
69
|
+
while (1) {
|
|
70
|
+
switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
jest.useFakeTimers();
|
|
73
|
+
onCloseMock = jest.fn();
|
|
74
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
75
|
+
open: true,
|
|
76
|
+
duration: 1000,
|
|
77
|
+
message: "Make wellbeing universal",
|
|
78
|
+
onClose: onCloseMock,
|
|
79
|
+
hideCloseButton: true
|
|
80
|
+
})));
|
|
81
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
82
|
+
jest.runAllTimers();
|
|
83
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
84
|
+
|
|
85
|
+
case 6:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, _callee);
|
|
91
|
+
})));
|
|
92
|
+
it('should close with timeout set up', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
93
|
+
var onCloseMock, button;
|
|
94
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
95
|
+
while (1) {
|
|
96
|
+
switch (_context2.prev = _context2.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
onCloseMock = jest.fn();
|
|
99
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
100
|
+
open: true,
|
|
101
|
+
duration: 1000,
|
|
102
|
+
message: "Make wellbeing universal",
|
|
103
|
+
onClose: onCloseMock
|
|
104
|
+
})));
|
|
105
|
+
button = screen.getByRole('button');
|
|
106
|
+
fireEvent.click(button);
|
|
107
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
108
|
+
|
|
109
|
+
case 5:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context2.stop();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, _callee2);
|
|
115
|
+
})));
|
|
116
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { number, arrayOf, string } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import activeDot from '../activeDot';
|
|
9
|
+
import Text from '../../Text';
|
|
10
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n justify-content: space-between;\n"])));
|
|
11
|
+
var DotWrapper = styled.View(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n width: 15px;\n"])));
|
|
12
|
+
var Dot = styled.View(function (_ref) {
|
|
13
|
+
var active = _ref.active,
|
|
14
|
+
stepper = _ref.theme.yoga.components.stepper;
|
|
15
|
+
return "\n width: 15px;\n height: 15px;\n\n margin-top: -6px;\n\n border-radius: " + stepper.dot.radius + "px;\n background-color: " + (active ? stepper.dot.backgroundColor.active : stepper.dot.backgroundColor.inactive) + ";\n ";
|
|
16
|
+
});
|
|
17
|
+
var Label = styled(Text.Bold)(function (_ref2) {
|
|
18
|
+
var active = _ref2.active,
|
|
19
|
+
stepper = _ref2.theme.yoga.components.stepper;
|
|
20
|
+
return "\n width: 95px;\n margin-top: 10px;\n margin-left: -40px;\n\n color: " + (active ? stepper.label.color.active : stepper.label.color.inactive) + ";\n\n font-size: " + stepper.label.font.size + "px;\n text-align: center;\n ";
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var Dots = function Dots(_ref3) {
|
|
24
|
+
var activeStep = _ref3.activeStep,
|
|
25
|
+
labels = _ref3.labels;
|
|
26
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, labels.map(function (label, index) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(DotWrapper, {
|
|
28
|
+
key: label
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Dot, {
|
|
30
|
+
active: activeDot(index, activeStep)
|
|
31
|
+
}), /*#__PURE__*/React.createElement(Label, {
|
|
32
|
+
active: activeDot(index, activeStep)
|
|
33
|
+
}, label));
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Dots.propTypes = {
|
|
38
|
+
activeStep: number,
|
|
39
|
+
labels: arrayOf(string)
|
|
40
|
+
};
|
|
41
|
+
Dots.defaultProps = {
|
|
42
|
+
activeStep: 0,
|
|
43
|
+
labels: []
|
|
44
|
+
};
|
|
45
|
+
export default Dots;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { number } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n position: relative;\n"])));
|
|
9
|
+
var InactiveLine = styled.View(function (_ref) {
|
|
10
|
+
var stepper = _ref.theme.yoga.components.stepper;
|
|
11
|
+
return "\n width: 100%;\n height: 4px;\n\n position: absolute;\n top: 0;\n\n background-color: " + stepper.line.backgroundColor.inactive + ";\n";
|
|
12
|
+
});
|
|
13
|
+
var ActiveLine = styled.View(function (_ref2) {
|
|
14
|
+
var width = _ref2.width,
|
|
15
|
+
stepper = _ref2.theme.yoga.components.stepper;
|
|
16
|
+
return "\n position: absolute;\n top: 0;\n\n background-color: " + stepper.line.backgroundColor.active + ";\n width: " + width + "%;\n height: 4px;\n";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var Line = function Line(_ref3) {
|
|
20
|
+
var activeStep = _ref3.activeStep,
|
|
21
|
+
totalSteps = _ref3.totalSteps;
|
|
22
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(InactiveLine, null), /*#__PURE__*/React.createElement(ActiveLine, {
|
|
23
|
+
width: activeStep <= 0 ? 0 : activeStep / totalSteps * 100
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.propTypes = {
|
|
28
|
+
activeStep: number,
|
|
29
|
+
totalSteps: number
|
|
30
|
+
};
|
|
31
|
+
Line.defaultProps = {
|
|
32
|
+
activeStep: 0,
|
|
33
|
+
totalSteps: 0
|
|
34
|
+
};
|
|
35
|
+
export default Line;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { string } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
9
|
+
|
|
10
|
+
var Step = function Step(props) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(Wrapper, props);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Step.displayName = 'Stepper.Step';
|
|
15
|
+
Step.propTypes = {
|
|
16
|
+
/** Label to be displayed below the stepper dot. */
|
|
17
|
+
label: string.isRequired
|
|
18
|
+
};
|
|
19
|
+
export default Step;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var _excluded = ["children", "activeStep"];
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
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
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import { limitChildren, typeOf } from '../../shared';
|
|
12
|
+
import Line from './Line';
|
|
13
|
+
import Dots from './Dots';
|
|
14
|
+
import Step from './Step';
|
|
15
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
16
|
+
var LineWrapper = styled.View(function (_ref) {
|
|
17
|
+
var stepper = _ref.theme.yoga.components.stepper;
|
|
18
|
+
return "\n width: 100%;\n padding: 0 " + stepper.padding.right + "px 0 " + stepper.padding.left + "px;\n";
|
|
19
|
+
});
|
|
20
|
+
/** Stepper is responsible for the logic that drives a stepped workflow, it
|
|
21
|
+
provides a wizard-like workflow by dividing content into logical steps. */
|
|
22
|
+
|
|
23
|
+
var Stepper = function Stepper(_ref2) {
|
|
24
|
+
var children = _ref2.children,
|
|
25
|
+
activeStep = _ref2.activeStep,
|
|
26
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement(Wrapper, rest, /*#__PURE__*/React.createElement(LineWrapper, null, /*#__PURE__*/React.createElement(Line, {
|
|
29
|
+
activeStep: activeStep,
|
|
30
|
+
totalSteps: React.Children.count(children) - 1
|
|
31
|
+
}), /*#__PURE__*/React.createElement(Dots, {
|
|
32
|
+
activeStep: activeStep,
|
|
33
|
+
labels: React.Children.map(children, function (child) {
|
|
34
|
+
return child.props.label;
|
|
35
|
+
})
|
|
36
|
+
})), React.Children.toArray(children)[activeStep]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Stepper.displayName = 'Stepper';
|
|
40
|
+
Stepper.propTypes = {
|
|
41
|
+
/** Must be a Stepper.Step component. */
|
|
42
|
+
children: typeOf(Step),
|
|
43
|
+
|
|
44
|
+
/** Controls the active step, it receive the index value for showing some
|
|
45
|
+
* step. Starting from 0. */
|
|
46
|
+
activeStep: limitChildren
|
|
47
|
+
};
|
|
48
|
+
Stepper.defaultProps = {
|
|
49
|
+
children: undefined,
|
|
50
|
+
activeStep: 0
|
|
51
|
+
};
|
|
52
|
+
export default Stepper;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { render, toJSON } from '@testing-library/react-native';
|
|
4
|
+
import ThemeProvider from '../../Theme';
|
|
5
|
+
import Stepper from '..';
|
|
6
|
+
describe('<Stepper />', function () {
|
|
7
|
+
describe('Snapshots', function () {
|
|
8
|
+
it('should match snapshot with first step active', function () {
|
|
9
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
10
|
+
activeStep: 0
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
12
|
+
label: "step one"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
14
|
+
label: "step two"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
16
|
+
label: "step three"
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
18
|
+
container = _render.container;
|
|
19
|
+
|
|
20
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
it('should match snapshot with second step active', function () {
|
|
23
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
24
|
+
activeStep: 1
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
26
|
+
label: "step one"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
28
|
+
label: "step two"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
30
|
+
label: "step three"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
32
|
+
container = _render2.container;
|
|
33
|
+
|
|
34
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('Steps', function () {
|
|
38
|
+
it('should change the active step', function () {
|
|
39
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
40
|
+
activeStep: 0
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
42
|
+
label: "step one"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
44
|
+
label: "step two"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
46
|
+
label: "step three"
|
|
47
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
48
|
+
queryByText = _render3.queryByText,
|
|
49
|
+
rerender = _render3.rerender;
|
|
50
|
+
|
|
51
|
+
expect(queryByText('step one content')).toBeTruthy();
|
|
52
|
+
expect(queryByText('step two content')).toBeFalsy();
|
|
53
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
54
|
+
rerender( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
55
|
+
activeStep: 1
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
57
|
+
label: "step one"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
59
|
+
label: "step two"
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
61
|
+
label: "step three"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content")))));
|
|
63
|
+
expect(queryByText('step one content')).toBeFalsy();
|
|
64
|
+
expect(queryByText('step two content')).toBeTruthy();
|
|
65
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import ThemeProvider from '../../Theme';
|
|
4
|
+
import Stepper from '..';
|
|
5
|
+
describe('<Stepper />', function () {
|
|
6
|
+
describe('Snapshots', function () {
|
|
7
|
+
it('should match snapshot with first step active', function () {
|
|
8
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
9
|
+
activeStep: 0
|
|
10
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
11
|
+
label: "step one"
|
|
12
|
+
}, "step one content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
13
|
+
label: "step two"
|
|
14
|
+
}, "step two content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
15
|
+
label: "step three"
|
|
16
|
+
}, "step three content")))),
|
|
17
|
+
container = _render.container;
|
|
18
|
+
|
|
19
|
+
expect(container).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('should match snapshot with second step active', function () {
|
|
22
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
23
|
+
activeStep: 1
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
25
|
+
label: "step one"
|
|
26
|
+
}, "step one content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
27
|
+
label: "step two"
|
|
28
|
+
}, "step two content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
29
|
+
label: "step three"
|
|
30
|
+
}, "step three content")))),
|
|
31
|
+
container = _render2.container;
|
|
32
|
+
|
|
33
|
+
expect(container).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('Steps', function () {
|
|
37
|
+
it('should change the active step', function () {
|
|
38
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
39
|
+
activeStep: 0
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
41
|
+
label: "step one"
|
|
42
|
+
}, "step one content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
43
|
+
label: "step two"
|
|
44
|
+
}, "step two content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
45
|
+
label: "step three"
|
|
46
|
+
}, "step three content")))),
|
|
47
|
+
queryByText = _render3.queryByText,
|
|
48
|
+
rerender = _render3.rerender;
|
|
49
|
+
|
|
50
|
+
expect(queryByText('step one content')).toBeTruthy();
|
|
51
|
+
expect(queryByText('step two content')).toBeFalsy();
|
|
52
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
53
|
+
rerender( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
54
|
+
activeStep: 1
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
56
|
+
label: "step one"
|
|
57
|
+
}, "step one content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
58
|
+
label: "step two"
|
|
59
|
+
}, "step two content"), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
60
|
+
label: "step three"
|
|
61
|
+
}, "step three content"))));
|
|
62
|
+
expect(queryByText('step one content')).toBeFalsy();
|
|
63
|
+
expect(queryByText('step two content')).toBeTruthy();
|
|
64
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var _excluded = ["children", "icon", "theme", "small"];
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
|
|
5
|
+
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); }
|
|
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 from 'react';
|
|
12
|
+
import styled, { withTheme } from 'styled-components';
|
|
13
|
+
import { func, oneOf, node, bool } from 'prop-types';
|
|
14
|
+
import { margins } from '@gympass/yoga-system';
|
|
15
|
+
import { StyledTag, StyledText } from './Tag';
|
|
16
|
+
import Icon from '../../Icon';
|
|
17
|
+
var Informative = styled(StyledTag)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n\n ", "\n"])), function (_ref) {
|
|
18
|
+
var variant = _ref.variant,
|
|
19
|
+
_ref$theme$yoga = _ref.theme.yoga,
|
|
20
|
+
_ref$theme$yoga$color = _ref$theme$yoga.colors,
|
|
21
|
+
text = _ref$theme$yoga$color.text,
|
|
22
|
+
_ref$theme$yoga$color2 = _ref$theme$yoga$color.feedback[variant],
|
|
23
|
+
color = _ref$theme$yoga$color2 === void 0 ? {
|
|
24
|
+
light: text.secondary
|
|
25
|
+
} : _ref$theme$yoga$color2,
|
|
26
|
+
tag = _ref$theme$yoga.components.tag;
|
|
27
|
+
return "\n background-color: " + color.light + ";\n border-color: " + color.light + ";\n border-radius: " + tag.border.radius + "px;\n ";
|
|
28
|
+
}, margins);
|
|
29
|
+
var Wrapper = styled.View(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n justify-content: center;\n align-items: center;\n"])));
|
|
30
|
+
var StyledTextInformative = styled(StyledText)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref2) {
|
|
31
|
+
var _ref2$theme$yoga = _ref2.theme.yoga,
|
|
32
|
+
text = _ref2$theme$yoga.colors.text,
|
|
33
|
+
tag = _ref2$theme$yoga.components.tag;
|
|
34
|
+
return "\n color: " + text.primary + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n font-weight: " + tag.font.weight + ";\n ";
|
|
35
|
+
});
|
|
36
|
+
/** Tags should be keywords to categorize or organize an item. */
|
|
37
|
+
|
|
38
|
+
var TagInformative = function TagInformative(_ref3) {
|
|
39
|
+
var children = _ref3.children,
|
|
40
|
+
icon = _ref3.icon,
|
|
41
|
+
_ref3$theme$yoga = _ref3.theme.yoga,
|
|
42
|
+
text = _ref3$theme$yoga.colors.text,
|
|
43
|
+
tag = _ref3$theme$yoga.components.tag,
|
|
44
|
+
small = _ref3.small,
|
|
45
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(Informative, _extends({
|
|
48
|
+
small: small
|
|
49
|
+
}, props), /*#__PURE__*/React.createElement(Wrapper, null, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
50
|
+
as: icon,
|
|
51
|
+
size: small ? tag.icon.size.small : tag.icon.size["default"],
|
|
52
|
+
fill: text.primary,
|
|
53
|
+
marginRight: tag.icon.margin.right
|
|
54
|
+
}), /*#__PURE__*/React.createElement(StyledTextInformative, null, children)));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
TagInformative.propTypes = {
|
|
58
|
+
/** style the tag following the theme (success, informative, attention) */
|
|
59
|
+
variant: oneOf(['success', 'informative', 'attention']).isRequired,
|
|
60
|
+
icon: func,
|
|
61
|
+
children: node.isRequired,
|
|
62
|
+
|
|
63
|
+
/** Can send small to use this variant */
|
|
64
|
+
small: bool
|
|
65
|
+
};
|
|
66
|
+
TagInformative.defaultProps = {
|
|
67
|
+
icon: undefined,
|
|
68
|
+
small: false
|
|
69
|
+
};
|
|
70
|
+
TagInformative.displayName = 'Tag.Informative';
|
|
71
|
+
export default withTheme(TagInformative);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var _excluded = ["variant"],
|
|
2
|
+
_excluded2 = ["children", "variant", "small"];
|
|
3
|
+
|
|
4
|
+
var _templateObject, _templateObject2;
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import styled from 'styled-components';
|
|
14
|
+
import { oneOf, node, bool } from 'prop-types';
|
|
15
|
+
import { margins } from '@gympass/yoga-system';
|
|
16
|
+
import Text from '../../Text';
|
|
17
|
+
export var StyledTag = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n justify-content: center;\n align-items: center;\n\n ", "\n\n ", "\n"])), function (_ref) {
|
|
18
|
+
var variant = _ref.variant,
|
|
19
|
+
small = _ref.small,
|
|
20
|
+
_ref$theme$yoga = _ref.theme.yoga,
|
|
21
|
+
_ref$theme$yoga$color = _ref$theme$yoga.colors,
|
|
22
|
+
elements = _ref$theme$yoga$color.elements,
|
|
23
|
+
_ref$theme$yoga$color2 = _ref$theme$yoga$color.feedback[variant],
|
|
24
|
+
borderColor = _ref$theme$yoga$color2 === void 0 ? {
|
|
25
|
+
dark: elements.selectionAndIcons
|
|
26
|
+
} : _ref$theme$yoga$color2,
|
|
27
|
+
tag = _ref$theme$yoga.components.tag;
|
|
28
|
+
return "\n width: auto;\n " + (small ? "\n padding:\n " + tag.padding.small.top + "\n " + tag.padding.small.right + "px\n " + tag.padding.small.bottom + "\n " + tag.padding.small.left + "px;\n " : "\n padding:\n " + tag.padding["default"].top + "px\n " + tag.padding["default"].right + "px\n " + tag.padding["default"].bottom + "px\n " + tag.padding["default"].left + "px;\n ") + "\n\n border-radius: " + tag.border.radius + "px;\n border-width: " + tag.border.width + "px;\n border-color: " + borderColor.dark + ";\n ";
|
|
29
|
+
}, margins);
|
|
30
|
+
export var StyledText = styled(function (_ref2) {
|
|
31
|
+
var variant = _ref2.variant,
|
|
32
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
33
|
+
|
|
34
|
+
return /*#__PURE__*/React.createElement(Text.Medium, rest);
|
|
35
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref3) {
|
|
36
|
+
var variant = _ref3.variant,
|
|
37
|
+
_ref3$theme$yoga = _ref3.theme.yoga,
|
|
38
|
+
_ref3$theme$yoga$colo = _ref3$theme$yoga.colors,
|
|
39
|
+
text = _ref3$theme$yoga$colo.text,
|
|
40
|
+
_ref3$theme$yoga$colo2 = _ref3$theme$yoga$colo.feedback[variant],
|
|
41
|
+
color = _ref3$theme$yoga$colo2 === void 0 ? {
|
|
42
|
+
dark: text.secondary
|
|
43
|
+
} : _ref3$theme$yoga$colo2,
|
|
44
|
+
tag = _ref3$theme$yoga.components.tag;
|
|
45
|
+
return "\n color: " + color.dark + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n ";
|
|
46
|
+
});
|
|
47
|
+
/** Use Tag component when you want to categorize your content */
|
|
48
|
+
|
|
49
|
+
var Tag = function Tag(_ref4) {
|
|
50
|
+
var children = _ref4.children,
|
|
51
|
+
variant = _ref4.variant,
|
|
52
|
+
small = _ref4.small,
|
|
53
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
54
|
+
|
|
55
|
+
return /*#__PURE__*/React.createElement(StyledTag, _extends({
|
|
56
|
+
variant: variant,
|
|
57
|
+
small: small
|
|
58
|
+
}, props), /*#__PURE__*/React.createElement(StyledText, {
|
|
59
|
+
variant: variant
|
|
60
|
+
}, children));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Tag.propTypes = {
|
|
64
|
+
/** style the tag following the theme (success, informative, attention) */
|
|
65
|
+
variant: oneOf(['', 'success', 'informative', 'attention']),
|
|
66
|
+
|
|
67
|
+
/** Can send small to use this variant */
|
|
68
|
+
small: bool,
|
|
69
|
+
children: node.isRequired
|
|
70
|
+
};
|
|
71
|
+
Tag.defaultProps = {
|
|
72
|
+
variant: '',
|
|
73
|
+
small: false
|
|
74
|
+
};
|
|
75
|
+
export default Tag;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { Building } from '@gympass/yoga-icons';
|
|
4
|
+
import { ThemeProvider, Tag } from '../..';
|
|
5
|
+
describe('<Tag />', function () {
|
|
6
|
+
it('should match snapshot', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag, null, "default"))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
it('should match snapshot with custom icon and informative type', function () {
|
|
13
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
14
|
+
variant: "success",
|
|
15
|
+
icon: Building
|
|
16
|
+
}, "success with custom icon"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
17
|
+
variant: "success",
|
|
18
|
+
icon: Building,
|
|
19
|
+
small: true
|
|
20
|
+
}, "success with custom icon"))),
|
|
21
|
+
container = _render2.container;
|
|
22
|
+
|
|
23
|
+
expect(container).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('should match snapshot with without icon and informative type', function () {
|
|
26
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
27
|
+
variant: "success"
|
|
28
|
+
}, "success without icon"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
29
|
+
variant: "success",
|
|
30
|
+
small: true
|
|
31
|
+
}, "success without icon"))),
|
|
32
|
+
container = _render3.container;
|
|
33
|
+
|
|
34
|
+
expect(container).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
it('should match snapshot with variant prop', function () {
|
|
37
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag, {
|
|
38
|
+
variant: "success"
|
|
39
|
+
}, "success"), /*#__PURE__*/React.createElement(Tag, {
|
|
40
|
+
variant: "informative"
|
|
41
|
+
}, "informative"), /*#__PURE__*/React.createElement(Tag, {
|
|
42
|
+
variant: "attention"
|
|
43
|
+
}, "attention"), /*#__PURE__*/React.createElement(Tag, {
|
|
44
|
+
variant: "attention",
|
|
45
|
+
small: true
|
|
46
|
+
}, "attention small"))),
|
|
47
|
+
container = _render4.container;
|
|
48
|
+
|
|
49
|
+
expect(container).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
it('should match snapshot with variant prop and informative type', function () {
|
|
52
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
53
|
+
variant: "success"
|
|
54
|
+
}, "success"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
55
|
+
variant: "informative"
|
|
56
|
+
}, "informative"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
57
|
+
variant: "attention"
|
|
58
|
+
}, "attention"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
59
|
+
variant: "attention",
|
|
60
|
+
small: true
|
|
61
|
+
}, "attention small"))),
|
|
62
|
+
container = _render5.container;
|
|
63
|
+
|
|
64
|
+
expect(container).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
it('should match snapshot with variant and margin prop ', function () {
|
|
67
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag, {
|
|
68
|
+
variant: "success"
|
|
69
|
+
}, "success"), /*#__PURE__*/React.createElement(Tag, {
|
|
70
|
+
mv: "medium",
|
|
71
|
+
variant: "informative"
|
|
72
|
+
}, "informative"), /*#__PURE__*/React.createElement(Tag, {
|
|
73
|
+
variant: "attention"
|
|
74
|
+
}, "attention"))),
|
|
75
|
+
container = _render6.container;
|
|
76
|
+
|
|
77
|
+
expect(container).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
it('should match snapshot with variant prop and informative type with margin prop', function () {
|
|
80
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
81
|
+
variant: "success"
|
|
82
|
+
}, "success"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
83
|
+
mv: "medium",
|
|
84
|
+
variant: "informative"
|
|
85
|
+
}, "informative"), /*#__PURE__*/React.createElement(Tag.Informative, {
|
|
86
|
+
variant: "attention"
|
|
87
|
+
}, "attention"))),
|
|
88
|
+
container = _render7.container;
|
|
89
|
+
|
|
90
|
+
expect(container).toMatchSnapshot();
|
|
91
|
+
});
|
|
92
|
+
});
|