diff --git a/types/index-tests.tsx b/types/index-tests.tsx new file mode 100644 index 0000000..964df94 --- /dev/null +++ b/types/index-tests.tsx @@ -0,0 +1,292 @@ +import * as React from "react"; +import { TwitterTimelineEmbed, TwitterFollowButton, TwitterHashtagButton, TwitterShareButton, TwitterMentionButton, TwitterTweetEmbed, TwitterMomentShare, TwitterDMButton, TwitterVideoEmbed, TwitterOnAirButton } from "."; + +export const example = () => ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <> + + + + <> + + + + + <> + + + + + + + + { + const tweetEl = tweetWidgetEl.shadowRoot.querySelector( + ".EmbeddedTweet" + ); + tweetEl.style.border = "5px solid red"; + }} + /> + + + + + + + + + +); diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..852ca3e --- /dev/null +++ b/types/index.d.ts @@ -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 {} + +type TwitterFollowButtonProps = { + screenName: string + options?: any +} + +export class TwitterFollowButton extends React.Component {} + +type TwitterHashtagButtonProps = { + tag: string + options?: any +} + +export class TwitterHashtagButton extends React.Component {} + +type TwitterShareButtonProps = { + url: string + options?: any +} + +export class TwitterShareButton extends React.Component {} + +type TwitterMentionButtonProps = { + screenName: string + options?: any +} + +export class TwitterMentionButton extends React.Component {} + +type TwitterTweetEmbedProps = { + tweetId: string + options?: any + onLoaded?: (elm: any) => void +} + +export class TwitterTweetEmbed extends React.Component {} + +type TwitterMomentShareProps = { + momentId: string + options?: any +} + +export class TwitterMomentShare extends React.Component {} + +type TwitterDMButtonProps = { + id: number + options?: any +} + +export class TwitterDMButton extends React.Component {} + +type TwitterVideoEmbedProps = { + id: string +} + +export class TwitterVideoEmbed extends React.Component {} + +type TwitterOnAirButtonProps = { + username: string + options?: any +} + +export class TwitterOnAirButton extends React.Component {} diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..3a34ce8 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "lib": [ + "es6", + "dom" + ], + "module": "commonjs", + "noEmit": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "typeRoots": [ + "../" + ], + "types": [] + }, + "files": [ + "index.d.ts", + "index-tests.tsx" + ] +}