react95-native-rabbl 0.1.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.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/package.json +154 -0
  4. package/src/assets/fonts/src/ms-sans-serif/MS Sans Serif.ttf +0 -0
  5. package/src/assets/fonts/src/ms-sans-serif/license.txt +4 -0
  6. package/src/assets/fonts/src/ms-sans-serif/readme.txt +26 -0
  7. package/src/assets/fonts/src/ms-sans-serif-bold/MS Sans Serif Bold.ttf +0 -0
  8. package/src/assets/fonts/src/ms-sans-serif-bold/license.txt +4 -0
  9. package/src/assets/fonts/src/ms-sans-serif-bold/readme.txt +26 -0
  10. package/src/components/AppBar/AppBar.spec.tsx +140 -0
  11. package/src/components/AppBar/AppBar.tsx +43 -0
  12. package/src/components/AppBar/AppBarBackAction.tsx +20 -0
  13. package/src/components/AppBar/AppBarContent.tsx +84 -0
  14. package/src/components/AppBar/index.ts +1 -0
  15. package/src/components/Button/Button.spec.tsx +59 -0
  16. package/src/components/Button/Button.tsx +236 -0
  17. package/src/components/Button/index.ts +1 -0
  18. package/src/components/Card/Card.spec.tsx +54 -0
  19. package/src/components/Card/Card.tsx +88 -0
  20. package/src/components/Card/CardContent.tsx +23 -0
  21. package/src/components/Card/index.ts +1 -0
  22. package/src/components/Checkbox/Checkbox.tsx +10 -0
  23. package/src/components/Checkbox/index.ts +1 -0
  24. package/src/components/ColorButton/ColorButton.tsx +69 -0
  25. package/src/components/ColorButton/index.ts +1 -0
  26. package/src/components/ColorPicker/ColorPicker.tsx +109 -0
  27. package/src/components/ColorPicker/index.ts +1 -0
  28. package/src/components/Desktop/Desktop.spec.tsx +32 -0
  29. package/src/components/Desktop/Desktop.tsx +132 -0
  30. package/src/components/Desktop/index.tsx +1 -0
  31. package/src/components/Divider/Divider.spec.tsx +47 -0
  32. package/src/components/Divider/Divider.tsx +52 -0
  33. package/src/components/Divider/index.tsx +1 -0
  34. package/src/components/FAB/FAB.tsx +288 -0
  35. package/src/components/FAB/FABGroup.tsx +385 -0
  36. package/src/components/FAB/index.ts +1 -0
  37. package/src/components/Fieldset/Fieldset.spec.tsx +48 -0
  38. package/src/components/Fieldset/Fieldset.tsx +107 -0
  39. package/src/components/Fieldset/index.ts +1 -0
  40. package/src/components/Hourglass/Hourglass.spec.tsx +24 -0
  41. package/src/components/Hourglass/Hourglass.tsx +43 -0
  42. package/src/components/Hourglass/base64hourglass.ts +3 -0
  43. package/src/components/Hourglass/index.ts +1 -0
  44. package/src/components/Icons/ArrowIcon.tsx +85 -0
  45. package/src/components/Icons/CheckmarkIcon.tsx +55 -0
  46. package/src/components/Icons/ChevronIcon.tsx +93 -0
  47. package/src/components/Icons/CloseIcon.tsx +48 -0
  48. package/src/components/Icons/index.ts +4 -0
  49. package/src/components/Label/Label.tsx +77 -0
  50. package/src/components/Label/index.ts +1 -0
  51. package/src/components/List/List.tsx +3 -0
  52. package/src/components/List/ListAccordion.tsx +154 -0
  53. package/src/components/List/ListItem.tsx +74 -0
  54. package/src/components/List/ListSection.tsx +51 -0
  55. package/src/components/List/index.ts +3 -0
  56. package/src/components/Menu/Menu.tsx +100 -0
  57. package/src/components/Menu/MenuItem.tsx +100 -0
  58. package/src/components/Menu/index.ts +1 -0
  59. package/src/components/NumberInput/NumberInput.spec.tsx +119 -0
  60. package/src/components/NumberInput/NumberInput.tsx +144 -0
  61. package/src/components/NumberInput/index.ts +1 -0
  62. package/src/components/Panel/Panel.spec.tsx +29 -0
  63. package/src/components/Panel/Panel.tsx +75 -0
  64. package/src/components/Panel/index.ts +1 -0
  65. package/src/components/Portal/Portal.tsx +52 -0
  66. package/src/components/Portal/PortalConsumer.tsx +48 -0
  67. package/src/components/Portal/PortalHost.tsx +150 -0
  68. package/src/components/Portal/PortalManager.tsx +57 -0
  69. package/src/components/Portal/index.ts +1 -0
  70. package/src/components/Progress/Progress.tsx +125 -0
  71. package/src/components/Progress/index.ts +1 -0
  72. package/src/components/Radio/Radio.tsx +14 -0
  73. package/src/components/Radio/index.ts +1 -0
  74. package/src/components/ScrollPanel/ScrollPanel.tsx +72 -0
  75. package/src/components/ScrollPanel/index.ts +1 -0
  76. package/src/components/ScrollView/ScrollView.tsx +284 -0
  77. package/src/components/ScrollView/index.ts +1 -0
  78. package/src/components/Select/Select.tsx +229 -0
  79. package/src/components/Select/SelectBase.tsx +119 -0
  80. package/src/components/Select/SelectBox.tsx +66 -0
  81. package/src/components/Select/index.ts +2 -0
  82. package/src/components/Slider/Slider.tsx +301 -0
  83. package/src/components/Slider/index.ts +1 -0
  84. package/src/components/Snackbar/Snackbar.tsx +260 -0
  85. package/src/components/Snackbar/SnackbarContent.tsx +23 -0
  86. package/src/components/Snackbar/index.ts +1 -0
  87. package/src/components/SwitchBase/SwitchBase.tsx +193 -0
  88. package/src/components/SwitchBase/index.ts +1 -0
  89. package/src/components/Tabs/Tabs.tsx +208 -0
  90. package/src/components/Tabs/index.ts +1 -0
  91. package/src/components/TextInput/TextInput.tsx +82 -0
  92. package/src/components/TextInput/index.ts +1 -0
  93. package/src/components/Toolbar/Toolbar.tsx +113 -0
  94. package/src/components/Toolbar/index.ts +1 -0
  95. package/src/components/Typography/Anchor.tsx +38 -0
  96. package/src/components/Typography/Text.spec.tsx +30 -0
  97. package/src/components/Typography/Text.tsx +55 -0
  98. package/src/components/Typography/Title.tsx +58 -0
  99. package/src/components/Typography/index.ts +3 -0
  100. package/src/components/Window/Window.tsx +132 -0
  101. package/src/components/Window/index.ts +1 -0
  102. package/src/core/Provider.tsx +52 -0
  103. package/src/core/theming.tsx +8 -0
  104. package/src/hooks/useAsyncReference.ts +22 -0
  105. package/src/hooks/useControlledOrUncontrolled.ts +23 -0
  106. package/src/index.ts +38 -0
  107. package/src/styles/shadow.tsx +36 -0
  108. package/src/styles/styleElements.tsx +105 -0
  109. package/src/styles/styles.ts +129 -0
  110. package/src/styles/themes/aiee.ts +36 -0
  111. package/src/styles/themes/ash.ts +35 -0
  112. package/src/styles/themes/azureOrange.ts +33 -0
  113. package/src/styles/themes/bee.ts +33 -0
  114. package/src/styles/themes/blackAndWhite.ts +33 -0
  115. package/src/styles/themes/blue.ts +36 -0
  116. package/src/styles/themes/brick.ts +33 -0
  117. package/src/styles/themes/candy.ts +33 -0
  118. package/src/styles/themes/cherry.ts +36 -0
  119. package/src/styles/themes/coldGray.ts +34 -0
  120. package/src/styles/themes/counterStrike.ts +33 -0
  121. package/src/styles/themes/darkTeal.ts +36 -0
  122. package/src/styles/themes/eggplant.ts +33 -0
  123. package/src/styles/themes/fxDev.ts +36 -0
  124. package/src/styles/themes/highContrast.ts +33 -0
  125. package/src/styles/themes/hotChocolate.ts +36 -0
  126. package/src/styles/themes/index.ts +103 -0
  127. package/src/styles/themes/lilac.ts +33 -0
  128. package/src/styles/themes/lilacRoseDark.ts +34 -0
  129. package/src/styles/themes/maple.ts +33 -0
  130. package/src/styles/themes/marine.ts +33 -0
  131. package/src/styles/themes/matrix.ts +33 -0
  132. package/src/styles/themes/millenium.ts +33 -0
  133. package/src/styles/themes/modernDark.ts +33 -0
  134. package/src/styles/themes/molecule.ts +33 -0
  135. package/src/styles/themes/monochrome.ts +0 -0
  136. package/src/styles/themes/ninjaTurtles.ts +33 -0
  137. package/src/styles/themes/olive.ts +33 -0
  138. package/src/styles/themes/original.ts +33 -0
  139. package/src/styles/themes/pamelaAnderson.ts +33 -0
  140. package/src/styles/themes/plum.ts +33 -0
  141. package/src/styles/themes/polarized.ts +36 -0
  142. package/src/styles/themes/powerShell.ts +36 -0
  143. package/src/styles/themes/rainyDay.ts +33 -0
  144. package/src/styles/themes/raspberry.ts +36 -0
  145. package/src/styles/themes/redWine.ts +36 -0
  146. package/src/styles/themes/rose.ts +33 -0
  147. package/src/styles/themes/seawater.ts +36 -0
  148. package/src/styles/themes/slate.ts +33 -0
  149. package/src/styles/themes/solarizedDark.ts +36 -0
  150. package/src/styles/themes/solarizedLight.ts +36 -0
  151. package/src/styles/themes/spruce.ts +33 -0
  152. package/src/styles/themes/stormClouds.ts +36 -0
  153. package/src/styles/themes/theSixtiesUSA.ts +33 -0
  154. package/src/styles/themes/tokyoDark.ts +33 -0
  155. package/src/styles/themes/tooSexy.ts +33 -0
  156. package/src/styles/themes/travel.ts +33 -0
  157. package/src/styles/themes/vaporTeal.ts +33 -0
  158. package/src/styles/themes/vermillion.ts +33 -0
  159. package/src/styles/themes/violetDark.ts +33 -0
  160. package/src/styles/themes/water.ts +33 -0
  161. package/src/styles/themes/wmii.ts +36 -0
  162. package/src/types.tsx +55 -0
  163. package/src/utils/index.ts +57 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Luiz Baldi, Artur Bień
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ <h1 align="center">React95 Native</h1>
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/react95-native"><img src="https://flat.badgen.net/npm/dt/react95-native" alt="NPM" /></a>
5
+ <a href="https://www.npmjs.com/package/react95-native"><img src="https://flat.badgen.net/npm/v/react95-native" alt="react95-native version" /></a>
6
+ <a href="https://www.npmjs.com/package/react95-native"><img src="https://flat.badgen.net/npm/license/react95-native" alt="react95-native license" /></a>
7
+ <a href="https://twitter.com/intent/follow?screen_name=react95_io"><img src="https://img.shields.io/twitter/follow/react95_io" alt="React95 twitter" /></a>
8
+ </p>
9
+ <h3 align="center">
10
+ <a href="https://apps.apple.com/tr/app/react95-native/id1553479159">Components (iOS app)</a> -
11
+ <a href="https://coins95.web.app/">Demo app (web version)</a> -
12
+ <a href="https://react95.io/">Website</a> -
13
+ <a href="https://join.slack.com/t/react95/shared_invite/enQtOTA1NzEyNjAyNTc4LWYxZjU3NWRiMWJlMGJiMjhkNzE2MDA3ZmZjZDc1YmY0ODdlZjMwZDA1NWJiYWExYmY1NTJmNmE4OWVjNWFhMTE">Slack</a> -
14
+ <a href="https://www.paypal.me/react95">PayPal donation 💰</a>
15
+ </h3>
16
+ <p align="center">
17
+ <b>Refreshed</b> Windows95 UI components for your modern React-Native apps.</p>
18
+
19
+ ![hero](https://user-images.githubusercontent.com/28541613/152637028-eb445b2a-32cd-4672-bf75-3f3904123637.png)
20
+
21
+ ### Support
22
+
23
+ - [Become a backer or sponsor on Patreon](https://www.patreon.com/arturbien)
24
+ - [One-time donation via PayPal](https://www.paypal.me/react95)
package/package.json ADDED
@@ -0,0 +1,154 @@
1
+ {
2
+ "name": "react95-native-rabbl",
3
+ "version": "0.1.1",
4
+ "description": "Refreshed Windows 95 style UI components for your React Native app",
5
+ "funding": [
6
+ {
7
+ "type": "paypal",
8
+ "url": "https://www.paypal.me/react95"
9
+ },
10
+ {
11
+ "type": "patreon",
12
+ "url": "https://www.patreon.com/arturbien"
13
+ }
14
+ ],
15
+ "contributors": [
16
+ {
17
+ "name": "Artur Bień",
18
+ "email": "artur.bien+react95@gmail.com",
19
+ "url": "https://www.linkedin.com/in/arturbien/"
20
+ },
21
+ {
22
+ "name": "Luiz Baldi",
23
+ "email": "baldilp@gmail.com",
24
+ "url": "https://www.linkedin.com/in/luizbaldi/"
25
+ }
26
+ ],
27
+ "main": "dist/commonjs/index",
28
+ "module": "dist/module/index",
29
+ "types": "dist/typescript/src/index.d.ts",
30
+ "react-native": "src/index",
31
+ "source": "src/index",
32
+ "files": [
33
+ "src",
34
+ "dist"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "cz": "git-cz",
41
+ "test": "jest ./src",
42
+ "test:ci": "jest ./src --maxWorkers=2",
43
+ "test:watch": "jest ./src --watch",
44
+ "test:coverage": "jest ./src --coverage",
45
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
46
+ "typescript": "tsc --noEmit",
47
+ "build": "bob build",
48
+ "semantic-release": "semantic-release",
49
+ "example": "yarn --cwd example",
50
+ "pods": "cd example && pod-install --quiet",
51
+ "bootstrap": "yarn example && yarn && yarn pods"
52
+ },
53
+ "keywords": [
54
+ "react-native",
55
+ "ios",
56
+ "android",
57
+ "windows95",
58
+ "components",
59
+ "vaporwave"
60
+ ],
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "https://github.com/react95-io/react95-native"
64
+ },
65
+ "license": "MIT",
66
+ "bugs": {
67
+ "url": "https://github.com/react95-io/react95-native/issues"
68
+ },
69
+ "homepage": "https://github.com/react95-io/react95-native#readme",
70
+ "devDependencies": {
71
+ "@commitlint/config-conventional": "^8.3.4",
72
+ "@react-native-community/bob": "^0.16.2",
73
+ "@testing-library/jest-native": "^3.4.3",
74
+ "@testing-library/react-native": "^7.1.0",
75
+ "@types/jest": "^26.0.0",
76
+ "@types/react": "^16.9.19",
77
+ "@types/react-native": "0.62.13",
78
+ "@typescript-eslint/eslint-plugin": "^4.9.1",
79
+ "@typescript-eslint/parser": "^4.6.0",
80
+ "commitizen": "^4.2.2",
81
+ "commitlint": "^8.3.5",
82
+ "cz-conventional-changelog": "^3.3.0",
83
+ "eslint": "^7.12.1",
84
+ "eslint-config-airbnb": "18.2.0",
85
+ "eslint-config-prettier": "^6.11.0",
86
+ "eslint-plugin-import": "^2.21.2",
87
+ "eslint-plugin-jest": "^24.1.0",
88
+ "eslint-plugin-jsx-a11y": "^6.3.0",
89
+ "eslint-plugin-prettier": "^3.1.3",
90
+ "eslint-plugin-react": "^7.20.0",
91
+ "eslint-plugin-react-hooks": "4.0.0",
92
+ "husky": "^4.2.5",
93
+ "jest": "^26.0.1",
94
+ "lint-staged": "^10.5.3",
95
+ "pod-install": "^0.1.0",
96
+ "prettier": "^2.0.5",
97
+ "react": "16.11.0",
98
+ "react-native": "0.62.2",
99
+ "react-test-renderer": "^17.0.1",
100
+ "semantic-release": "^17.3.1",
101
+ "typescript": "^3.8.3"
102
+ },
103
+ "peerDependencies": {
104
+ "react": "*",
105
+ "react-native": "*"
106
+ },
107
+ "lint-staged": {
108
+ "*.js": [
109
+ "eslint --fix",
110
+ "prettier --write",
111
+ "git add"
112
+ ]
113
+ },
114
+ "commitlint": {
115
+ "extends": [
116
+ "@commitlint/config-conventional"
117
+ ]
118
+ },
119
+ "husky": {
120
+ "hooks": {
121
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
122
+ "pre-commit": "lint-staged && yarn typescript"
123
+ }
124
+ },
125
+ "config": {
126
+ "commitizen": {
127
+ "path": "./node_modules/cz-conventional-changelog"
128
+ }
129
+ },
130
+ "eslintIgnore": [
131
+ "node_modules/",
132
+ "dist/"
133
+ ],
134
+ "@react-native-community/bob": {
135
+ "source": "src",
136
+ "output": "dist",
137
+ "targets": [
138
+ "commonjs",
139
+ "module",
140
+ [
141
+ "typescript",
142
+ {
143
+ "project": "tsconfig.build.json"
144
+ }
145
+ ]
146
+ ],
147
+ "files": [
148
+ "src/"
149
+ ]
150
+ },
151
+ "dependencies": {
152
+ "@callstack/react-theme-provider": "^2.1.0"
153
+ }
154
+ }
@@ -0,0 +1,4 @@
1
+ The FontStruction “MS Sans Serif”
2
+ (https://fontstruct.com/fontstructions/show/1384746) by “lou” is licensed
3
+ under a Creative Commons Attribution Share Alike license
4
+ (http://creativecommons.org/licenses/by-sa/3.0/).
@@ -0,0 +1,26 @@
1
+ The font file in this archive was created using Fontstruct the free, online
2
+ font-building tool.
3
+ This font was created by “lou”.
4
+ This font has a homepage where this archive and other versions may be found:
5
+ https://fontstruct.com/fontstructions/show/1384746
6
+
7
+ Try Fontstruct at http://fontstruct.com
8
+ It’s easy and it’s fun.
9
+
10
+ NOTE FOR FLASH USERS: Fontstruct fonts (fontstructions) are optimized for Flash.
11
+ If the font in this archive is a pixel font, it is best displayed at a font-size
12
+ of 11.
13
+
14
+ Fontstruct is sponsored by FontShop.
15
+ Visit them at https://fontshop.com
16
+ FontShop is the original independent font retailer. We’ve been around since
17
+ the dawn of digital type. Whether you need the right font or need to create the
18
+ right font from scratch, let our 26 years of experience work for you.
19
+
20
+ Fontstruct is copyright ©2017 Rob Meek
21
+
22
+ LEGAL NOTICE:
23
+ In using this font you must comply with the licensing terms described in the
24
+ file “license.txt” included with this archive.
25
+ If you redistribute the font file in this archive, it must be accompanied by all
26
+ the other files from this archive, including this one.
@@ -0,0 +1,4 @@
1
+ The FontStruction “MS Sans Serif Bold”
2
+ (https://fontstruct.com/fontstructions/show/1384862) by “lou” is licensed
3
+ under a Creative Commons Attribution Share Alike license
4
+ (http://creativecommons.org/licenses/by-sa/3.0/).
@@ -0,0 +1,26 @@
1
+ The font file in this archive was created using Fontstruct the free, online
2
+ font-building tool.
3
+ This font was created by “lou”.
4
+ This font has a homepage where this archive and other versions may be found:
5
+ https://fontstruct.com/fontstructions/show/1384862
6
+
7
+ Try Fontstruct at http://fontstruct.com
8
+ It’s easy and it’s fun.
9
+
10
+ NOTE FOR FLASH USERS: Fontstruct fonts (fontstructions) are optimized for Flash.
11
+ If the font in this archive is a pixel font, it is best displayed at a font-size
12
+ of 11.
13
+
14
+ Fontstruct is sponsored by FontShop.
15
+ Visit them at https://fontshop.com
16
+ FontShop is the original independent font retailer. We’ve been around since
17
+ the dawn of digital type. Whether you need the right font or need to create the
18
+ right font from scratch, let our 26 years of experience work for you.
19
+
20
+ Fontstruct is copyright ©2017 Rob Meek
21
+
22
+ LEGAL NOTICE:
23
+ In using this font you must comply with the licensing terms described in the
24
+ file “license.txt” included with this archive.
25
+ If you redistribute the font file in this archive, it must be accompanied by all
26
+ the other files from this archive, including this one.
@@ -0,0 +1,140 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react-native';
3
+ import { testId } from '../Panel/Panel';
4
+ import { AppBar, Text } from '../..';
5
+
6
+ describe('<AppBar />', () => {
7
+ it('should render children', () => {
8
+ const { getByTestId } = render(
9
+ <AppBar>
10
+ <Text>This is an AppBar</Text>
11
+ </AppBar>,
12
+ );
13
+
14
+ expect(getByTestId(testId)).toHaveTextContent('This is an AppBar');
15
+ });
16
+
17
+ it('should render custom styles', () => {
18
+ const style = { marginTop: 42 };
19
+
20
+ const { getByTestId } = render(
21
+ <AppBar style={style}>
22
+ <Text>This is an AppBar</Text>
23
+ </AppBar>,
24
+ );
25
+
26
+ expect(getByTestId(testId)).toHaveStyle(style);
27
+ });
28
+ });
29
+
30
+ describe('<AppBar.Content />', () => {
31
+ it('should render custom styles', () => {
32
+ const style = { marginTop: 42 };
33
+
34
+ const { getByTestId } = render(
35
+ <AppBar>
36
+ <AppBar.Content title='Title' style={style} testID='content' />
37
+ </AppBar>,
38
+ );
39
+
40
+ expect(getByTestId('content')).toHaveStyle(style);
41
+ });
42
+ describe('title', () => {
43
+ it('should render title', () => {
44
+ const { getByText } = render(
45
+ <AppBar>
46
+ <AppBar.Content title='Title' />
47
+ </AppBar>,
48
+ );
49
+
50
+ expect(getByText('Title')).toBeTruthy();
51
+ });
52
+
53
+ it('should pass styles to title', () => {
54
+ const style = { color: 'red' };
55
+ const { getByText } = render(
56
+ <AppBar>
57
+ <AppBar.Content title='Title' titleStyle={style} />
58
+ </AppBar>,
59
+ );
60
+
61
+ expect(getByText('Title')).toHaveStyle(style);
62
+ });
63
+ });
64
+
65
+ describe('subtitle', () => {
66
+ it('should render subtitle', () => {
67
+ const { getByText } = render(
68
+ <AppBar>
69
+ <AppBar.Content title='Title' subtitle='Subtitle' />
70
+ </AppBar>,
71
+ );
72
+
73
+ expect(getByText('Subtitle')).toBeTruthy();
74
+ });
75
+
76
+ it('should pass styles to subtitle', () => {
77
+ const style = { color: 'red' };
78
+ const { getByText } = render(
79
+ <AppBar>
80
+ <AppBar.Content
81
+ title='Title'
82
+ subtitle='Subtitle'
83
+ subtitleStyle={style}
84
+ />
85
+ </AppBar>,
86
+ );
87
+
88
+ expect(getByText('Subtitle')).toHaveStyle(style);
89
+ });
90
+ });
91
+
92
+ describe('prop: onPress', () => {
93
+ it('should handle onPress', () => {
94
+ const onPress = jest.fn();
95
+
96
+ const { getByTestId } = render(
97
+ <AppBar>
98
+ <AppBar.Content
99
+ testID='content'
100
+ onPress={onPress}
101
+ title='Title'
102
+ subtitle='Subtitle'
103
+ />
104
+ </AppBar>,
105
+ );
106
+
107
+ fireEvent(getByTestId('content'), 'press');
108
+ expect(onPress).toHaveBeenCalled();
109
+ });
110
+ });
111
+ });
112
+
113
+ describe('<AppBar.BackAction />', () => {
114
+ it('should render custom styles', () => {
115
+ const style = { marginTop: 42 };
116
+
117
+ const { getByTestId } = render(
118
+ <AppBar>
119
+ <AppBar.BackAction testID='backAction' style={style} />
120
+ </AppBar>,
121
+ );
122
+
123
+ expect(getByTestId('backAction')).toHaveStyle(style);
124
+ });
125
+
126
+ describe('prop: onPress', () => {
127
+ it('should handle onPress', () => {
128
+ const onPress = jest.fn();
129
+
130
+ const { getByTestId } = render(
131
+ <AppBar>
132
+ <AppBar.BackAction testID='backAction' onPress={onPress} />
133
+ </AppBar>,
134
+ );
135
+
136
+ fireEvent(getByTestId('backAction'), 'press');
137
+ expect(onPress).toHaveBeenCalled();
138
+ });
139
+ });
140
+ });
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
+
4
+ import type { Theme } from '../../types';
5
+ import { withTheme } from '../../core/theming';
6
+
7
+ import AppBarContent from './AppBarContent';
8
+ import AppBarBackAction from './AppBarBackAction';
9
+ import Panel from '../Panel';
10
+
11
+ type Props = React.ComponentPropsWithRef<typeof View> & {
12
+ children: React.ReactNode;
13
+ style?: StyleProp<ViewStyle>;
14
+ theme: Theme;
15
+ };
16
+
17
+ const AppBar = ({ children, style = {}, ...rest }: Props) => {
18
+ return (
19
+ <Panel
20
+ style={[styles.wrapper, style]}
21
+ variant='raised'
22
+ elevation={2}
23
+ {...rest}
24
+ >
25
+ {children}
26
+ </Panel>
27
+ );
28
+ };
29
+
30
+ const styles = StyleSheet.create({
31
+ wrapper: {
32
+ position: 'relative',
33
+ height: 56,
34
+ flexDirection: 'row',
35
+ alignItems: 'center',
36
+ paddingHorizontal: 8,
37
+ },
38
+ });
39
+
40
+ AppBar.Content = AppBarContent;
41
+ AppBar.BackAction = AppBarBackAction;
42
+
43
+ export default withTheme(AppBar);
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { $RemoveChildren } from '../../types';
3
+
4
+ import { Button, ChevronIcon } from '../..';
5
+
6
+ type Props = $RemoveChildren<typeof Button>;
7
+
8
+ const AppBarBackAction = ({ disabled, ...rest }: Props) => {
9
+ return (
10
+ <Button disabled={disabled} square variant='menu' {...rest}>
11
+ <ChevronIcon
12
+ disabled={disabled}
13
+ direction='left'
14
+ style={{ marginLeft: -2 }}
15
+ />
16
+ </Button>
17
+ );
18
+ };
19
+
20
+ export default AppBarBackAction;
@@ -0,0 +1,84 @@
1
+ /* eslint-disable react/jsx-props-no-spreading */
2
+ import * as React from 'react';
3
+ import {
4
+ StyleProp,
5
+ StyleSheet,
6
+ TextStyle,
7
+ TouchableWithoutFeedback,
8
+ View,
9
+ ViewStyle,
10
+ } from 'react-native';
11
+
12
+ import type { Theme, $RemoveChildren } from '../../types';
13
+ import { withTheme } from '../../core/theming';
14
+
15
+ import { Text } from '../..';
16
+
17
+ type Props = $RemoveChildren<typeof View> & {
18
+ // titleRef?: React.RefObject<Text>;
19
+ // TODO: titleRef
20
+ onPress?: () => void;
21
+ style?: StyleProp<ViewStyle>;
22
+ subtitle?: React.ReactNode;
23
+ subtitleStyle?: StyleProp<TextStyle>;
24
+ theme: Theme;
25
+ title: React.ReactNode;
26
+ titleRef?: React.RefObject<Text>;
27
+ titleStyle?: StyleProp<TextStyle>;
28
+ };
29
+
30
+ const AppbarContent = ({
31
+ // titleRef,
32
+ onPress,
33
+ style,
34
+ subtitle,
35
+ subtitleStyle,
36
+ theme,
37
+ title,
38
+ titleStyle,
39
+ ...rest
40
+ }: Props) => {
41
+ return (
42
+ <View style={[styles.container, style]} {...rest}>
43
+ <TouchableWithoutFeedback onPress={onPress} disabled={!onPress}>
44
+ <View>
45
+ <Text
46
+ theme={theme}
47
+ // ref={titleRef}
48
+ style={[styles.title, titleStyle]}
49
+ accessibilityTraits='header'
50
+ >
51
+ {title}
52
+ </Text>
53
+ {subtitle ? (
54
+ <Text
55
+ theme={theme}
56
+ secondary
57
+ style={[styles.subtitle, subtitleStyle]}
58
+ >
59
+ {subtitle}
60
+ </Text>
61
+ ) : null}
62
+ </View>
63
+ </TouchableWithoutFeedback>
64
+ </View>
65
+ );
66
+ };
67
+
68
+ // TODO: attach displayName to every component?
69
+ AppbarContent.displayName = 'Appbar.Content';
70
+
71
+ const styles = StyleSheet.create({
72
+ container: {
73
+ flex: 1,
74
+ paddingHorizontal: 12,
75
+ },
76
+ title: {
77
+ fontSize: 16,
78
+ },
79
+ subtitle: {
80
+ fontSize: 12,
81
+ },
82
+ });
83
+
84
+ export default withTheme(AppbarContent);
@@ -0,0 +1 @@
1
+ export { default } from './AppBar';
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react-native';
3
+ import type { Sizes } from '../../types';
4
+ import { blockSizes } from '../../styles/styles';
5
+ import { testId } from './Button';
6
+ import { Button, Text } from '../..';
7
+
8
+ const noop = () => {};
9
+
10
+ describe('<Button />', () => {
11
+ it('should render children', () => {
12
+ const { getByText } = render(
13
+ <Button onPress={noop}>
14
+ <Text>Potato</Text>
15
+ </Button>,
16
+ );
17
+
18
+ expect(getByText('Potato')).toBeTruthy();
19
+ });
20
+
21
+ it('should fire press', () => {
22
+ const onButtonPress = jest.fn();
23
+
24
+ const { getByRole } = render(
25
+ <Button onPress={onButtonPress}>
26
+ <Text>Ok</Text>
27
+ </Button>,
28
+ );
29
+
30
+ fireEvent(getByRole('button'), 'press');
31
+ expect(onButtonPress).toHaveBeenCalled();
32
+ });
33
+
34
+ it('should handle square sizes', () => {
35
+ const sizes: Sizes[] = ['sm', 'md', 'lg'];
36
+
37
+ sizes.forEach(size => {
38
+ const { getByTestId } = render(
39
+ <Button onPress={noop} size={size} square>
40
+ <Text>Ok</Text>
41
+ </Button>,
42
+ );
43
+
44
+ expect(getByTestId(testId)).toHaveStyle({ width: blockSizes[size] });
45
+ });
46
+ });
47
+
48
+ it('should render custom styles', () => {
49
+ const style = { backgroundColor: 'papayawhip' };
50
+
51
+ const { getByTestId } = render(
52
+ <Button onPress={noop} style={style}>
53
+ <Text>Ok</Text>
54
+ </Button>,
55
+ );
56
+
57
+ expect(getByTestId(testId)).toHaveStyle(style);
58
+ });
59
+ });