Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit be7cdf1

Browse files
Filipe Medeirosthemariamarques
Filipe Medeiros
authored andcommitted
chore(typescript): add type declaration file for module
Add Typescript dependencies (ts, react and react-dom) and add an initial declaration file. No source files were modified.
1 parent bf11d86 commit be7cdf1

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed

index.d.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Component, FC, ReactElement, ReactNode } from "react";
2+
3+
type BreakpointNames = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
4+
5+
type InitialBreakpoints = BreakpointNames | '_initial'
6+
7+
type MediaQueries = {
8+
[mq in InitialBreakpoints]?: string
9+
}
10+
11+
type MediaTypeMapping = boolean
12+
13+
type IsCalculated = boolean
14+
15+
type MediaTypeMap = {
16+
[mt in InitialBreakpoints]?: MediaTypeMapping
17+
}
18+
19+
type Orientation = 'portrait' | 'landscape' | null
20+
21+
interface ResponsiveContext {
22+
isCalculated: IsCalculated,
23+
mediaType: InitialBreakpoints,
24+
lessThan: MediaTypeMap,
25+
greaterThan: MediaTypeMap,
26+
is: MediaTypeMap,
27+
orientation: Orientation,
28+
}
29+
30+
interface IsMobile {
31+
isCalculated: IsCalculated,
32+
isMobile: MediaTypeMapping,
33+
}
34+
35+
type Breakpoints = {
36+
[bp in BreakpointNames]?: string
37+
}
38+
39+
interface ResponsiveProps {
40+
children: ReactNode,
41+
}
42+
43+
interface ResponsiveProviderProps {
44+
initialMediaType?: InitialBreakpoints,
45+
defaultOrientation?: Orientation,
46+
children: ReactNode,
47+
breakpoints?: Breakpoints,
48+
breakpointsMax?: Breakpoints,
49+
mediaQueries?: MediaQueries,
50+
}
51+
52+
interface WithResponsiveProps {
53+
responsive: ResponsiveContext
54+
}
55+
56+
export const ResponsiveProvider: FC<ResponsiveProviderProps>
57+
58+
export const useResponsive: () => ResponsiveContext
59+
60+
export const Responsive: FC<ResponsiveProps>
61+
62+
export const withResponsive: <P = {}>(Component: Component) =>
63+
(props: P) => ReactElement<P & WithResponsiveProps>
64+
65+
export const withIsMobile: <P = {}>(Component: Component) =>
66+
(props: P) => ReactElement<P & IsMobile>
67+
68+
export const useIsMobile: () => IsMobile

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
"@semantic-release/git": "^9.0.0",
6767
"@testing-library/jest-dom": "^5.8.0",
6868
"@testing-library/react": "^10.0.4",
69+
"@types/react": "^16.9.56",
70+
"@types/react-dom": "^16.9.9",
6971
"babel-eslint": "^10.1.0",
7072
"babel-plugin-add-module-exports": "^1.0.2",
7173
"commitlint": "^8.0.0",
@@ -86,6 +88,7 @@
8688
"react-dom": "^16.9.0",
8789
"react-test-renderer": "^15.6.2",
8890
"rimraf": "^3.0.2",
89-
"semantic-release": "^17.1.1"
91+
"semantic-release": "^17.1.1",
92+
"typescript": "^4.0.5"
9093
}
9194
}

yarn.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,13 @@
15821582
dependencies:
15831583
"@types/react" "*"
15841584

1585+
"@types/react-dom@^16.9.9":
1586+
version "16.9.9"
1587+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.9.tgz#d2d0a6f720a0206369ccbefff752ba37b9583136"
1588+
integrity sha512-jE16FNWO3Logq/Lf+yvEAjKzhpST/Eac8EMd1i4dgZdMczfgqC8EjpxwNgEe3SExHYLliabXDh9DEhhqnlXJhg==
1589+
dependencies:
1590+
"@types/react" "*"
1591+
15851592
"@types/react@*":
15861593
version "16.9.35"
15871594
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368"
@@ -1590,6 +1597,14 @@
15901597
"@types/prop-types" "*"
15911598
csstype "^2.2.0"
15921599

1600+
"@types/react@^16.9.56":
1601+
version "16.9.56"
1602+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.56.tgz#ea25847b53c5bec064933095fc366b1462e2adf0"
1603+
integrity sha512-gIkl4J44G/qxbuC6r2Xh+D3CGZpJ+NdWTItAPmZbR5mUS+JQ8Zvzpl0ea5qT/ZT3ZNTUcDKUVqV3xBE8wv/DyQ==
1604+
dependencies:
1605+
"@types/prop-types" "*"
1606+
csstype "^3.0.2"
1607+
15931608
"@types/retry@^0.12.0":
15941609
version "0.12.0"
15951610
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
@@ -2950,6 +2965,11 @@ csstype@^2.2.0:
29502965
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
29512966
integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==
29522967

2968+
csstype@^3.0.2:
2969+
version "3.0.4"
2970+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.4.tgz#b156d7be03b84ff425c9a0a4b1e5f4da9c5ca888"
2971+
integrity sha512-xc8DUsCLmjvCfoD7LTGE0ou2MIWLx0K9RCZwSHMOdynqRsP4MtUcLeqh1HcQ2dInwDTqn+3CE0/FZh1et+p4jA==
2972+
29532973
currently-unhandled@^0.4.1:
29542974
version "0.4.1"
29552975
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
@@ -9176,6 +9196,11 @@ typedarray@^0.0.6:
91769196
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
91779197
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
91789198

9199+
typescript@^4.0.5:
9200+
version "4.0.5"
9201+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
9202+
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
9203+
91799204
ua-parser-js@^0.7.18:
91809205
version "0.7.21"
91819206
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"

0 commit comments

Comments
 (0)