Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCE] Types Enhancement #9

Merged
merged 3 commits into from
Apr 3, 2021
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.tgz
example/android/local.properties
node_modules/
node_modules/
.DS_Store
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<p align="center">
<a href="https://www.npmjs.com/package/react-native-gif-search"><img alt="npm downloads" src="https://img.shields.io/npm/dm/react-native-gif-search.svg"/></a>
<a href="https://www.npmjs.com/package/react-native-gif-search"><img alt="npm version" src="https://badge.fury.io/js/react-native-gif-search.svg"/></a>
<a href="https://www.npmjs.com/package/react-native-gif-search"><img alt="typescript" src="https://flat.badgen.net/badge/Built%20With/TypeScript/blue"/></a>
</p>

<p align="center">
Expand Down
205 changes: 205 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
declare module 'react-native-gif-search' {
import React from 'react';
import { TextInputProps, TextStyle, ViewStyle } from 'react-native';

enum Providers {
TENOR = 'tenor',
GIPHY = 'giphy',
ALL = 'all',
}

enum GifTypes {
GIF = 'gif',
STICKER = 'sticker',
ALL = 'all',
}

interface BaseImage {
url: string;
width: string;
height: string;
}

type Rating = "y" | "g" | "pg" | "pg-13" | "r";

interface GiphyImages {
fixed_height: BaseImage & {
size: string;
mp4: string;
mp4_size: string;
webp: string;
webp_size: string;
};
fixed_height_still: BaseImage;
fixed_height_downsampled: BaseImage & {
size: string;
webp: string;
webp_size: string;
};
fixed_width: BaseImage & {
size: string;
mp4: string;
mp4_size: string;
webp: string;
webp_size: string;
};
original_still: BaseImage;
fixed_width_still: BaseImage;
fixed_width_downsampled: BaseImage & {
size: string;
webp: string;
webp_size: string;
};
fixed_height_small: BaseImage & {
size: string;
mp4: string;
mp4_size: string;
webp: string;
webp_size: string;
};
fixed_height_small_still: BaseImage;
fixed_width_small: BaseImage & {
size: string;
mp4: string;
mp4_size: string;
webp: string;
webp_size: string;
};
fixed_width_small_still: BaseImage;
downsized: BaseImage & {
size: string;
};
downsized_still: BaseImage;
downsized_large: BaseImage & {
size: string;
};
downsized_medium: BaseImage & {
size: string;
};
downsized_small: BaseImage & {
size: string;
};
original: BaseImage & {
size: string;
frames: string;
mp4: string;
mp4_size: string;
webp: string;
webp_size: string;
};
looping: { mp4: string };
preview: {
width: string;
height: string;
mp4: string;
mp4_size: string;
};
preview_gif: BaseImage & {
size: string;
};
}

export interface GiphyGIFObject {
type: string;
id: string;
slug: string;
url: string;
bitly_url: string;
embed_url: string;
username: string;
source: string;
rating: Rating;
content_url: string;
user?: {
avatar_url: string;
banner_url: string;
profile_url: string;
username: string;
display_name: string;
twitter: string;
};
source_tld: string;
source_post_url: string;
update_datetime: string;
create_datetime: string;
import_datetime: string;
trending_datetime: string;
title: string;
images: GiphyImages;
}

interface TenorGifFormats {
gif: string;
mediumgif: string;
tinygif: string;
nanogif: string;
mp4: string;
loopedmp4: string;
tinymp4: string;
nanomp4: string;
webm: string;
tinywebm: string;
nanowebm: string;
}

interface TenorMediaObject {
preview: string;
url: string;
dims: number[];
size: number;
}

export interface TenorGIFObject {
created: number;
hasaudio: boolean;
id: string;
media: { [key in keyof TenorGifFormats]: keyof TenorMediaObject }[];
tags: string[];
title: string;
itemurl: string;
hascaption: boolean;
url: string;
}

export interface GifSearchProps {
visible?: boolean;
gifsToLoad?: number;
maxGifsToLoad?: number;
giphyApiKey?: string;
tenorApiKey?: string;
showScrollBar?: boolean;
stickersPlaceholderText?: string;
noGifsFoundText?: string;
horizontal?: boolean;
numColumns?: number;
provider?: keyof typeof Providers;
providerLogo?: string;
gifType?: keyof typeof GifTypes;
showGifsButtonText?: string;
showStickersButtonText?: string;
placeholderTextColor?: string;
loadingSpinnerColor?: string;

style?: ViewStyle;
textInputStyle?: TextStyle;
gifListStyle?: ViewStyle;
gifStyle?: ViewStyle;
placeholderText?: string;
noGifsFoundTextStyle?: TextStyle;

textInputProps?: TextInputProps;

onError?: (error: ErrorEvent) => void;
onGifSelected: (
gifUrl: string,
gifObject: GiphyGIFObject | TenorGIFObject
) => void;
onGifLongPress?: (
gifUrl: string,
gifObject: GiphyGIFObject | TenorGIFObject
) => void;
onBackPressed?: () => void;
}

export const GifSearch: (props: GifSearchProps) => JSX.Element;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.5",
"description": "An easy-to-use, highly customizable react-native package for searching and selecting from a list of gifs and/or stickers using the Tenor and/or the Giphy API",
"main": "index.js",
"types": "./index.d.ts",
"publishConfig": {
"registry":"https://npm.pkg.github.com/"
},
Expand Down
6 changes: 6 additions & 0 deletions ts-example/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
3 changes: 3 additions & 0 deletions ts-example/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files
[*.bat]
end_of_line = crlf
4 changes: 4 additions & 0 deletions ts-example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
3 changes: 3 additions & 0 deletions ts-example/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
59 changes: 59 additions & 0 deletions ts-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
7 changes: 7 additions & 0 deletions ts-example/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
16 changes: 16 additions & 0 deletions ts-example/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"prettier.eslintIntegration": true,
"editor.formatOnSave": true,
"files.exclude": {
"**/*.git": true,
".*": true,
"**/*.DS_Store": true,
"node_modules/": true
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
}
1 change: 1 addition & 0 deletions ts-example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading