Skip to content

Commit

Permalink
馃 Merge PR #69590 Add Types for react-smartbanner by @PCOffline
Browse files Browse the repository at this point in the history
Co-authored-by: Eldar Bakerman <eldar@tictuk.com>
  • Loading branch information
PCOffline and Eldar Bakerman committed May 16, 2024
1 parent 34f621f commit ab5017e
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 0 deletions.
5 changes: 5 additions & 0 deletions types/react-smartbanner/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
28 changes: 28 additions & 0 deletions types/react-smartbanner/index.d.ts
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;
20 changes: 20 additions & 0 deletions types/react-smartbanner/package.json
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"
}
]
}
63 changes: 63 additions & 0 deletions types/react-smartbanner/react-smartbanner-tests.tsx
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={() => {}}
/>
);
};
20 changes: 20 additions & 0 deletions types/react-smartbanner/tsconfig.json
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"
]
}

0 comments on commit ab5017e

Please sign in to comment.