-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path05-react-native.js
More file actions
56 lines (46 loc) · 1.59 KB
/
Copy path05-react-native.js
File metadata and controls
56 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Embed - https://codepen.io/ThatGuySam/pen/abVWjzp
// Expo Snack - https://snack.expo.dev/@thatguysam/vumbnail-react-native-demo
// Expo Snack Embeddind Docs - https://docs.expo.dev/workflow/snack/#embed-it-on-your-website
export const title = 'React Native'
export const description = 'Vumbnail example for embedding iamge in React Native'
export class ReactNativeExample {
constructor ( options = {} ) {
this.videoId = options.videoId
}
title = title
description = description
template () {
return `
import * as React from 'react';
import { Image } from 'react-native'
<Image
style={{ width: 320, height: 180 }}
source={{
uri: 'https://vumbnail.com/${ this.videoId }.jpg',
}}
/>
`
}
embedHtml () {
const encodeTitle = encodeURIComponent( this.title )
const encodeDescription = encodeURIComponent( this.description )
const encodedExampleCode = encodeURIComponent( this.template() )
return /* html */`
<div
data-snack-code="${ encodedExampleCode }"
data-snack-dependencies="expo-constants%2Clodash%404"
data-snack-name="${ encodeTitle }"
data-snack-description="${ encodeDescription }"
data-snack-preview="true"
data-snack-platform="web"
style="overflow:hidden;background:#fafafa;border:1px solid rgba(0,0,0,.08);border-radius:4px;height:505px;width:100%">
</div>
`
}
embedScript () {
return {
async: true,
src = 'https://snack.expo.dev/embed.js',
}
}
}