generated from sixfootsixdesigns/React-Library-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 53
/
LinkPreview.stories.tsx
75 lines (73 loc) · 2.67 KB
/
LinkPreview.stories.tsx
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from 'react';
import { storiesOf } from '@storybook/react';
import { LinkPreview } from './LinkPreview';
const customFetcher = async (url: string) => {
const response = await fetch(`https://rlp-proxy.herokuapp.com/v2?url=${url}`);
const json = await response.json();
return json.metadata;
};
storiesOf('LinkPreview', module)
.add('Default', () => <LinkPreview url='https://barcauniversal.com' />)
.add('Article', () => (
<LinkPreview url='https://barcauniversal.com/predicted-barcelona-lineup-against-eibar/' />
))
.add('Text align right', () => (
<LinkPreview
url='https://barcauniversal.com/predicted-barcelona-lineup-against-eibar/'
textAlign='right'
/>
))
.add('Custom image height', () => (
<LinkPreview
url='https://barcauniversal.com/predicted-barcelona-lineup-against-eibar/'
imageHeight='50vh'
/>
))
.add('YouTube link', () => (
<LinkPreview url='https://www.youtube.com/watch?v=JKJdGNHW1xk' width='30vw' />
))
.add('Twitter link', () => (
<LinkPreview url='https://twitter.com/BarcaUniversal/status/1396232440314830856' width='20vw' />
))
.add('Reddit link', () => (
<LinkPreview
url='https://www.reddit.com/r/LifeProTips/comments/nivqb3/lpt_if_your_your_largest_hex_key_is_to_small_you/'
width='20vw'
descriptionLength={100}
/>
))
.add('Fallback', () => <LinkPreview url='https://webzy.dev' fallback={<div>Fallback</div>} />)
.add('Colors', () => (
<LinkPreview
url='https://www.youtube.com/watch?v=dQw4w9WgXcQ'
backgroundColor='black'
primaryTextColor='white'
secondaryTextColor='#ccc'
borderColor='red'
width='30vw'
margin='30px auto'
/>
))
.add('Fallback image', () => (
<LinkPreview
url='https://google.com'
width='30vw'
fallbackImageSrc='https://www.aljazeera.com/wp-content/uploads/2021/08/2019-12-07T000000Z_879038429_RC2LQD9L67FQ_RTRMADP_3_SOCCER-SPAIN-FCB-RCD-REPORT.jpg?resize=770%2C513'
/>
))
.add('Using custom fetcher', () => (
<LinkPreview url='stripe.com' fetcher={customFetcher} fallback={<div>Fallback</div>} />
))
.add('Image onError', () => (
<LinkPreview url='https://www.brianfriel.xyz/learning-how-to-build-on-solana/' width='30vw' />
))
.add('Explicit image', () => (
<LinkPreview
url='https://barcauniversal.com/predicted-barcelona-lineup-against-eibar/'
width='30vw'
explicitImageSrc='https://barcauniversal.com/wp-content/uploads/2021/05/1002622558-2048x1365.jpg'
/>
))
.add('Explicit no image in case of no image in metadata', () => (
<LinkPreview url='https://barcauniversal.com' width='30vw' showPlaceholderIfNoImage={false} />
));