Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Aug 20, 2024
1 parent 3c5098c commit 71b7b1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
31 changes: 13 additions & 18 deletions scripts/inject-smartbanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';

const SMARTBANNER_APP_NAME = 'some fake thing';
const SMARTBANNER_ORG_NAME = 'some fake thing';
const SMARTBANNER_ICON_URL = 'some fake thing';
const SMARTBANNER_APPSTORE_URL = 'some fake thing';
const SMARTBANNER_GOOGLEPLAY_URL = 'some fake thing';
const SMARTBANNER_APP_NAME = process.env.SMARTBANNER_APP_NAME;
const SMARTBANNER_ORG_NAME = process.env.SMARTBANNER_ORG_NAME;
const SMARTBANNER_ICON_URL = process.env.SMARTBANNER_ICON_URL;
const SMARTBANNER_APPSTORE_URL = process.env.SMARTBANNER_APPSTORE_URL;
const SMARTBANNER_GOOGLEPLAY_URL = process.env.SMARTBANNER_GOOGLEPLAY_URL;

const currentPath = fileURLToPath(import.meta.url);
const projectRoot = path.dirname(currentPath);
Expand All @@ -17,10 +17,11 @@ if (
SMARTBANNER_APP_NAME &&
SMARTBANNER_ORG_NAME &&
SMARTBANNER_ICON_URL &&
(SMARTBANNER_APPSTORE_URL || SMARTBANNER_GOOGLEPLAY_URL)
(SMARTBANNER_APPSTORE_URL ?? SMARTBANNER_GOOGLEPLAY_URL)
) {
try {
const files = await fs.readdir('entry-points');
// eslint-disable-next-line no-restricted-syntax
for (const file of files) {
inject(file);
}
Expand All @@ -42,32 +43,26 @@ async function inject(fileName) {
/* hardcoded injection depending on whether the app is available on App Store and/or Google Play */

if (SMARTBANNER_APPSTORE_URL) {
smartbanner =
`\t<meta name="smartbanner:button-url-apple" content="${SMARTBANNER_APPSTORE_URL}">\n` +
smartbanner;
smartbanner = `\t<meta name="smartbanner:button-url-apple" content="${SMARTBANNER_APPSTORE_URL}">\n${smartbanner}`;
}
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner =
`\t<meta name="smartbanner:button-url-google" content="${SMARTBANNER_GOOGLEPLAY_URL}">\n` +
smartbanner;
smartbanner = `\t<meta name="smartbanner:button-url-google" content="${SMARTBANNER_GOOGLEPLAY_URL}">\n${smartbanner}`;
}
if (SMARTBANNER_APPSTORE_URL) {
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner =
`\t<meta name="smartbanner:enabled-platforms" content="android,ios">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android,ios">\n${smartbanner}`;
} else {
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="ios">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="ios">\n${smartbanner}`;
}
} else {
if (SMARTBANNER_GOOGLEPLAY_URL) {
smartbanner =
`\t<meta name="smartbanner:enabled-platforms" content="android">\n` + smartbanner;
smartbanner = `\t<meta name="smartbanner:enabled-platforms" content="android">\n${smartbanner}`;
}
}

const injectedHtml = html.replace('</head>', `${smartbanner}\n</head>`);

await fs.writeFile(htmlFilePath, injectedHtml, 'utf-8');
console.log(htmlFilePath, injectedHtml);

console.log(`Smartbanner scripts successfully injected (${fileName}).`);
}
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ strong,
b {
font-weight: 700;
}

/* Fixes the smart banner being unclickable. We want this to rise above all app banners */
.smartbanner--ios {
z-index: 999;
}
6 changes: 0 additions & 6 deletions src/styles/constants.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,3 @@
--form-input-paddingY: 0.25rem;
--form-input-paddingX: 0.625rem;
}

.smartbanner--ios {
font-size: 18px;
color: #007aff;
z-index: 10;
}

0 comments on commit 71b7b1c

Please sign in to comment.