Skip to content

Commit

Permalink
Add fonts to ConnectJS initialize method (#74)
Browse files Browse the repository at this point in the history
* Add `fonts` to ConnectJS initialize method

* Address feedback
  • Loading branch information
slye-stripe authored Nov 21, 2023
1 parent e9f0478 commit 7b2fec6
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions types/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,56 @@ export declare type LoadConnectAndInitialize = (

export declare type OverlayOption = "dialog" | "drawer";

/*
* Use a `CssFontSource` to pass custom fonts via a stylesheet URL when initializing a Connect instance.
*/
export declare type CssFontSource = {
/**
* A relative or absolute URL pointing to a CSS file with [@font-face](https://developer.mozilla.org/en/docs/Web/CSS/@font-face) definitions, for example:
*
* https://fonts.googleapis.com/css?family=Open+Sans
*
* Note that if you are using a [content security policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) (CSP), [additional directives](https://stripe.com/docs/security#content-security-policy) may be necessary.
*/
cssSrc: string;
};

/*
* Use a `CustomFontSource` to pass custom fonts when initializing a Connect instance.
*/
export declare type CustomFontSource = {
/**
* The name to give the font
*/
family: string;

/**
* A valid [src](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src) value pointing to your custom font file.
* This is usually (though not always) a link to a file with a `.woff` , `.otf`, or `.svg` suffix.
*/
src: string;

/**
* A valid [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display) value.
*/
display?: string;

/**
* Defaults to `normal`.
*/
style?: "normal" | "italic" | "oblique";

/**
* A valid [unicode-range](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range) value.
*/
unicodeRange?: string;

/**
* A valid [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight), as a string.
*/
weight?: string;
};

/**
* Appearance options for the Connect instance.
*/
Expand Down Expand Up @@ -354,6 +404,11 @@ export interface IStripeConnectInitParams {
* The locale to use for the Connect instance.
*/
locale?: string;

/**
* An array of custom fonts, which embedded components created from a ConnectInstance can use.
*/
fonts?: Array<CssFontSource | CustomFontSource>;
}

type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
Expand Down

0 comments on commit 7b2fec6

Please sign in to comment.