Skip to content
Open
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
292 changes: 292 additions & 0 deletions types/index-tests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
import * as React from "react";
import { TwitterTimelineEmbed, TwitterFollowButton, TwitterHashtagButton, TwitterShareButton, TwitterMentionButton, TwitterTweetEmbed, TwitterMomentShare, TwitterDMButton, TwitterVideoEmbed, TwitterOnAirButton } from ".";

export const example = () => (
<>
<TwitterTimelineEmbed
sourceType={"profile"}
screenName={"saurabhnemade"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"profile"}
userId={1934309676}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"likes"}
screenName={"saurabhnemade"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"likes"}
userId={1934309676}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"list"}
ownerScreenName={"palafo"}
slug={"breakingnews"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"list"}
id={8044403}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"collection"}
id={"576828964162965504"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"url"}
url={"https://twitter.com/NYTNow/timelines/576828964162965504"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"url"}
url={"https://twitter.com/rahul581"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"url"}
url={"https://twitter.com/mashable/lists/social-media"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"url"}
url={"https://twitter.com/ladygaga/likes"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"widget"}
widgetId={"539487832448843776"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"widget"}
widgetId={"539487832448843776"}
autoHeight
/>
<TwitterTimelineEmbed
sourceType={"widget"}
widgetId={"539487832448843776"}
autoHeight
/>
<TwitterTimelineEmbed
sourceType={"widget"}
widgetId={"539487832448843776"}
autoHeight
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"light"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
linkColor={"#F44336"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
linkColor={"#CDDC39"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
linkColor={"#4CAF50"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
borderColor={"#F44336"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
borderColor={"#CDDC39"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
borderColor={"#4CAF50"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
noHeader
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
noFooter
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
noHeader
noFooter
options={{ height: 400 }}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
options={{ height: 400 }}
theme={"dark"}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
noBorders
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
options={{ height: 400 }}
theme={"dark"}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
noScrollbar
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
options={{ height: 400 }}
theme={"dark"}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
transparent
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
options={{ height: 400 }}
theme={"dark"}
lang={"hi"}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
lang={"es"}
/>
<TwitterTimelineEmbed
sourceType={"timeline"}
id={"539487832448843776"}
theme={"dark"}
options={{ height: 400 }}
lang={"fr"}
/>
<TwitterShareButton
url={"https://facebook.com/saurabhnemade"}
options={{ text: "#reactjs is awesome", via: "saurabhnemade" }}
/>
<TwitterShareButton
url={"https://facebook.com/saurabhnemade"}
options={{
text: "#reactjs is awesome",
via: "saurabhnemade",
size: "large"
}}
/>
<>
<TwitterFollowButton screenName={"saurabhnemade"} />
<TwitterFollowButton
screenName={"saurabhnemade"}
options={{ size: "large" }}
/>
</>
<>
<TwitterHashtagButton tag={"cybersecurity"} />
<TwitterHashtagButton tag={"cybersecurity"} options={{ size: "large" }} />
</>

<>
<TwitterMentionButton screenName={"saurabhnemade"} />
<TwitterMentionButton
screenName={"saurabhnemade"}
options={{ size: "large" }}
/>
</>

<TwitterTweetEmbed tweetId={"933354946111705097"} />
<TwitterTweetEmbed tweetId={"1083592734038929408"} />
<TwitterTweetEmbed
tweetId={"1083592734038929408"}
options={{ cards: "hidden" }}
/>
<TwitterTweetEmbed
tweetId={"1083592734038929408"}
onLoaded={tweetWidgetEl => {
const tweetEl = tweetWidgetEl.shadowRoot.querySelector(
".EmbeddedTweet"
);
tweetEl.style.border = "5px solid red";
}}
/>
<TwitterMomentShare momentId="650667182356082688" />
<TwitterDMButton id={1364031673} />
<TwitterDMButton id={1364031673} options={{ size: "large" }} />

<TwitterVideoEmbed id={"560070183650213889"} />

<TwitterOnAirButton username={"KatmaiNPS"} />
<TwitterOnAirButton username={"KatmaiNPS"} options={{ size: "large" }} />
</>
);
90 changes: 90 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import * as React from 'react'

type TwitterTimelineEmbedBaseProps = {
options?: any
autoHeight?: boolean
theme?: 'dark' | 'light'
linkColor?: string
borderColor?: string
noHeader?: boolean
noFooter?: boolean
noBorders?: boolean
noScrollbar?: boolean
transparent?: boolean
lang?: string
}

type TwitterTimelineEmbedProps =
| TwitterTimelineEmbedBaseProps & { sourceType: 'profile' | 'likes', screenName: string }
| TwitterTimelineEmbedBaseProps & { sourceType: 'profile' | 'likes', userId: number }
| TwitterTimelineEmbedBaseProps & { sourceType: 'list', ownerScreenName: string, slug: string }
| TwitterTimelineEmbedBaseProps & { sourceType: 'list', id: number }
| TwitterTimelineEmbedBaseProps & { sourceType: 'collection', id: string }
| TwitterTimelineEmbedBaseProps & { sourceType: 'url', url: string }
| TwitterTimelineEmbedBaseProps & { sourceType: 'widget', widgetId: string }
| TwitterTimelineEmbedBaseProps & { sourceType: 'timeline', id: string }

export class TwitterTimelineEmbed extends React.Component<TwitterTimelineEmbedProps> {}

type TwitterFollowButtonProps = {
screenName: string
options?: any
}

export class TwitterFollowButton extends React.Component<TwitterFollowButtonProps> {}

type TwitterHashtagButtonProps = {
tag: string
options?: any
}

export class TwitterHashtagButton extends React.Component<TwitterHashtagButtonProps> {}

type TwitterShareButtonProps = {
url: string
options?: any
}

export class TwitterShareButton extends React.Component<TwitterShareButtonProps> {}

type TwitterMentionButtonProps = {
screenName: string
options?: any
}

export class TwitterMentionButton extends React.Component<TwitterMentionButtonProps> {}

type TwitterTweetEmbedProps = {
tweetId: string
options?: any
onLoaded?: (elm: any) => void
}

export class TwitterTweetEmbed extends React.Component<TwitterTweetEmbedProps> {}

type TwitterMomentShareProps = {
momentId: string
options?: any
}

export class TwitterMomentShare extends React.Component<TwitterMomentShareProps> {}

type TwitterDMButtonProps = {
id: number
options?: any
}

export class TwitterDMButton extends React.Component<TwitterDMButtonProps> {}

type TwitterVideoEmbedProps = {
id: string
}

export class TwitterVideoEmbed extends React.Component<TwitterVideoEmbedProps> {}

type TwitterOnAirButtonProps = {
username: string
options?: any
}

export class TwitterOnAirButton extends React.Component<TwitterOnAirButtonProps> {}
Loading