Skip to content

Commit 17f3ff0

Browse files
committed
add ads component
1 parent f95c19f commit 17f3ff0

File tree

6 files changed

+87
-43
lines changed

6 files changed

+87
-43
lines changed

frontend/.env.development

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
NEXT_PUBLIC_API_URL=http://localhost:8080
1+
NEXT_PUBLIC_API_URL=http://localhost:8080
2+
NEXT_PUBLIC_GOOGLE_AD_CLIENT=ca-pub-7134126650568891
3+
NEXT_PUBLIC_GOOGLE_AD_SLOT=2983860255

frontend/.env.production

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
NEXT_PUBLIC_API_URL=https://pairwise-api.yuuniworks.com
1+
NEXT_PUBLIC_API_URL=https://pairwise-api.yuuniworks.com
2+
NEXT_PUBLIC_GOOGLE_AD_CLIENT=ca-pub-7134126650568891
3+
NEXT_PUBLIC_GOOGLE_AD_SLOT=2983860255
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { useEffect } from 'react';
2+
3+
interface IProps {}
4+
5+
export const AdCard: React.FC<IProps> = ({}) => {
6+
useEffect(() => {
7+
if (!process.browser) {
8+
return;
9+
}
10+
if (!window.adsbygoogle) {
11+
window.adsbygoogle = [];
12+
}
13+
window.adsbygoogle.push({});
14+
}, []);
15+
16+
return (
17+
<ins
18+
className="adsbygoogle"
19+
style={{ display: 'inline-block', width: '1200px', height: '90px' }}
20+
data-ad-client={process.env.NEXT_PUBLIC_GOOGLE_AD_CLIENT}
21+
data-ad-slot={process.env.NEXT_PUBLIC_GOOGLE_AD_SLOT}
22+
data-full-width-responsive="true"
23+
></ins>
24+
);
25+
};

frontend/src/features/top/Top.module.css

Lines changed: 0 additions & 39 deletions
This file was deleted.

frontend/src/features/top/Top.tsx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { css } from 'emotion';
12
import React, { useCallback, useState } from 'react';
23
import { Button } from '../../components/Button';
34
import { Textarea } from '../../components/Textarea';
5+
import { AdCard } from '../ads/AdCard';
46
import { Header } from '../header';
5-
import style from './Top.module.css';
67

78
export const Top = () => {
89
const [isFetching, setIsFetching] = useState(false);
@@ -25,10 +26,57 @@ export const Top = () => {
2526
.finally(() => setIsFetching(false));
2627
}, [factorText]);
2728

29+
const style = {
30+
rootContainer: css`
31+
background: #fafafa;
32+
display: flex;
33+
flex-direction: column;
34+
height: 100vh;
35+
width: 100vw;
36+
`,
37+
description: css`
38+
padding: 0 1rem;
39+
margin-top: 1rem;
40+
line-height: 1.8;
41+
`,
42+
converterRow: css`
43+
align-items: stretch;
44+
display: flex;
45+
flex: 1 0; /* expand */
46+
justify-content: space-between;
47+
padding: 1rem;
48+
`,
49+
adsRow: css`
50+
flex: 0 0 90px;
51+
margin-top: 1rem;
52+
overflow: hidden;
53+
text-align: center;
54+
`,
55+
factors: css`
56+
display: flex;
57+
flex-direction: column;
58+
flex: 1;
59+
`,
60+
results: css`
61+
display: flex;
62+
flex-direction: column;
63+
flex: 1;
64+
`,
65+
download: css`
66+
display: block;
67+
margin: 0.5rem 0 1rem;
68+
text-align: center;
69+
`,
70+
};
71+
2872
return (
2973
<div className={style.rootContainer}>
3074
<Header />
3175

76+
<div className={style.adsRow}>
77+
<AdCard />
78+
</div>
79+
3280
<div className={style.description}>
3381
An online service that easily generates pair-wise test cases.
3482
<br />
@@ -37,7 +85,7 @@ export const Top = () => {
3785
hood.
3886
</div>
3987

40-
<div className={style.row}>
88+
<div className={style.converterRow}>
4189
<div className={style.factors}>
4290
<Textarea
4391
aria-label="factors"

frontend/src/pages/_app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import React from 'react';
44
import { AdBlockGuard } from '../features/ads/AdBlockGuard';
55
import './global.css';
66

7+
declare global {
8+
interface Window {
9+
adsbygoogle: any;
10+
}
11+
}
12+
713
function App({ Component, pageProps }: AppProps) {
814
return (
915
<>

0 commit comments

Comments
 (0)