Skip to content

Commit be6f2d8

Browse files
feat(example): add border demo
1 parent 6d21d18 commit be6f2d8

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

example/src/demos/BorderDemo.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useState } from 'react';
2+
import { Text, StyleSheet } from 'react-native';
3+
import { EaseView } from 'react-native-ease';
4+
5+
import { Section } from '../components/Section';
6+
import { Button } from '../components/Button';
7+
8+
export function BorderDemo() {
9+
const [active, setActive] = useState(false);
10+
return (
11+
<Section title="Border">
12+
<EaseView
13+
animate={{
14+
borderWidth: active ? 4 : 0,
15+
borderColor: active ? '#e74c3c' : '#4a90d9',
16+
}}
17+
transition={{
18+
border: { type: 'spring', damping: 15, stiffness: 120 },
19+
}}
20+
style={styles.box}
21+
>
22+
<Text style={styles.text}>{active ? 'Red' : 'None'}</Text>
23+
</EaseView>
24+
<Button
25+
label={active ? 'Remove' : 'Add Border'}
26+
onPress={() => setActive((v) => !v)}
27+
/>
28+
</Section>
29+
);
30+
}
31+
32+
const styles = StyleSheet.create({
33+
box: {
34+
width: 100,
35+
height: 100,
36+
borderRadius: 16,
37+
backgroundColor: '#f0f0f0',
38+
alignItems: 'center',
39+
justifyContent: 'center',
40+
},
41+
text: {
42+
color: '#333',
43+
fontSize: 13,
44+
fontWeight: '700',
45+
},
46+
});

example/src/demos/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BackgroundColorDemo } from './BackgroundColorDemo';
55
import { BenchmarkDemo } from './BenchmarkDemo';
66
import { BannerDemo } from './BannerDemo';
77
import { CardFlipDemo } from './CardFlipDemo';
8+
import { BorderDemo } from './BorderDemo';
89
import { BorderRadiusDemo } from './BorderRadiusDemo';
910
import { ButtonDemo } from './ButtonDemo';
1011
import { CombinedDemo } from './CombinedDemo';
@@ -62,6 +63,11 @@ export const demos: Record<string, DemoEntry> = {
6263
title: 'Styled Card',
6364
section: 'Style',
6465
},
66+
'border': {
67+
component: BorderDemo,
68+
title: 'Border',
69+
section: 'Style',
70+
},
6571
'border-radius': {
6672
component: BorderRadiusDemo,
6773
title: 'Border Radius',

0 commit comments

Comments
 (0)