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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Groups map to top-level folders under `evals/`.
| animation | `evals/animation` | Active |
| async-state | `evals/async-state` | Active |
| navigation | `evals/navigation` | Active |
| react-native-apis | `evals/react-native-apis` | WIP |
| react-native-apis | `evals/react-native-apis` | Active |
| expo-sdk | `evals/expo-sdk` | WIP |
| nitro-modules | `evals/nitro-modules` | WIP |
| lists | `evals/lists` | Active |
Expand Down
6 changes: 6 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions evals/react-native-apis/01-rn-stylesheet-card-variants/app/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import { Text, View } from 'react-native'

const CARDS = [
{
id: 'card-1',
status: 'On schedule',
title: 'City route handoff',
},
{
id: 'card-2',
highlighted: true,
status: 'Delayed',
title: 'Warehouse transfer',
},
]

export default function App() {
return (
<View>
<Text>Status</Text>
{CARDS.map((card) => {
return (
<View key={card.id}>
<Text>{card.title}</Text>
<Text>{card.status}</Text>
</View>
)
})}
</View>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add styles for the two status cards: a normal card and a highlighted card.
The base card should use a light gray border.
The highlighted card should keep the same base styling and change the border to red.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

const CARDS = [
{
id: 'card-1',
status: 'On schedule',
title: 'City route handoff',
},
{
id: 'card-2',
highlighted: true,
status: 'Delayed',
title: 'Warehouse transfer',
},
]

export default function App() {
return (
<View>
<Text>Status</Text>
{CARDS.map((card) => {
return (
<View
key={card.id}
style={[styles.card, card.highlighted && styles.cardHighlighted]}
>
<Text>{card.title}</Text>
<Text>{card.status}</Text>
</View>
)
})}
</View>
)
}

const styles = StyleSheet.create({
card: {
backgroundColor: '#fff',
borderColor: '#cbd5e1',
borderWidth: 2,
borderRadius: 16,
padding: 16,
},
cardHighlighted: {
borderColor: '#dc2626',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1
inputs:
files:
- app/App.tsx
requirements:
- id: implementation-render-stylesheet-create
description: Must define styles with `StyleSheet.create(...)`.
- id: base-card-and-highlight-diff-style
description: Must define a base card style and a highlighted diff style instead of two full separate card styles.
- id: highlighted-style-conditionally-extends-base-card
description: Must conditionally extend the base card style for highlighted cards instead of using separate standalone card styles.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

const CARD = {
title: 'Dispatch inbox',
}

export default function App() {
return (
<View style={styles.screen}>
<Text style={styles.title}>Inbox</Text>
<View style={styles.card}>
<View style={styles.thumbnail} />
<Text style={styles.cardTitle}>{CARD.title}</Text>
</View>
</View>
)
}

const styles = StyleSheet.create({
card: {
backgroundColor: '#fff',
borderRadius: 18,
overflow: 'hidden',
},
cardTitle: {
color: '#0f172a',
fontSize: 16,
fontWeight: '700',
padding: 14,
},
screen: {
backgroundColor: '#f8fafc',
flex: 1,
justifyContent: 'center',
paddingHorizontal: 20,
},
thumbnail: {
backgroundColor: '#cbd5e1',
height: 160,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
marginBottom: 12,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add an overlay on top of the thumbnail card that says `Login required`.
The overlay should cover the thumbnail with a black background at 50% opacity.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

const CARD = {
title: 'Dispatch inbox',
}

export default function App() {
return (
<View style={styles.screen}>
<Text style={styles.title}>Inbox</Text>
<View style={styles.card}>
<View style={styles.thumbnail} />
<View pointerEvents="none" style={styles.overlay}>
<Text style={styles.overlayText}>Login required</Text>
</View>
<Text style={styles.cardTitle}>{CARD.title}</Text>
</View>
</View>
)
}

const styles = StyleSheet.create({
overlay: {
...StyleSheet.absoluteFill,
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
borderTopLeftRadius: 18,
borderTopRightRadius: 18,
justifyContent: 'center',
},
overlayText: {
color: '#fff',
fontSize: 16,
fontWeight: '700',
},
card: {
backgroundColor: '#fff',
borderRadius: 18,
overflow: 'hidden',
},
cardTitle: {
color: '#0f172a',
fontSize: 16,
fontWeight: '700',
padding: 14,
},
screen: {
backgroundColor: '#f8fafc',
flex: 1,
justifyContent: 'center',
paddingHorizontal: 20,
},
thumbnail: {
backgroundColor: '#cbd5e1',
height: 160,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
marginBottom: 12,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 1
inputs:
files:
- app/App.tsx
requirements:
- id: overlay-covers-thumbnail-with-stylesheet-helper
description: Must position the thumbnail overlay with `StyleSheet.absoluteFill`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could add "must not use deprecated StyleSheet.absoluteFillObject" (removed in 0.85 btw)

- id: overlay-background-color-rgba
description: Must have a background color of `rgba(0, 0, 0, 0.5)`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

export default function App() {
return (
<View style={styles.screen}>
<Text style={styles.title}>Settings</Text>
<View style={styles.panel}>
<View style={styles.row}>
<Text style={styles.rowLabel}>Notifications</Text>
</View>
<View style={styles.row}>
<Text style={styles.rowLabel}>Theme</Text>
</View>
<View style={styles.row}>
<Text style={styles.rowLabel}>Privacy</Text>
</View>
</View>
</View>
)
}

const styles = StyleSheet.create({
panel: {
backgroundColor: '#fff',
borderRadius: 16,
overflow: 'hidden',
},
row: {
paddingHorizontal: 16,
paddingVertical: 16,
},
rowLabel: {
color: '#0f172a',
fontSize: 16,
fontWeight: '600',
},
screen: {
backgroundColor: '#f8fafc',
flex: 1,
justifyContent: 'center',
paddingHorizontal: 20,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
marginBottom: 12,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add a divider between each settings rows.
The divider should be a thin hairline separator and have black color.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

function Divider() {
return <View style={styles.divider} />
}

export default function App() {
return (
<View style={styles.screen}>
<Text style={styles.title}>Settings</Text>
<View style={styles.panel}>
<View style={styles.row}>
<Text style={styles.rowLabel}>Notifications</Text>
</View>
<Divider />
<View style={styles.row}>
<Text style={styles.rowLabel}>Theme</Text>
</View>
<Divider />
<View style={styles.row}>
<Text style={styles.rowLabel}>Privacy</Text>
</View>
</View>
</View>
)
}

const styles = StyleSheet.create({
panel: {
backgroundColor: '#fff',
borderRadius: 16,
overflow: 'hidden',
},
divider: {
backgroundColor: '#000',
height: StyleSheet.hairlineWidth,
},
row: {
paddingHorizontal: 16,
paddingVertical: 16,
},
rowLabel: {
color: '#0f172a',
fontSize: 16,
fontWeight: '600',
},
screen: {
backgroundColor: '#f8fafc',
flex: 1,
justifyContent: 'center',
paddingHorizontal: 20,
},
title: {
color: '#0f172a',
fontSize: 24,
fontWeight: '700',
marginBottom: 12,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1
inputs:
files:
- app/App.tsx
requirements:
- id: reusable-divider-component-present
description: Must render a divider component between each row.
- id: divider-uses-hairline-width
description: Must use `StyleSheet.hairlineWidth` for the divider thickness.
- id: divider-color-light-gray
description: Must use backgroundColor for the divider color.
Loading