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

no support for tsx #39

Open
ahmedfadhil opened this issue Feb 2, 2022 · 3 comments
Open

no support for tsx #39

ahmedfadhil opened this issue Feb 2, 2022 · 3 comments

Comments

@ahmedfadhil
Copy link

ahmedfadhil commented Feb 2, 2022

how to use this library with cra and tsx? there is no way to import it. It keeps complaining that module not found!

@vpachedzhi
Copy link

Just create a file ending with .d.ts and write this line in it

declare module '@ideasio/add-to-homescreen-react';

@maisoncastro
Copy link

Doesn't work sadly.

@HypernovaTX
Copy link

HypernovaTX commented Nov 17, 2022

I'm late for this but I would suggest to create a new *.d.ts file like global.d.ts at the root src directory (same directory as App.tsx).

Then paste this in the *.d.ts file you just created (I went over the source code and documentations over the types:

declare module '@ideasio/add-to-homescreen-react' {
  interface PlatformPropType {
    showClasses?: string[];
    targetUrl?: string;
    images?: { src?: string; alt?: string }[];
    action?: { ok?: string; cancel?: string; guidanceCancel?: string };
  }
  interface AddToHomeScreenProps {
    appId?: string;
    debug?: boolean;
    activateLogging?: boolean;
    startAutomatically?: boolean;
    skipFirstVisit?: boolean;
    minPageViews?: number;
    startDelay?: number;
    lifespan?: number;
    displayPace?: number;
    mustShowCustomPrompt?: boolean;
    maxDisplayCount?: number;
    validLocation?: RegExp[];
    onInit?: () => void;
    onShow?: () => void;
    onAdd?: () => void;
    onInstall?: () => void;
    onCancel?: () => void;
    showClasses?: string[];
    showClass?: string;
    hideClass?: string;
    customCriteria?: null | (() => void) | boolean;
    customPromptContent?: {
      title?: string;
      src?: string;
      cancelMsg?: string;
      installMsg?: string;
      guidanceCancelMsg?: string;
    };
    customPromptElements?: {
      container?: string;
      containerAddOns?: string;
      banner?: string;
      bannerAddOns?: string;
      logoCell?: string;
      logoCellAddOns?: string;
      logo?: string;
      logoAddOns?: string;
      titleCell?: string;
      titleCellAddOns?: string;
      title?: string;
      titleAddOns?: string;
      cancelButtonCell?: string;
      cancelButtonCellAddOns?: string;
      cancelButton?: string;
      cancelButtonAddOns?: string;
      installButtonCell?: string;
      installButtonCellAddOns?: string;
      installButton?: string;
      installButtonAddOns?: string;
      guidance?: string;
      guidanceAddOns?: string;
      guidanceImageCell?: string;
      guidanceImageCellAddOns?: string;
      guidanceCancelButton?: string;
      guidanceCancelButtonAddOns?: string;
    };
    customPromptPlatformDependencies?: {
      native?: PlatformPropType;
      chromium?: PlatformPropType;
      edge?: PlatformPropType;
      iphone?: PlatformPropType;
      ipad?: PlatformPropType;
      firefox?: PlatformPropType;
      samsung?: PlatformPropType;
      opera?: PlatformPropType;
    };
  }
  declare const AddToHomeScreen: React.FC<AddToHomeScreenProps>;
  export default AddToHomeScreen;
}

Perhaps I should make a PR to include this to NPM so Typescript users would be able to use it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants