Skip to content

Commit c0c6214

Browse files
committed
fix: docs; feat: add events, split placeholder
1 parent c06abcc commit c0c6214

File tree

6 files changed

+225
-136
lines changed

6 files changed

+225
-136
lines changed

README.md

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
`react-native-really-awesome-button` is a performant, extendable, production ready React Native component that renders an animated set of 3D UI buttons.
66

7-
Run the <a target="_blank" title="Live Demo" href="https://expo.io/@rcaferati/react-native-really-awesome-button">live demo</a> @ expo.io.
8-
97
| <img width="240" src='https://raw.githubusercontent.com/rcaferati/react-native-really-awesome-button/master/assets/demo-button-blue-new.gif?raw=true' /> | <img width="240" src='https://raw.githubusercontent.com/rcaferati/react-native-really-awesome-button/master/assets/demo-button-rick.gif?raw=true' /> | <img width="240" src='https://raw.githubusercontent.com/rcaferati/react-native-really-awesome-button/master/assets/demo-button-cartman.gif?raw=true' /> |
108
|---|---|---|
119

@@ -42,8 +40,8 @@ function Button() {
4240
return (
4341
<AwesomeButton
4442
progress
45-
onPress={next => {
46-
/** Do Something **/
43+
onPress={async (next) => {
44+
/** await for something; then: **/
4745
next();
4846
}}
4947
>
@@ -53,12 +51,27 @@ function Button() {
5351
}
5452
```
5553

54+
### Importing a specific theme
55+
56+
```jsx
57+
import { ThemedButton } from 'react-native-really-awesome-button';
58+
59+
function ButtonWithTheme() {
60+
return (
61+
<>
62+
<ThemedButton name="rick" type="primary">Rick's Primary Button</ThemedButton>
63+
<ThemedButton name="rick" type="secondary">Rick's Secondary Button</ThemedButton>
64+
</>
65+
);
66+
}
67+
```
68+
5669
### Custom Children
5770

5871
```jsx
5972
import AwesomeButton from "react-native-really-awesome-button";
6073

61-
function Button() {
74+
function ButtonWithCustomChildren() {
6275
return (
6376
<AwesomeButton>
6477
<Image source="require('send-icon.png)" />
@@ -68,32 +81,40 @@ function Button() {
6881
}
6982
```
7083

71-
### Importing a specific theme
84+
### Adding content before and after the button label
85+
Useful for handling icons or any other inlined content which animates together with the button text.
7286

7387
```jsx
74-
import AwesomeButtonRick from 'react-native-really-awesome-button/src/themes/rick';
88+
import { ThemedButton } from 'react-native-really-awesome-button';
89+
import { FontAwesome } from "@expo/icons";
7590

76-
function Button() {
91+
function ButtonWithIcon() {
7792
return (
78-
<AwesomeButtonRick type="primary">Rick's Primary Button</AwesomeButtonRick>
79-
<AwesomeButtonRick type="secondary">Rick's Secondary Button</AwesomeButtonRick>
93+
<ThemedButton
94+
name="bruce"
95+
type="primary"
96+
before={<FontAwesome name="twitter" />}>
97+
Rick's Primary Button
98+
</ThemedButton>
8099
);
81100
}
82101
```
83102
84-
### Extra Content placement
85-
You can use the `Extra Content` prop to render a component inside the button content body. This could be useful to render an image or gradient background
103+
### Extra content placement
104+
You can use the `extra` prop to render a component inside the button content body; this should be useful to render an image or gradient background
86105
87106
```jsx
107+
import { StyleSheet } from "react-native";
88108
import AwesomeButton from "react-native-really-awesome-button";
89109
import LinearGradient from "react-native-linear-gradient";
90110
91-
function Button() {
111+
function ButtonWithExtraContent() {
92112
return (
93113
<AwesomeButton
94-
ExtraContent={
114+
extra={
95115
<LinearGradient
96116
colors={["#4C63D2", "#BC3081", "#F47133", "#FED576"]}
117+
style={{ ...StyleSheet.absoluteFillObject }}
97118
/>
98119
}
99120
>
@@ -103,53 +124,95 @@ function Button() {
103124
}
104125
```
105126
127+
### Full event control
128+
Added a set of controlling events on `v2`, giving control of every animation stage like `onPressedIn` and `onPressedOut` which are triggered on the `Animated` callback.
129+
130+
```jsx
131+
import { StyleSheet } from "react-native";
132+
import AwesomeButton from "react-native-really-awesome-button";
133+
import LinearGradient from "react-native-linear-gradient";
134+
135+
function ButtonWithExtraEvents() {
136+
return (
137+
<>
138+
<AwesomeButton
139+
onPressIn={handlePressIn}
140+
onPressedIn={handlePressedIn}
141+
onPressOut={handlePressOut}
142+
onPressedOut={handlePressedOut}
143+
>
144+
Label
145+
</AwesomeButton>
146+
<AwesomeButton
147+
progress
148+
onProgressStart={handleOnProgressStart}
149+
onProgressEnd={handleOnProgressEnd}
150+
onPress={handleOnPress}
151+
>
152+
Label
153+
</AwesomeButton>
154+
</>
155+
);
156+
}
157+
```
158+
106159
## Props
107160
108161
| Attributes | Type | Default | Description |
109162
| :-------------------- | :-----------: | :-------: | :-------------------------------------------------------- |
110163
| activityColor | `String` | `#FFFFFF` | Button activity indicator color |
111164
| activeOpacity | `Number` | `1` | Button active state opacity |
165+
| animatedPlaceholder | `Boolean` | `true` | When set to `false` removes the placeholder animation loop |
112166
| backgroundActive | `String` | `#C0C0C0` | Button active state background-color |
113167
| backgroundColor | `String` | `#C0C0C0` | Button content background-color |
114168
| backgroundDarker | `String` | `#9F9F9F` | Button bottom-front-face background-color |
115-
| backgroundShadow | `String` | `#C0C0C0` | Button bottom shaddow background-color |
169+
| backgroundShadow | `String` | `#C0C0C0` | Button bottom shadow background-color |
116170
| backgroundPlaceholder | `String` | `#C0C0C0` | Button placeholder background-color |
117171
| backgroundProgress | `String` | `#C0C0C0` | Button progress bar background-color |
118-
| borderColor | `String` | `null` | Button border-color |
172+
| borderColor | `String` | `null` | Button border-color |
119173
| borderRadius | `Number` | `4` | Button border-radius |
120174
| borderWidth | `Number` | `0` | Button border-width |
175+
| dangerouslySetPressableProps | `PressableProps` | `null` | Exposes the `PressableProps` of the `Pressable` wrapper; it can overwrite all props except `onPressIn` and `onPressOut` |
176+
| debouncedPressTime | `Number` | `0` | Configure onPress function debounce time |
177+
| disabled | `Boolean` | `true` | Button disabled state: cancels animation and onPress func |
121178
| height | `Number` | `50` | Button height |
122179
| width | `Number` | `null` | Setting width to `null` mirrors an `auto` behaviour |
123180
| paddingHorizontal | `Number` | `12` | Sets the button horizontal padding |
124181
| paddingTop | `Number` | `0` | Sets the button padding top |
125182
| paddingBottom | `Number` | `0` | Sets the button padding bottom |
126183
| stretch | `Boolean` | `false` | When set to `true` together with width set to `null` the button fills it's parent component width |
127-
| disabled | `Boolean` | `true` | Button disabled state: cancels animation and onPress func |
128184
| raiseLevel | `Number` | `4` | Button 3D raise level |
129-
| ExtraContent | `Node` | `null` | Renders a custom component inside the button content body |
130-
| springRelease | `Boolean` | `true` | Button uses spring on the release animation |
131-
| onPress               | `Function`   | `null` | Button onPress function. It receives a `next` argument when the `progress` prop is set to `true` |
132-
| progress             | `Boolean`    | `false` | When set to `true` enables progress animation |
133-
| progressLoadingTime   | `Number`    | `3000` | Number in `ms` for the maximum progress bar animation time |
185+
| before | `ReactNode` | `null` | Renders a custom component before the button content Text |
186+
| after | `ReactNode` | `null` | Renders a custom component after the button content Text |
187+
| extra | `ReactNode` | `null` | Renders a custom component inside the button content body |
188+
| springRelease | `Boolean` | `true` | Button uses elastic spring on the release animation |
189+
| progress | `Boolean` | `false` | When set to `true` enables progress animation |
190+
| progressLoadingTime   | `Number` | `3000` | Number in `ms` for the maximum progress bar animation time |
134191
| textColor | `String` | `#FFFFFF` | Button default label text color |
135192
| textLineHeight | `Number` | `20` | Button default label text line height |
136193
| textSize | `Number` | `16` | Button default label text font size |
137194
| textFontFamily | `String` | `null` | Button default label text font family |
138-
| style                 | `Style`     | `null`   | Button container custom styles |
195+
| style | `Style` | `null`   | Button container custom styles |
196+
| onPress | `Function` | `null` | Button onPress function. It receives a `next` argument when the `progress` prop is set to `true` |
197+
| onPressIn | `Function` | `null` | Triggered with the `onPressIn` native event |
198+
| onPressedIn | `Function` | `null` | Triggered once the press animation has finished |
199+
| onPressOut | `Function` | `null` | Triggered with the `onPressOut` native event |
200+
| onPressedOut | `Function` | `null` | Triggered once the release animation has finished |
201+
| onProgressStart | `Function` | `null` | Triggered before the progress animation has started |
202+
| onProgressEnd | `Function` | `null` | Triggered after the progress animation has finished |
139203

140204
## Web version
141-
Checkout the web version of the Awesome Button UI component at [rcaferati/react-awesome-button](https://github.com/rcaferati/react-awesome-button)
205+
Checkout the web version of the `Awesome Button UI Component` at [rcaferati/react-awesome-button](https://github.com/rcaferati/react-awesome-button)
142206

143207
[<img src="https://github.com/rcaferati/react-awesome-button/blob/master/assets/public/images/react-awesome-button-customizer.png?raw=true" width="800" />](https://caferati.me/demo/react-awesome-button)
144208

145209
## About the Author
146210

147211
#### Rafael Caferati
148212

149-
- Checkout my <a href="https://caferati.me" title="Full-Stack Web Developer, UI/UX Javascript Specialist" target="_blank">Full-Stack Web Developer Website</a>
150-
- Other open source projects @ <a title="Web Software Developer Code Laboratory" target="_blank" href="https://caferati.me/labs">Code Laboratory</a>
151-
- A scope of my work @ <a title="Web Software Developer Portfolio" target="_blank" href="https://caferati.me/portfolio">Web Developer Portfolio</a>
213+
- Checkout my <a href="https://caferati.me" title="Full-Stack Web Developer, UI/UX Javascript Specialist" target="_blank">Portfolio Website</a>
214+
- Connect with me on `LinkedIn` <a href="https://linkedin.com/in/rcaferati" title="Full-Stack Web Developer, UI/UX Javascript Specialist" target="_blank">@rcaferati</a>
152215

153216
## License
154217

155-
MIT. Copyright (c) 2018 Rafael Caferati.
218+
MIT. Copyright (c) 2022 Rafael Caferati.

demo/src/components/Example.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,23 +261,6 @@ export default function Example({ index }: any) {
261261
/>
262262
</ThemedButton>
263263
</Section>
264-
{/* <Section title="Linear Gradient Overwrite">
265-
<Themed
266-
config={theme}
267-
backgroundDarker="#EAAC1E"
268-
backgroundActive="rgba(0,0,0,0.1)"
269-
ExtraContent={
270-
<LinearGradient
271-
colors={['#4C63D2', '#BC3081', '#F47133', '#FED576']}
272-
style={styles.gradient}
273-
/>
274-
}
275-
style={styles.button}
276-
type="primary"
277-
size="medium">
278-
Gradient Overwrite
279-
</ThemedButton>
280-
</Section> */}
281264
<Section title="With auto and stretch">
282265
<ThemedButton
283266
config={theme}

demo/src/screens/Social.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default function Social({ navigation }: any) {
8080
progress
8181
backgroundProgress="rgba(0,0,0,0.15)"
8282
onPress={handleTimeout}
83-
ExtraContent={
83+
extra={
8484
<LinearGradient
8585
colors={['#4C63D2', '#BC3081', '#F47133', '#FED576']}
8686
style={{ ...StyleSheet.absoluteFillObject }}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"eslint-config-prettier": "^8.5.0",
6161
"eslint-plugin-prettier": "^4.0.0",
6262
"jest": "^28.1.1",
63+
"lodash.debounce": "^4.0.8",
6364
"pod-install": "^0.1.0",
6465
"prettier": "^2.0.5",
6566
"react": "17.0.2",
@@ -150,8 +151,5 @@
150151
}
151152
]
152153
]
153-
},
154-
"dependencies": {
155-
"lodash.debounce": "^4.0.8"
156154
}
157155
}

0 commit comments

Comments
 (0)