mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: patreon exempt
This commit is contained in:
1 parent
9bc745bc0e
commit
4f5a8c9a37
5 files changed
+110
-12
No files matched your search
@@ -1,12 +1,17 @@
|
||||
import { Box, type BoxProps } from '@radix-ui/themes';
|
||||
import { useEffect } from 'react';
|
||||
import { useAdExempt } from '../hooks/useAdExempt';
|
||||
|
||||
type AdProps = BoxProps & {
|
||||
export type AdProps = BoxProps & {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export function Ad({ id, ...props }: AdProps) {
|
||||
const exempt = useAdExempt();
|
||||
|
||||
useEffect(() => {
|
||||
if (exempt) return;
|
||||
|
||||
(window as any).nitroAds.createAd(id, {
|
||||
refreshTime: 30,
|
||||
demo: import.meta.env.MODE === 'development',
|
||||
@@ -19,7 +24,9 @@ export function Ad({ id, ...props }: AdProps) {
|
||||
position: 'top-right',
|
||||
},
|
||||
});
|
||||
}, []);
|
||||
}, [exempt, id]);
|
||||
|
||||
if (exempt) return null;
|
||||
|
||||
return <Box id={id} width="100%" {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { App } from '../stores/app';
|
||||
import { Ad, type AdProps } from './Ad';
|
||||
|
||||
export function AdWithContext(props: AdProps) {
|
||||
return (
|
||||
<App.Provider>
|
||||
<Ad {...props} />
|
||||
</App.Provider>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user