Skip to content

Commit f03fe8c

Browse files
committed
feat: disable html margin by props
1 parent 4aa49f7 commit f03fe8c

7 files changed

Lines changed: 26 additions & 5 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
- name: Build docs
3232
run: pnpm run build:docs
3333

34+
- name: Run tests
35+
run: pnpm run test:run
36+
3437
- name: Show current directory files
3538
run: ls -la
3639

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
- name: Biome format & linter
3535
run: pnpm run format
3636

37+
- name: Run tests
38+
run: pnpm run test:run
39+
3740
- name: Build library
3841
run: pnpm run build
3942

docs/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ <h2 id="props">Props</h2>
179179
<td><code>navigator.language</code> or <code>'us'</code></td>
180180
<td><code>string</code> <p>Language code used to generate App Store or Play Store URLs.</p></td>
181181
</tr>
182+
<tr>
183+
<td><code>disableHtmlMargin</code></td>
184+
<td><code>false</code></td>
185+
<td><code>boolean</code> <p>Disable HTML margin.</p></td>
186+
</tr>
182187
<tr>
183188
<td><code>withPortal</code></td>
184189
<td><code>true</code></td>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@
7474
"dependencies": {
7575
"js-cookie": "^3.0.5",
7676
"ua-parser-js": "^2.0.3"
77-
}
77+
},
78+
"packageManager": "pnpm@9.4.0"
7879
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
iconsRels,
88
isStandalone,
99
cookie,
10-
} from "./utils";
10+
} from "../utils";
1111

1212
describe("utils", () => {
1313
describe("is_client", () => {

src/smartbanner.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const SmartBanner: React.FC<SmartBannerProps> = ({
3333
ignoreIosVersion = false,
3434
onClose,
3535
onInstall,
36+
disableHtmlMargin = false,
3637
withPortal = true,
3738
portalTargetId,
3839
target,
@@ -91,8 +92,10 @@ export const SmartBanner: React.FC<SmartBannerProps> = ({
9192
React.useEffect(() => {
9293
if (!html) return;
9394

94-
html.classList.toggle(ClassNames.TOP, placement === "top");
95-
html.classList.toggle(ClassNames.BOTTOM, placement === "bottom");
95+
if (!disableHtmlMargin) {
96+
html.classList.toggle(ClassNames.TOP, placement === "top");
97+
html.classList.toggle(ClassNames.BOTTOM, placement === "bottom");
98+
}
9699

97100
// return () => {
98101
// if (!html) return;
@@ -103,7 +106,7 @@ export const SmartBanner: React.FC<SmartBannerProps> = ({
103106
// ClassNames.BOTTOM
104107
// );
105108
// }
106-
}, [placement]);
109+
}, [placement, disableHtmlMargin]);
107110

108111
const handleShow = React.useCallback((show: boolean) => {
109112
if (html) {

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export interface SmartBannerProps {
9797
*/
9898
onInstall?: () => void;
9999

100+
/**
101+
* Disable HTML margin.
102+
* @default false
103+
*/
104+
disableHtmlMargin?: boolean;
105+
100106
/**
101107
* Whether to render the banner using a React Portal.
102108
* @default true

0 commit comments

Comments
 (0)