@openpass/openpass-js-sdk
Advanced tools
Comparing version 4.4.0 to 4.4.1
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SIGN_IN_BUTTON_STYLESHEET_ID = void 0; | ||
const html_1 = require("./embedded-assets/html"); | ||
@@ -17,2 +18,3 @@ const styles_1 = require("./embedded-assets/styles"); | ||
const stylesheets_1 = require("./utils/stylesheets"); | ||
exports.SIGN_IN_BUTTON_STYLESHEET_ID = "openpass-sign-in-button-stylesheet"; | ||
/** | ||
@@ -84,4 +86,6 @@ * Handles rendering and functionality of the automatically rendered sign in button. | ||
} | ||
// Inject stylesheet and fonts | ||
(0, stylesheets_1.injectStylesheetContent)((0, styles_1.createSignInButtonStylesheet)()); | ||
// Inject stylesheet and fonts if not already present | ||
if (!(0, stylesheets_1.hasStyleTagWithId)(exports.SIGN_IN_BUTTON_STYLESHEET_ID)) { | ||
(0, stylesheets_1.injectStylesheetContent)((0, styles_1.createSignInButtonStylesheet)(), exports.SIGN_IN_BUTTON_STYLESHEET_ID); | ||
} | ||
if (!(0, stylesheets_1.hasLinkRefContainingHrefText)("Poppins")) { | ||
@@ -88,0 +92,0 @@ (0, stylesheets_1.injectStylesheetLinkRef)("https://fonts.googleapis.com/css?family=Poppins"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasLinkRefContainingHrefText = exports.injectStylesheetLinkRef = exports.injectStylesheetContent = void 0; | ||
const injectStylesheetContent = (contents) => { | ||
exports.hasStyleTagWithId = exports.hasLinkRefContainingHrefText = exports.injectStylesheetLinkRef = exports.injectStylesheetContent = void 0; | ||
const injectStylesheetContent = (contents, styleTagId) => { | ||
const style = document.createElement("style"); | ||
style.innerHTML = contents; | ||
style.id = styleTagId; | ||
const head = document.getElementsByTagName("head")[0]; | ||
@@ -31,2 +32,7 @@ head.appendChild(style); | ||
exports.hasLinkRefContainingHrefText = hasLinkRefContainingHrefText; | ||
const hasStyleTagWithId = (id) => { | ||
const styleTagWithId = document.querySelector(`style[id=${id}]`); | ||
return styleTagWithId !== null; | ||
}; | ||
exports.hasStyleTagWithId = hasStyleTagWithId; | ||
//# sourceMappingURL=stylesheets.js.map |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -13,3 +13,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { SdkError } from "./error/errors"; | ||
import { hasLinkRefContainingHrefText, injectStylesheetContent, injectStylesheetLinkRef } from "./utils/stylesheets"; | ||
import { hasLinkRefContainingHrefText, hasStyleTagWithId, injectStylesheetContent, injectStylesheetLinkRef } from "./utils/stylesheets"; | ||
export const SIGN_IN_BUTTON_STYLESHEET_ID = "openpass-sign-in-button-stylesheet"; | ||
/** | ||
@@ -81,4 +82,6 @@ * Handles rendering and functionality of the automatically rendered sign in button. | ||
} | ||
// Inject stylesheet and fonts | ||
injectStylesheetContent(createSignInButtonStylesheet()); | ||
// Inject stylesheet and fonts if not already present | ||
if (!hasStyleTagWithId(SIGN_IN_BUTTON_STYLESHEET_ID)) { | ||
injectStylesheetContent(createSignInButtonStylesheet(), SIGN_IN_BUTTON_STYLESHEET_ID); | ||
} | ||
if (!hasLinkRefContainingHrefText("Poppins")) { | ||
@@ -85,0 +88,0 @@ injectStylesheetLinkRef("https://fonts.googleapis.com/css?family=Poppins"); |
@@ -1,4 +0,5 @@ | ||
export const injectStylesheetContent = (contents) => { | ||
export const injectStylesheetContent = (contents, styleTagId) => { | ||
const style = document.createElement("style"); | ||
style.innerHTML = contents; | ||
style.id = styleTagId; | ||
const head = document.getElementsByTagName("head")[0]; | ||
@@ -25,2 +26,6 @@ head.appendChild(style); | ||
}; | ||
export const hasStyleTagWithId = (id) => { | ||
const styleTagWithId = document.querySelector(`style[id=${id}]`); | ||
return styleTagWithId !== null; | ||
}; | ||
//# sourceMappingURL=stylesheets.js.map |
@@ -5,2 +5,3 @@ import { SignInButtonOptions } from "../types"; | ||
import RedirectAuth from "./redirect"; | ||
export declare const SIGN_IN_BUTTON_STYLESHEET_ID = "openpass-sign-in-button-stylesheet"; | ||
/** | ||
@@ -7,0 +8,0 @@ * Handles rendering and functionality of the automatically rendered sign in button. |
@@ -1,3 +0,4 @@ | ||
export declare const injectStylesheetContent: (contents: string) => void; | ||
export declare const injectStylesheetContent: (contents: string, styleTagId: string) => void; | ||
export declare const injectStylesheetLinkRef: (href: string) => void; | ||
export declare const hasLinkRefContainingHrefText: (text: string) => boolean; | ||
export declare const hasStyleTagWithId: (id: string) => boolean; |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1295726
7590