Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions docs/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ If this button doesn't look right for your app, you can build your own button us

## Example

```SnackPlayer name=Button%20Example
```SnackPlayer name=Button%20Example&ext=js
import React from 'react';
import {StyleSheet, Button, View, Text, Alert} from 'react-native';
import {StyleSheet, Button, View, Text, Alert, Platform} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

const Separator = () => <View style={styles.separator} />;

function showAlert(message) {
if (Platform.OS === 'web') {
window.alert(message);
} else {
Alert.alert(message);
}
}

const App = () => (
<SafeAreaProvider>
<SafeAreaView style={styles.container}>
Expand All @@ -35,7 +43,7 @@ const App = () => (
</Text>
<Button
title="Press me"
onPress={() => Alert.alert('Simple Button pressed')}
onPress={() => showAlert('Simple Button pressed')}
/>
</View>
<Separator />
Expand All @@ -48,7 +56,7 @@ const App = () => (
<Button
title="Press me"
color="#f194ff"
onPress={() => Alert.alert('Button with adjusted color pressed')}
onPress={() => showAlert('Button with adjusted color pressed')}
/>
</View>
<Separator />
Expand All @@ -59,7 +67,7 @@ const App = () => (
<Button
title="Press me"
disabled
onPress={() => Alert.alert('Cannot press this one')}
onPress={() => showAlert('Cannot press this one')}
/>
</View>
<Separator />
Expand All @@ -70,11 +78,11 @@ const App = () => (
<View style={styles.fixToText}>
<Button
title="Left button"
onPress={() => Alert.alert('Left button pressed')}
onPress={() => showAlert('Left button pressed')}
/>
<Button
title="Right button"
onPress={() => Alert.alert('Right button pressed')}
onPress={() => showAlert('Right button pressed')}
/>
</View>
</View>
Expand Down
1 change: 1 addition & 0 deletions packages/lint-examples/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default defineConfig([
...reactNativeConfig.rules,
// Many existing inline styles in examples
'react-native/no-inline-styles': 'off',
'no-alert': 'off',
},

settings: {
Expand Down
22 changes: 15 additions & 7 deletions website/versioned_docs/version-0.82/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ If this button doesn't look right for your app, you can build your own button us

## Example

```SnackPlayer name=Button%20Example
```SnackPlayer name=Button%20Example&ext=js
import React from 'react';
import {StyleSheet, Button, View, Text, Alert} from 'react-native';
import {StyleSheet, Button, View, Text, Alert, Platform} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

const Separator = () => <View style={styles.separator} />;

function showAlert(message) {
if (Platform.OS === 'web') {
window.alert(message);
} else {
Alert.alert(message);
}
}

const App = () => (
<SafeAreaProvider>
<SafeAreaView style={styles.container}>
Expand All @@ -35,7 +43,7 @@ const App = () => (
</Text>
<Button
title="Press me"
onPress={() => Alert.alert('Simple Button pressed')}
onPress={() => showAlert('Simple Button pressed')}
/>
</View>
<Separator />
Expand All @@ -48,7 +56,7 @@ const App = () => (
<Button
title="Press me"
color="#f194ff"
onPress={() => Alert.alert('Button with adjusted color pressed')}
onPress={() => showAlert('Button with adjusted color pressed')}
/>
</View>
<Separator />
Expand All @@ -59,7 +67,7 @@ const App = () => (
<Button
title="Press me"
disabled
onPress={() => Alert.alert('Cannot press this one')}
onPress={() => showAlert('Cannot press this one')}
/>
</View>
<Separator />
Expand All @@ -70,11 +78,11 @@ const App = () => (
<View style={styles.fixToText}>
<Button
title="Left button"
onPress={() => Alert.alert('Left button pressed')}
onPress={() => showAlert('Left button pressed')}
/>
<Button
title="Right button"
onPress={() => Alert.alert('Right button pressed')}
onPress={() => showAlert('Right button pressed')}
/>
</View>
</View>
Expand Down
22 changes: 15 additions & 7 deletions website/versioned_docs/version-0.83/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ If this button doesn't look right for your app, you can build your own button us

## Example

```SnackPlayer name=Button%20Example
```SnackPlayer name=Button%20Example&ext=js
import React from 'react';
import {StyleSheet, Button, View, Text, Alert} from 'react-native';
import {StyleSheet, Button, View, Text, Alert, Platform} from 'react-native';
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';

const Separator = () => <View style={styles.separator} />;

function showAlert(message) {
if (Platform.OS === 'web') {
window.alert(message);
} else {
Alert.alert(message);
}
}

const App = () => (
<SafeAreaProvider>
<SafeAreaView style={styles.container}>
Expand All @@ -35,7 +43,7 @@ const App = () => (
</Text>
<Button
title="Press me"
onPress={() => Alert.alert('Simple Button pressed')}
onPress={() => showAlert('Simple Button pressed')}
/>
</View>
<Separator />
Expand All @@ -48,7 +56,7 @@ const App = () => (
<Button
title="Press me"
color="#f194ff"
onPress={() => Alert.alert('Button with adjusted color pressed')}
onPress={() => showAlert('Button with adjusted color pressed')}
/>
</View>
<Separator />
Expand All @@ -59,7 +67,7 @@ const App = () => (
<Button
title="Press me"
disabled
onPress={() => Alert.alert('Cannot press this one')}
onPress={() => showAlert('Cannot press this one')}
/>
</View>
<Separator />
Expand All @@ -70,11 +78,11 @@ const App = () => (
<View style={styles.fixToText}>
<Button
title="Left button"
onPress={() => Alert.alert('Left button pressed')}
onPress={() => showAlert('Left button pressed')}
/>
<Button
title="Right button"
onPress={() => Alert.alert('Right button pressed')}
onPress={() => showAlert('Right button pressed')}
/>
</View>
</View>
Expand Down