@gympass/yoga 7.66.0 → 7.67.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/Dialog/web/Dialog.js +12 -7
- package/cjs/Drawer/web/Drawer.js +5 -1
- package/cjs/Feedback/web/Feedback.js +16 -10
- package/esm/Accordion/web/Accordion.test.js +19 -0
- package/esm/ActionRequirement/index.native.js +2 -0
- package/esm/ActionRequirement/native/ActionRequirement.js +48 -0
- package/esm/ActionRequirement/native/ActionRequirement.test.js +45 -0
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +25 -0
- package/esm/ActionRequirement/native/index.js +6 -0
- package/esm/ActionRequirement/web/ActionRequirement.test.js +36 -0
- package/esm/AutoComplete/web/AutoComplete.test.js +139 -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 +48 -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 +772 -0
- 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 +22 -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 +51 -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 +34 -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/PlanCard.test.js +94 -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 +143 -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/Datepicker/web/Datepicker.test.js +247 -0
- package/esm/Dialog/web/Dialog.js +13 -8
- package/esm/Dialog/web/Dialog.test.js +62 -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/Drawer/web/Drawer.js +6 -2
- package/esm/Drawer/web/Drawer.test.js +33 -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.js +17 -11
- package/esm/Feedback/web/Feedback.test.js +94 -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 +38 -0
- package/esm/Heading/web/Heading.test.js +58 -0
- 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/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/Phone.test.js +95 -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/Menu/web/Menu.test.js +115 -0
- package/esm/Popover/web/Popover.test.js +19 -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 +96 -0
- package/esm/RadioGroup/native/Radio/Radio.js +88 -0
- package/esm/RadioGroup/native/Radio/Radio.test.js +112 -0
- package/esm/RadioGroup/native/RadioGroup.js +66 -0
- package/esm/RadioGroup/native/RadioGroup.test.js +50 -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/Skeleton/index.native.js +2 -0
- package/esm/Skeleton/native/Skeleton.js +94 -0
- package/esm/Skeleton/native/Skeleton.test.js +78 -0
- package/esm/Skeleton/native/index.js +2 -0
- package/esm/Skeleton/web/Skeleton.test.js +77 -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 +122 -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 +118 -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 +70 -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 +72 -0
- package/esm/Tag/native/Tag.js +75 -0
- package/esm/Tag/native/Tag.test.js +94 -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/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 +26 -0
- package/esm/shared/index.native.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import { Booking } from '@gympass/yoga-icons';
|
|
4
|
+
import ThemeProvider from '../../Theme';
|
|
5
|
+
import Button from '..';
|
|
6
|
+
describe('<Button />', function () {
|
|
7
|
+
describe('Snapshots', function () {
|
|
8
|
+
describe('primary buttons', function () {
|
|
9
|
+
describe('Without props', function () {
|
|
10
|
+
it('should match snapshot with default Button', function () {
|
|
11
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, null))),
|
|
12
|
+
toJSON = _render.toJSON;
|
|
13
|
+
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
it('should match snapshot with text Button', function () {
|
|
17
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, null))),
|
|
18
|
+
toJSON = _render2.toJSON;
|
|
19
|
+
|
|
20
|
+
expect(toJSON()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
it('should match snapshot with link Button', function () {
|
|
23
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Link, null))),
|
|
24
|
+
toJSON = _render3.toJSON;
|
|
25
|
+
|
|
26
|
+
expect(toJSON()).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
29
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
30
|
+
icon: Booking
|
|
31
|
+
}))),
|
|
32
|
+
toJSON = _render4.toJSON;
|
|
33
|
+
|
|
34
|
+
expect(toJSON()).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
37
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
38
|
+
icon: Booking
|
|
39
|
+
}))),
|
|
40
|
+
toJSON = _render5.toJSON;
|
|
41
|
+
|
|
42
|
+
expect(toJSON()).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('With inverted prop', function () {
|
|
46
|
+
it('should match snapshot with default Button', function () {
|
|
47
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
48
|
+
inverted: true
|
|
49
|
+
}))),
|
|
50
|
+
toJSON = _render6.toJSON;
|
|
51
|
+
|
|
52
|
+
expect(toJSON()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
it('should match snapshot with text Button', function () {
|
|
55
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
56
|
+
inverted: true
|
|
57
|
+
}))),
|
|
58
|
+
toJSON = _render7.toJSON;
|
|
59
|
+
|
|
60
|
+
expect(toJSON()).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
63
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
64
|
+
inverted: true,
|
|
65
|
+
icon: Booking
|
|
66
|
+
}))),
|
|
67
|
+
toJSON = _render8.toJSON;
|
|
68
|
+
|
|
69
|
+
expect(toJSON()).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
72
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
73
|
+
inverted: true,
|
|
74
|
+
icon: Booking
|
|
75
|
+
}))),
|
|
76
|
+
toJSON = _render9.toJSON;
|
|
77
|
+
|
|
78
|
+
expect(toJSON()).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
it('should match snapshot with icon Button', function () {
|
|
81
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
82
|
+
icon: Booking,
|
|
83
|
+
inverted: true
|
|
84
|
+
}))),
|
|
85
|
+
toJSON = _render10.toJSON;
|
|
86
|
+
|
|
87
|
+
expect(toJSON()).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('With small prop', function () {
|
|
91
|
+
it('should match snapshot with default Button', function () {
|
|
92
|
+
var _render11 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
93
|
+
small: true
|
|
94
|
+
}))),
|
|
95
|
+
toJSON = _render11.toJSON;
|
|
96
|
+
|
|
97
|
+
expect(toJSON()).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
it('should match snapshot with text Button', function () {
|
|
100
|
+
var _render12 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
101
|
+
small: true
|
|
102
|
+
}))),
|
|
103
|
+
toJSON = _render12.toJSON;
|
|
104
|
+
|
|
105
|
+
expect(toJSON()).toMatchSnapshot();
|
|
106
|
+
});
|
|
107
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
108
|
+
var _render13 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
109
|
+
small: true,
|
|
110
|
+
icon: Booking
|
|
111
|
+
}))),
|
|
112
|
+
toJSON = _render13.toJSON;
|
|
113
|
+
|
|
114
|
+
expect(toJSON()).toMatchSnapshot();
|
|
115
|
+
});
|
|
116
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
117
|
+
var _render14 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
118
|
+
small: true,
|
|
119
|
+
icon: Booking
|
|
120
|
+
}))),
|
|
121
|
+
toJSON = _render14.toJSON;
|
|
122
|
+
|
|
123
|
+
expect(toJSON()).toMatchSnapshot();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('With full prop', function () {
|
|
127
|
+
it('should match snapshot with default Button', function () {
|
|
128
|
+
var _render15 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
129
|
+
full: true
|
|
130
|
+
}))),
|
|
131
|
+
toJSON = _render15.toJSON;
|
|
132
|
+
|
|
133
|
+
expect(toJSON()).toMatchSnapshot();
|
|
134
|
+
});
|
|
135
|
+
it('should match snapshot with text Button', function () {
|
|
136
|
+
var _render16 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
137
|
+
full: true
|
|
138
|
+
}))),
|
|
139
|
+
toJSON = _render16.toJSON;
|
|
140
|
+
|
|
141
|
+
expect(toJSON()).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
144
|
+
var _render17 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
145
|
+
full: true,
|
|
146
|
+
icon: Booking
|
|
147
|
+
}))),
|
|
148
|
+
toJSON = _render17.toJSON;
|
|
149
|
+
|
|
150
|
+
expect(toJSON()).toMatchSnapshot();
|
|
151
|
+
});
|
|
152
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
153
|
+
var _render18 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
154
|
+
full: true,
|
|
155
|
+
icon: Booking
|
|
156
|
+
}))),
|
|
157
|
+
toJSON = _render18.toJSON;
|
|
158
|
+
|
|
159
|
+
expect(toJSON()).toMatchSnapshot();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe('With large prop', function () {
|
|
163
|
+
it('should match snapshot icon Button with large prop', function () {
|
|
164
|
+
var _render19 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
165
|
+
icon: Booking,
|
|
166
|
+
large: true
|
|
167
|
+
}))),
|
|
168
|
+
toJSON = _render19.toJSON;
|
|
169
|
+
|
|
170
|
+
expect(toJSON()).toMatchSnapshot();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('secondary buttons', function () {
|
|
175
|
+
describe('Without props', function () {
|
|
176
|
+
it('should match snapshot with default Button', function () {
|
|
177
|
+
var _render20 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
178
|
+
secondary: true
|
|
179
|
+
}))),
|
|
180
|
+
toJSON = _render20.toJSON;
|
|
181
|
+
|
|
182
|
+
expect(toJSON()).toMatchSnapshot();
|
|
183
|
+
});
|
|
184
|
+
it('should match snapshot with text Button', function () {
|
|
185
|
+
var _render21 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
186
|
+
secondary: true
|
|
187
|
+
}))),
|
|
188
|
+
toJSON = _render21.toJSON;
|
|
189
|
+
|
|
190
|
+
expect(toJSON()).toMatchSnapshot();
|
|
191
|
+
});
|
|
192
|
+
it('should match snapshot with link Button', function () {
|
|
193
|
+
var _render22 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Link, {
|
|
194
|
+
secondary: true
|
|
195
|
+
}))),
|
|
196
|
+
toJSON = _render22.toJSON;
|
|
197
|
+
|
|
198
|
+
expect(toJSON()).toMatchSnapshot();
|
|
199
|
+
});
|
|
200
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
201
|
+
var _render23 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
202
|
+
icon: Booking,
|
|
203
|
+
secondary: true
|
|
204
|
+
}))),
|
|
205
|
+
toJSON = _render23.toJSON;
|
|
206
|
+
|
|
207
|
+
expect(toJSON()).toMatchSnapshot();
|
|
208
|
+
});
|
|
209
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
210
|
+
var _render24 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
211
|
+
icon: Booking,
|
|
212
|
+
secondary: true
|
|
213
|
+
}))),
|
|
214
|
+
toJSON = _render24.toJSON;
|
|
215
|
+
|
|
216
|
+
expect(toJSON()).toMatchSnapshot();
|
|
217
|
+
});
|
|
218
|
+
it('should match snapshot with icon Button with Icon', function () {
|
|
219
|
+
var _render25 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
220
|
+
icon: Booking,
|
|
221
|
+
secondary: true
|
|
222
|
+
}))),
|
|
223
|
+
toJSON = _render25.toJSON;
|
|
224
|
+
|
|
225
|
+
expect(toJSON()).toMatchSnapshot();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('With inverted prop', function () {
|
|
229
|
+
it('should match snapshot with default Button', function () {
|
|
230
|
+
var _render26 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
231
|
+
inverted: true,
|
|
232
|
+
secondary: true
|
|
233
|
+
}))),
|
|
234
|
+
toJSON = _render26.toJSON;
|
|
235
|
+
|
|
236
|
+
expect(toJSON()).toMatchSnapshot();
|
|
237
|
+
});
|
|
238
|
+
it('should match snapshot with text Button', function () {
|
|
239
|
+
var _render27 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
240
|
+
inverted: true,
|
|
241
|
+
secondary: true
|
|
242
|
+
}))),
|
|
243
|
+
toJSON = _render27.toJSON;
|
|
244
|
+
|
|
245
|
+
expect(toJSON()).toMatchSnapshot();
|
|
246
|
+
});
|
|
247
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
248
|
+
var _render28 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
249
|
+
inverted: true,
|
|
250
|
+
icon: Booking,
|
|
251
|
+
secondary: true
|
|
252
|
+
}))),
|
|
253
|
+
toJSON = _render28.toJSON;
|
|
254
|
+
|
|
255
|
+
expect(toJSON()).toMatchSnapshot();
|
|
256
|
+
});
|
|
257
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
258
|
+
var _render29 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
259
|
+
inverted: true,
|
|
260
|
+
icon: Booking,
|
|
261
|
+
secondary: true
|
|
262
|
+
}))),
|
|
263
|
+
toJSON = _render29.toJSON;
|
|
264
|
+
|
|
265
|
+
expect(toJSON()).toMatchSnapshot();
|
|
266
|
+
});
|
|
267
|
+
it('should match snapshot with icon Button with Icon', function () {
|
|
268
|
+
var _render30 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
269
|
+
inverted: true,
|
|
270
|
+
icon: Booking,
|
|
271
|
+
secondary: true
|
|
272
|
+
}))),
|
|
273
|
+
toJSON = _render30.toJSON;
|
|
274
|
+
|
|
275
|
+
expect(toJSON()).toMatchSnapshot();
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
describe('With small prop', function () {
|
|
279
|
+
it('should match snapshot with default Button', function () {
|
|
280
|
+
var _render31 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
281
|
+
small: true,
|
|
282
|
+
secondary: true
|
|
283
|
+
}))),
|
|
284
|
+
toJSON = _render31.toJSON;
|
|
285
|
+
|
|
286
|
+
expect(toJSON()).toMatchSnapshot();
|
|
287
|
+
});
|
|
288
|
+
it('should match snapshot with text Button', function () {
|
|
289
|
+
var _render32 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
290
|
+
small: true,
|
|
291
|
+
secondary: true
|
|
292
|
+
}))),
|
|
293
|
+
toJSON = _render32.toJSON;
|
|
294
|
+
|
|
295
|
+
expect(toJSON()).toMatchSnapshot();
|
|
296
|
+
});
|
|
297
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
298
|
+
var _render33 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
299
|
+
small: true,
|
|
300
|
+
icon: Booking,
|
|
301
|
+
secondary: true
|
|
302
|
+
}))),
|
|
303
|
+
toJSON = _render33.toJSON;
|
|
304
|
+
|
|
305
|
+
expect(toJSON()).toMatchSnapshot();
|
|
306
|
+
});
|
|
307
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
308
|
+
var _render34 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
309
|
+
small: true,
|
|
310
|
+
icon: Booking,
|
|
311
|
+
secondary: true
|
|
312
|
+
}))),
|
|
313
|
+
toJSON = _render34.toJSON;
|
|
314
|
+
|
|
315
|
+
expect(toJSON()).toMatchSnapshot();
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
describe('With full prop', function () {
|
|
319
|
+
it('should match snapshot with default Button', function () {
|
|
320
|
+
var _render35 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
321
|
+
full: true,
|
|
322
|
+
secondary: true
|
|
323
|
+
}))),
|
|
324
|
+
toJSON = _render35.toJSON;
|
|
325
|
+
|
|
326
|
+
expect(toJSON()).toMatchSnapshot();
|
|
327
|
+
});
|
|
328
|
+
it('should match snapshot with text Button', function () {
|
|
329
|
+
var _render36 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
330
|
+
full: true,
|
|
331
|
+
secondary: true
|
|
332
|
+
}))),
|
|
333
|
+
toJSON = _render36.toJSON;
|
|
334
|
+
|
|
335
|
+
expect(toJSON()).toMatchSnapshot();
|
|
336
|
+
});
|
|
337
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
338
|
+
var _render37 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
339
|
+
full: true,
|
|
340
|
+
icon: Booking,
|
|
341
|
+
secondary: true
|
|
342
|
+
}))),
|
|
343
|
+
toJSON = _render37.toJSON;
|
|
344
|
+
|
|
345
|
+
expect(toJSON()).toMatchSnapshot();
|
|
346
|
+
});
|
|
347
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
348
|
+
var _render38 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
349
|
+
full: true,
|
|
350
|
+
icon: Booking,
|
|
351
|
+
secondary: true
|
|
352
|
+
}))),
|
|
353
|
+
toJSON = _render38.toJSON;
|
|
354
|
+
|
|
355
|
+
expect(toJSON()).toMatchSnapshot();
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
describe('With large prop', function () {
|
|
359
|
+
it('should match snapshot icon Button with large prop', function () {
|
|
360
|
+
var _render39 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
361
|
+
large: true,
|
|
362
|
+
icon: Booking,
|
|
363
|
+
secondary: true
|
|
364
|
+
}))),
|
|
365
|
+
toJSON = _render39.toJSON;
|
|
366
|
+
|
|
367
|
+
expect(toJSON()).toMatchSnapshot();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
describe('disabled buttons', function () {
|
|
372
|
+
describe('With disabled prop', function () {
|
|
373
|
+
it('should match snapshot with default Button', function () {
|
|
374
|
+
var _render40 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
375
|
+
disabled: true
|
|
376
|
+
}))),
|
|
377
|
+
toJSON = _render40.toJSON;
|
|
378
|
+
|
|
379
|
+
expect(toJSON()).toMatchSnapshot();
|
|
380
|
+
});
|
|
381
|
+
it('should match snapshot with text Button', function () {
|
|
382
|
+
var _render41 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
383
|
+
disabled: true
|
|
384
|
+
}))),
|
|
385
|
+
toJSON = _render41.toJSON;
|
|
386
|
+
|
|
387
|
+
expect(toJSON()).toMatchSnapshot();
|
|
388
|
+
});
|
|
389
|
+
it('should match snapshot with link Button', function () {
|
|
390
|
+
var _render42 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Link, {
|
|
391
|
+
disabled: true
|
|
392
|
+
}))),
|
|
393
|
+
toJSON = _render42.toJSON;
|
|
394
|
+
|
|
395
|
+
expect(toJSON()).toMatchSnapshot();
|
|
396
|
+
});
|
|
397
|
+
it('should match snapshot with default Button with Icon', function () {
|
|
398
|
+
var _render43 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
399
|
+
disabled: true,
|
|
400
|
+
icon: Booking
|
|
401
|
+
}))),
|
|
402
|
+
toJSON = _render43.toJSON;
|
|
403
|
+
|
|
404
|
+
expect(toJSON()).toMatchSnapshot();
|
|
405
|
+
});
|
|
406
|
+
it('should match snapshot with text Button with Icon', function () {
|
|
407
|
+
var _render44 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
408
|
+
disabled: true,
|
|
409
|
+
icon: Booking
|
|
410
|
+
}))),
|
|
411
|
+
toJSON = _render44.toJSON;
|
|
412
|
+
|
|
413
|
+
expect(toJSON()).toMatchSnapshot();
|
|
414
|
+
});
|
|
415
|
+
it('should match snapshot with icon Button with Icon', function () {
|
|
416
|
+
var _render45 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
417
|
+
disabled: true,
|
|
418
|
+
icon: Booking
|
|
419
|
+
}))),
|
|
420
|
+
toJSON = _render45.toJSON;
|
|
421
|
+
|
|
422
|
+
expect(toJSON()).toMatchSnapshot();
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
describe('onPress prop', function () {
|
|
428
|
+
it('should call onPress function when click on Button', function () {
|
|
429
|
+
var onPressMock = jest.fn();
|
|
430
|
+
|
|
431
|
+
var _render46 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
432
|
+
onPress: onPressMock
|
|
433
|
+
}, "Button"))),
|
|
434
|
+
getByText = _render46.getByText;
|
|
435
|
+
|
|
436
|
+
fireEvent.press(getByText('Button'));
|
|
437
|
+
expect(onPressMock).toHaveBeenCalled();
|
|
438
|
+
});
|
|
439
|
+
it('should call onPress function when press on Button.Text', function () {
|
|
440
|
+
var onPressMock = jest.fn();
|
|
441
|
+
|
|
442
|
+
var _render47 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Text, {
|
|
443
|
+
onPress: onPressMock
|
|
444
|
+
}, "Button.Text"))),
|
|
445
|
+
getByText = _render47.getByText;
|
|
446
|
+
|
|
447
|
+
fireEvent.press(getByText('Button.Text'));
|
|
448
|
+
expect(onPressMock).toHaveBeenCalled();
|
|
449
|
+
});
|
|
450
|
+
it('should call onPress function when press on Button.Icon', function () {
|
|
451
|
+
var onPressMock = jest.fn();
|
|
452
|
+
|
|
453
|
+
var _render48 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button.Icon, {
|
|
454
|
+
onPress: onPressMock,
|
|
455
|
+
icon: Booking
|
|
456
|
+
}))),
|
|
457
|
+
getByRole = _render48.getByRole;
|
|
458
|
+
|
|
459
|
+
fireEvent.press(getByRole('button'));
|
|
460
|
+
expect(onPressMock).toHaveBeenCalled();
|
|
461
|
+
});
|
|
462
|
+
it('should not call onPress function when press on Button disabled', function () {
|
|
463
|
+
var onPressMock = jest.fn();
|
|
464
|
+
|
|
465
|
+
var _render49 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
466
|
+
disabled: true,
|
|
467
|
+
onPress: onPressMock
|
|
468
|
+
}, "Button"))),
|
|
469
|
+
getByText = _render49.getByText;
|
|
470
|
+
|
|
471
|
+
fireEvent.press(getByText('Button'));
|
|
472
|
+
expect(onPressMock).not.toHaveBeenCalled();
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var _excluded = ["icon", "theme", "small", "pressed", "disabled", "inverted", "secondary"];
|
|
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 styled, { withTheme } from 'styled-components';
|
|
13
|
+
import { node, oneOfType, func, bool } from 'prop-types';
|
|
14
|
+
import Icon from '../../Icon';
|
|
15
|
+
import withTouchable from './withTouchable';
|
|
16
|
+
var ButtonContainer = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n ", "\n"])), function (_ref) {
|
|
17
|
+
var small = _ref.small,
|
|
18
|
+
secondary = _ref.secondary,
|
|
19
|
+
button = _ref.theme.yoga.components.button,
|
|
20
|
+
disabled = _ref.disabled,
|
|
21
|
+
inverted = _ref.inverted,
|
|
22
|
+
pressed = _ref.pressed;
|
|
23
|
+
var state = secondary ? 'secondary' : 'primary';
|
|
24
|
+
return "\n border-radius: " + button.border.radius + "px;\n\n background-color: " + button.types.contained.backgroundColor[state]["default"] + ";\n\n width: " + (small ? button.height.small : button.height["default"]) + "px;\n height: " + (small ? button.height.small : button.height["default"]) + "px;\n\n " + (!disabled && pressed ? "\n background-color: " + button.types.contained.backgroundColor[state].pressed + ";\n " : '') + "\n\n " + (disabled ? "\n background-color: " + button.types.contained.backgroundColor.disabled + ";\n " : '') + "\n\n " + (inverted && !disabled ? "\n background-color: " + button.types.contained.font["default"].color + ";\n " : '') + "\n ";
|
|
25
|
+
});
|
|
26
|
+
var ButtonIcon = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
27
|
+
var icon = _ref2.icon,
|
|
28
|
+
button = _ref2.theme.yoga.components.button,
|
|
29
|
+
small = _ref2.small,
|
|
30
|
+
pressed = _ref2.pressed,
|
|
31
|
+
disabled = _ref2.disabled,
|
|
32
|
+
inverted = _ref2.inverted,
|
|
33
|
+
secondary = _ref2.secondary,
|
|
34
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
35
|
+
|
|
36
|
+
var state = secondary ? 'secondary' : 'primary';
|
|
37
|
+
var textColor = button.types.contained.font["default"].color;
|
|
38
|
+
|
|
39
|
+
if (disabled) {
|
|
40
|
+
textColor = button.types.contained.font.disabled.color;
|
|
41
|
+
} else if (inverted) {
|
|
42
|
+
textColor = button.types.contained.backgroundColor[state]["default"];
|
|
43
|
+
|
|
44
|
+
if (pressed) {
|
|
45
|
+
textColor = button.types.contained.backgroundColor[state].pressed;
|
|
46
|
+
}
|
|
47
|
+
} else if (pressed) {
|
|
48
|
+
textColor = button.types.contained.font.pressed.color;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return /*#__PURE__*/React.createElement(ButtonContainer, _extends({}, props, {
|
|
52
|
+
ref: ref,
|
|
53
|
+
small: small,
|
|
54
|
+
pressed: pressed,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
inverted: inverted,
|
|
57
|
+
secondary: secondary,
|
|
58
|
+
accessibilityRole: "button"
|
|
59
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
60
|
+
as: icon,
|
|
61
|
+
fill: textColor,
|
|
62
|
+
size: small ? button.icon.size.small : button.icon.size["default"]
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
ButtonIcon.propTypes = {
|
|
66
|
+
small: bool,
|
|
67
|
+
disabled: bool,
|
|
68
|
+
pressed: bool,
|
|
69
|
+
inverted: bool,
|
|
70
|
+
secondary: bool,
|
|
71
|
+
icon: oneOfType([node, func])
|
|
72
|
+
};
|
|
73
|
+
ButtonIcon.defaultProps = {
|
|
74
|
+
small: false,
|
|
75
|
+
disabled: false,
|
|
76
|
+
pressed: false,
|
|
77
|
+
inverted: false,
|
|
78
|
+
secondary: false,
|
|
79
|
+
icon: undefined
|
|
80
|
+
};
|
|
81
|
+
ButtonIcon.displayName = 'Button.Icon';
|
|
82
|
+
export default withTouchable(withTheme(ButtonIcon));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
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
|
+
|
|
5
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
6
|
+
|
|
7
|
+
import React, { forwardRef } from 'react';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { bool } from 'prop-types';
|
|
10
|
+
import { hexToRgb } from '@gympass/yoga-common';
|
|
11
|
+
import withTouchable from './withTouchable';
|
|
12
|
+
import { Label } from './Button';
|
|
13
|
+
var Link = styled(Label)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref) {
|
|
14
|
+
var disabled = _ref.disabled,
|
|
15
|
+
pressed = _ref.pressed,
|
|
16
|
+
secondary = _ref.secondary,
|
|
17
|
+
link = _ref.theme.yoga.components.button.types.link;
|
|
18
|
+
var state = secondary ? 'secondary' : 'primary';
|
|
19
|
+
return "\n color: " + link.font[state].color + ";\n\n " + (disabled ? "color: " + link.font.disabled.color + ";" : '') + "\n " + (!disabled && pressed ? "color: " + hexToRgb(link.font[state].color, 0.75) + ";" : '') + "\n ";
|
|
20
|
+
});
|
|
21
|
+
var ButtonLink = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(Link, _extends({}, props, {
|
|
23
|
+
ref: ref
|
|
24
|
+
}));
|
|
25
|
+
});
|
|
26
|
+
ButtonLink.propTypes = {
|
|
27
|
+
disabled: bool,
|
|
28
|
+
secondary: bool
|
|
29
|
+
};
|
|
30
|
+
ButtonLink.defaultProps = {
|
|
31
|
+
disabled: false,
|
|
32
|
+
secondary: false
|
|
33
|
+
};
|
|
34
|
+
ButtonLink.displayName = 'Button.Link';
|
|
35
|
+
export default withTouchable(ButtonLink);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var _excluded = ["children", "disabled", "pressed", "small", "secondary", "inverted", "icon", "theme"];
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
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 styled, { withTheme } from 'styled-components';
|
|
13
|
+
import { hexToRgb } from '@gympass/yoga-common';
|
|
14
|
+
import withTouchable from './withTouchable';
|
|
15
|
+
import { Label, ButtonContainer } from './Button';
|
|
16
|
+
var LabelText = styled(Label)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref) {
|
|
17
|
+
var color = _ref.color;
|
|
18
|
+
return "color: " + color + ";";
|
|
19
|
+
});
|
|
20
|
+
var ButtonContainerText = styled(ButtonContainer)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref2) {
|
|
21
|
+
var button = _ref2.theme.yoga.components.button;
|
|
22
|
+
return "\n background-color: " + button.types.text.backgroundColor + ";\n ";
|
|
23
|
+
});
|
|
24
|
+
var ButtonText = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
25
|
+
var children = _ref3.children,
|
|
26
|
+
disabled = _ref3.disabled,
|
|
27
|
+
pressed = _ref3.pressed,
|
|
28
|
+
small = _ref3.small,
|
|
29
|
+
secondary = _ref3.secondary,
|
|
30
|
+
inverted = _ref3.inverted,
|
|
31
|
+
Icon = _ref3.icon,
|
|
32
|
+
_ref3$theme$yoga = _ref3.theme.yoga,
|
|
33
|
+
colors = _ref3$theme$yoga.colors,
|
|
34
|
+
button = _ref3$theme$yoga.components.button,
|
|
35
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
36
|
+
|
|
37
|
+
var state = secondary ? 'secondary' : 'primary';
|
|
38
|
+
var textColor = colors[state];
|
|
39
|
+
|
|
40
|
+
if (disabled) {
|
|
41
|
+
textColor = button.types.text.disabled;
|
|
42
|
+
} else if (inverted) {
|
|
43
|
+
textColor = colors.white;
|
|
44
|
+
|
|
45
|
+
if (pressed) {
|
|
46
|
+
textColor = hexToRgb(colors.white, 0.75);
|
|
47
|
+
}
|
|
48
|
+
} else if (pressed) {
|
|
49
|
+
textColor = hexToRgb(colors[state], 0.75);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return /*#__PURE__*/React.createElement(ButtonContainerText, _extends({}, rest, {
|
|
53
|
+
disabled: disabled,
|
|
54
|
+
pressed: pressed,
|
|
55
|
+
small: small,
|
|
56
|
+
ref: ref
|
|
57
|
+
}), Icon && /*#__PURE__*/React.createElement(Icon, {
|
|
58
|
+
width: small ? button.icon.size.small : button.icon.size["default"],
|
|
59
|
+
height: small ? button.icon.size.small : button.icon.size["default"],
|
|
60
|
+
fill: textColor,
|
|
61
|
+
style: {
|
|
62
|
+
marginRight: button.icon.margin.right
|
|
63
|
+
}
|
|
64
|
+
}), /*#__PURE__*/React.createElement(LabelText, {
|
|
65
|
+
disabled: disabled,
|
|
66
|
+
pressed: pressed,
|
|
67
|
+
small: small,
|
|
68
|
+
secondary: secondary,
|
|
69
|
+
color: textColor
|
|
70
|
+
}, children));
|
|
71
|
+
});
|
|
72
|
+
ButtonText.propTypes = ButtonContainer.propTypes;
|
|
73
|
+
ButtonText.defaultProps = ButtonContainer.defaultProps;
|
|
74
|
+
export default withTouchable(withTheme(ButtonText));
|