Skip to content

Commit 1f4a6f4

Browse files
committedOct 13, 2022
Add examples for Chip component
1 parent 9b61716 commit 1f4a6f4

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed
 

Diff for: ‎example/src/App.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import FormControlExamples from './components/FormControlExamples';
1818
import TextInputExamples from './components/TextInputExamples';
1919
import PaletteColorGrid from './components/PaletteColorGrid';
2020
import ColorModeToggler from './components/ColorModeToggler';
21+
import ChipExamples from './components/ChipExamples';
2122

2223
const styles = StyleSheet.create( {
2324
container: {
@@ -128,6 +129,7 @@ const App = () => (
128129
<RadioExamples/>
129130
<FormControlExamples />
130131
<TextInputExamples />
132+
<ChipExamples />
131133
</VStack>
132134
</ScrollView>
133135
</SafeAreaView>

Diff for: ‎example/src/components/ChipExamples.tsx

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import * as React from 'react';
2+
3+
import { Alert, StyleSheet, View } from 'react-native';
4+
import {
5+
Chip, HStack, Icon, Text, VStack
6+
} from '@amalgama/embassy-ui';
7+
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
8+
9+
const styles = StyleSheet.create( {
10+
container: {
11+
marginBottom: 20
12+
},
13+
separator: {
14+
height: 1,
15+
minWidth: '100%',
16+
marginTop: 2,
17+
marginBottom: 6,
18+
backgroundColor: 'black'
19+
},
20+
vspace: {
21+
height: 10,
22+
minWidth: '100%'
23+
}
24+
} );
25+
26+
const onChipPressed = () => Alert.alert( 'Pressed!' );
27+
const onDeletePressed = () => Alert.alert( 'Delete pressed!' );
28+
29+
const ChipExamples = () => (
30+
<VStack style={styles.container} space="2">
31+
<Text variant="headline">Chip Component</Text>
32+
<View style={styles.vspace} />
33+
<HStack space="2" width="100%" flexWrap="wrap">
34+
<Chip label="Label" onPress={onChipPressed} />
35+
<Chip label="Selected" onPress={onChipPressed} selected />
36+
<Chip label="Disabled" onPress={onChipPressed} disabled />
37+
</HStack>
38+
<HStack space="2" width="100%" flexWrap="wrap">
39+
<Chip
40+
icon={<Icon name="lightning-bolt-outline" as={MaterialCommunityIcon} />}
41+
label="Left Icon"
42+
/>
43+
<Chip
44+
label="Delete Icon"
45+
onDeletePress={onDeletePressed}
46+
/>
47+
</HStack>
48+
<HStack space="2" width="100%" flexWrap="wrap">
49+
<Chip
50+
label="Custom Delete Icon"
51+
deleteIcon={<Icon name="close-circle-outline" as={MaterialCommunityIcon} />}
52+
onDeletePress={onDeletePressed}
53+
/>
54+
</HStack>
55+
</VStack>
56+
);
57+
58+
export default ChipExamples;

Diff for: ‎web_example/src/App.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import RadioExamples from './components/RadioExamples';
1717
import FormControlExamples from './components/FormControlExamples';
1818
import TextInputExamples from './components/TextInputExamples';
1919
import PaletteColorGrid from './components/PaletteColorGrid';
20+
import ChipExamples from './components/ChipExamples';
2021

2122
const customTheme = extendThemeConfig( {
2223
palette: {
@@ -122,6 +123,7 @@ const App = () => (
122123
<RadioExamples/>
123124
<FormControlExamples />
124125
<TextInputExamples />
126+
<ChipExamples />
125127
</VStack>
126128
</Box>
127129
</ThemeProvider>

Diff for: ‎web_example/src/components/ChipExamples.tsx

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import * as React from 'react';
2+
3+
import { Alert, StyleSheet, View } from 'react-native';
4+
import {
5+
Chip, HStack, Icon, Text, VStack
6+
} from '@amalgama/embassy-ui';
7+
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
8+
9+
const styles = StyleSheet.create( {
10+
container: {
11+
marginBottom: 20
12+
},
13+
separator: {
14+
height: 1,
15+
minWidth: '100%',
16+
marginTop: 2,
17+
marginBottom: 6,
18+
backgroundColor: 'black'
19+
},
20+
vspace: {
21+
height: 10,
22+
minWidth: '100%'
23+
}
24+
} );
25+
26+
const onChipPressed = () => Alert.alert( 'Pressed!' );
27+
const onDeletePressed = () => Alert.alert( 'Delete pressed!' );
28+
29+
const ChipExamples = () => (
30+
<VStack style={styles.container} space="2">
31+
<Text variant="headline">Chip Component</Text>
32+
<View style={styles.vspace} />
33+
<HStack space="2" width="100%" flexWrap="wrap">
34+
<Chip label="Label" onPress={onChipPressed} />
35+
<Chip label="Selected" onPress={onChipPressed} selected />
36+
<Chip label="Disabled" onPress={onChipPressed} disabled />
37+
</HStack>
38+
<HStack space="2" width="100%" flexWrap="wrap">
39+
<Chip
40+
icon={<Icon name="lightning-bolt-outline" as={MaterialCommunityIcon} />}
41+
label="Left Icon"
42+
/>
43+
<Chip
44+
label="Delete Icon"
45+
onDeletePress={onDeletePressed}
46+
/>
47+
</HStack>
48+
<HStack space="2" width="100%" flexWrap="wrap">
49+
<Chip
50+
label="Custom Delete Icon"
51+
deleteIcon={<Icon name="close-circle-outline" as={MaterialCommunityIcon} />}
52+
onDeletePress={onDeletePressed}
53+
/>
54+
</HStack>
55+
</VStack>
56+
);
57+
58+
export default ChipExamples;

0 commit comments

Comments
 (0)
Please sign in to comment.