-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added general props support #8
- Loading branch information
Showing
3 changed files
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
import React from "react"; | ||
import React, { DetailedHTMLProps } from "react"; | ||
|
||
export type Layout = "display" | "in-article" | "custom"; | ||
|
||
type AdLayoutProps = { | ||
interface AdLayoutProps | ||
extends DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement> { | ||
dataAdClient: string; | ||
dataAdSlot: string; | ||
}; | ||
} | ||
|
||
interface DisplayProps extends AdLayoutProps { | ||
responsive?: boolean; | ||
} | ||
|
||
export const Display = (props: DisplayProps) => { | ||
export const Display = ({ responsive, dataAdClient, dataAdSlot, ...props }: DisplayProps) => { | ||
return ( | ||
<ins | ||
className="adsbygoogle" | ||
style={{ display: "block" }} | ||
data-ad-format="auto" | ||
data-full-width-responsive={props.responsive ?? true} | ||
data-ad-client={props.dataAdClient} | ||
data-ad-slot={props.dataAdSlot} | ||
data-full-width-responsive={responsive ?? true} | ||
data-ad-client={dataAdClient} | ||
data-ad-slot={dataAdSlot} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
interface InArticleProps extends AdLayoutProps {} | ||
|
||
export const InArticle = (props: InArticleProps) => { | ||
export const InArticle = ({ dataAdClient, dataAdSlot, ...props }: InArticleProps) => { | ||
return ( | ||
<ins | ||
className="adsbygoogle" | ||
style={{ display: "block", textAlign: "center" }} | ||
data-ad-layout="in-article" | ||
data-ad-format="fluid" | ||
data-ad-client={props.dataAdClient} | ||
data-ad-slot={props.dataAdSlot} | ||
data-ad-client={dataAdClient} | ||
data-ad-slot={dataAdSlot} | ||
{...props} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters