Skip to content

Add Typescript definition file. #10

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.34.02",
"description": "Responsive grid for React Native based on react-native-flexbox-grid",
"main": "src/index.js",
"types": "src/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/idibidiart/react-native-responsive-grid.git"
Expand All @@ -20,5 +21,8 @@
"url": "https://github.com/idibidiart/react-native-responsive-grid/issues"
},
"homepage": "https://github.com/idibidiart/react-native-responsive-grid#readme",
"dependencies": {}
"dependencies": {
"@types/react": "^16.0.25",
"@types/react-native": "^0.50.7"
}
}
74 changes: 74 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
declare module "react-native-responsive-grid" {
import { Component } from "react";
import { ViewProperties } from "react-native";

export interface GridProps {

}

export interface ColumnProps {
size?: number,
sizePoints?: number,
offset?: number,
offsetPoints?: number,
smSize?: number,
smSizePoints?: number,
smOffset?: number,
smOffsetPoints?: number,
smHidden?: boolean,
mdSize?: number,
mdSizePoints?: number,
mdOffset?: number,
mdOffsetPoints?: number,
mdHidden?: boolean,
lgSize?: number,
lgSizePoints?: number,
lgOffset?: number,
lgOffsetPoints?: number,
lgHidden?: boolean,
xlSize?: number,
xlSizePoints?: number,
xlOffset?: number,
xlOffsetPoints?: number,
xlHidden?: boolean,
vAlign?: 'space' | 'distribute' | 'middle' | 'bottom' | 'top',
hAlign?: 'stretch' | 'center' | 'right' | 'left',
alignSelf?: 'auto' | 'top' | 'bottom' | 'middle' | 'stretch' | 'baseline',
fullWidth?: boolean,
aspectRatio?: object
}

export interface RowProps {
rtl?: boolean,
noWrap?: boolean,
hAlign?: 'space' | 'distribute' | 'center' | 'left' | 'right',
vAlign?: 'stretch' | 'middle' | 'right' | 'left',
alignSelf?: 'auto' | 'left' | 'right' | 'center' | 'stretch',
fullHeight?: boolean,
alignLines?: string,
size?: number,
sizePoints?: number
smSizePoints?: number,
mdSizePoints?: number,
lgSizePoints?: number,
xlSizePoints?: number
}

export type AspectRatio = '16:9' | '16:10' | '3:2' | '4:3' | '1:1' |'4:3' | '3:2' | '16:10' | '16:9'

export class Row extends Component<ViewProperties & RowProps, any> { }
export class Column extends Component<ViewProperties & ColumnProps, any> { }
export class Grid extends Component<ViewProperties & GridProps, any> { }

export interface ScreenParams {
mediaSize: 'sm' | 'md' | 'lg' | 'xl',
width: number,
height: number,
aspectRatio?: {
currentNearestRatio: AspectRatio,
currentOrientation: 'square' | 'landscape' | 'portrait'
}
}

export function ScreenInfo(onlySize?: boolean): ScreenParams;
}