-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃 Merge PR #69590 Add Types for react-smartbanner by @PCOffline
Co-authored-by: Eldar Bakerman <eldar@tictuk.com>
- Loading branch information
Showing
5 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!**/*.d.ts | ||
!**/*.d.cts | ||
!**/*.d.mts | ||
!**/*.d.*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference types="react" /> | ||
|
||
type Stores = "ios" | "android" | "windows" | "kindle"; | ||
type StoreObject = Partial<Record<Stores, string>>; | ||
|
||
interface Props { | ||
position: "top" | "bottom"; | ||
daysHidden?: number; | ||
daysReminder?: number; | ||
appStoreLanguage?: string; | ||
title?: string; | ||
author?: string; | ||
button?: React.ReactNode; | ||
storeText?: StoreObject; | ||
price?: StoreObject; | ||
url?: StoreObject; | ||
appMeta?: StoreObject; | ||
force?: Stores; | ||
ignoreIosVersion?: boolean; | ||
onClose?: () => void; | ||
onInstall?: () => void; | ||
} | ||
|
||
declare const SmartBanner: React.FC<Props>; | ||
|
||
declare module "dist/main.css"; | ||
|
||
export = SmartBanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"private": true, | ||
"name": "@types/react-smartbanner", | ||
"version": "5.1.9999", | ||
"projects": [ | ||
"https://github.com/patw0929/react-smartbanner#readme" | ||
], | ||
"dependencies": { | ||
"@types/react": "^18.3.9999" | ||
}, | ||
"devDependencies": { | ||
"@types/react-smartbanner": "workspace:." | ||
}, | ||
"owners": [ | ||
{ | ||
"name": "Eldar Bakerman", | ||
"githubUsername": "PCOffline" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from "react"; | ||
import SmartBanner from "react-smartbanner"; | ||
import "react-smartbanner/dist/main.css"; | ||
|
||
const EmptySmartBanner: React.FC = () => { | ||
// @ts-expect-error required parameter 'position' is missing | ||
return <SmartBanner />; | ||
}; | ||
|
||
const CorrectStoreObject: React.FC = () => { | ||
return <SmartBanner position="bottom" storeText={{ ios: "hello" }} />; | ||
}; | ||
|
||
const WrongStoreObject: React.FC = () => { | ||
// @ts-expect-error invalid field 'blabla' | ||
return <SmartBanner position="bottom" storeText={{ blabla: "hello", ios: "hello" }} />; | ||
}; | ||
|
||
const ValidSmartBanner: React.FC = () => { | ||
return <SmartBanner position="top" />; | ||
}; | ||
|
||
const FullSmartBanner: React.FC = () => { | ||
return ( | ||
<SmartBanner | ||
position="bottom" | ||
author="Myself" | ||
force="ios" | ||
appStoreLanguage="us" | ||
title="My Banner" | ||
daysHidden={15} | ||
daysReminder={90} | ||
ignoreIosVersion | ||
appMeta={{ | ||
ios: "apple-itunes-app", | ||
android: "google-play-app", | ||
windows: "msApplication-ID", | ||
kindle: "kindle-fire-app", | ||
}} | ||
url={{ | ||
ios: "", | ||
android: "", | ||
windows: "", | ||
kindle: "", | ||
}} | ||
storeText={{ | ||
ios: "On the App Store", | ||
android: "In Google Play", | ||
windows: "In Windows Store", | ||
kindle: "In the Amazon Appstore", | ||
}} | ||
price={{ | ||
ios: "Free", | ||
android: "Free", | ||
windows: "Free", | ||
kindle: "Free", | ||
}} | ||
button={<button>Click Me!</button>} | ||
onClose={() => {}} | ||
onInstall={() => {}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "node16", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react" | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"react-smartbanner-tests.tsx" | ||
] | ||
} |