Skip to content

Commit d2d8407

Browse files
New Tab Page Sponsored Image Clickbox (#17356)
1 parent 97576bf commit d2d8407

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

components/brave_new_tab_ui/components/default/page/index.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const StyledPage = styled('div')<PageProps>`
7171
width: 100%;
7272
display: grid;
7373
grid-template-rows: repeat(calc(var(--ntp-page-rows) - 1), min-content) auto;
74-
grid-template-columns: min-content auto min-content;
74+
grid-template-columns: min-content 1fr min-content;
7575
grid-auto-flow: row dense;
7676
padding: var(--ntp-page-padding);
7777
overflow: hidden;
@@ -185,10 +185,29 @@ export const GridItemWidgetStack = styled('section')`
185185
`
186186

187187
export const GridItemTopSites = styled('section')`
188-
grid-column: 1 / span 2;
188+
grid-column: 1;
189189
${singleColumnSmallViewport}
190190
`
191191

192+
export const GridItemSponsoredImageClickArea = styled.section<{ otherWidgetsHidden: boolean }>`
193+
grid-column: 2;
194+
grid-row: 2 / span 3;
195+
height: calc(100% - 200px);
196+
width: 100%;
197+
position: relative;
198+
199+
@media screen and (max-width: ${breakpointEveryBlock}) {
200+
${(p) =>
201+
p.otherWidgetsHidden
202+
? css`
203+
flex-grow: 2;
204+
`
205+
: css`
206+
display: none
207+
`}
208+
}
209+
`
210+
192211
export const GridItemNotification = styled('section')`
193212
position: fixed;
194213
left: 50%;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2023 The Brave Authors. All rights reserved.
2+
// This Source Code Form is subject to the terms of the Mozilla Public
3+
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
4+
// You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
import { OpenNewIcon } from 'brave-ui/components/icons'
7+
import * as React from 'react'
8+
import styled from 'styled-components'
9+
10+
const Indicator = styled.span`
11+
display: none;
12+
13+
position: absolute;
14+
top: 8px;
15+
right: 8px;
16+
17+
width: 20px;
18+
height: 20px;
19+
color: white;
20+
`
21+
22+
const Link = styled.a`
23+
position: absolute;
24+
top: 8px;
25+
left: 8px;
26+
right: 56px;
27+
bottom: 8px;
28+
display: block;
29+
30+
&:hover {
31+
cursor: pointer;
32+
${Indicator} {
33+
display: block;
34+
}
35+
}
36+
`
37+
38+
export default function SponsoredImageClickArea(props: { sponsoredImageUrl: string, onClick: () => void }) {
39+
return (
40+
<Link href={props.sponsoredImageUrl} rel="noreferrer noopener" onClick={props.onClick}>
41+
<Indicator>
42+
<OpenNewIcon />
43+
</Indicator>
44+
</Link>
45+
)
46+
}

components/brave_new_tab_ui/containers/newTab/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import Settings, { TabType as SettingsTabType } from './settings'
3737
import { BraveNewsContextProvider } from '../../components/default/braveNews/customize/Context'
3838
import BraveNewsHint from '../../components/default/braveNews/hint'
3939
import GridWidget from './gridWidget'
40+
import SponsoredImageClickArea from '../../components/default/sponsoredImage/sponsoredImageClickArea'
4041

4142
interface Props {
4243
newTabData: NewTab.State
@@ -640,6 +641,10 @@ class NewTabPage extends React.Component<Props, State> {
640641
/>
641642
</Page.GridItemTopSites>
642643
}
644+
{newTabData.brandedWallpaper?.isSponsored && <Page.GridItemSponsoredImageClickArea otherWidgetsHidden={this.allWidgetsHidden()}>
645+
<SponsoredImageClickArea onClick={this.onClickLogo}
646+
sponsoredImageUrl={newTabData.brandedWallpaper.logo.destinationUrl}/>
647+
</Page.GridItemSponsoredImageClickArea>}
643648
{
644649
gridSitesData.shouldShowSiteRemovedNotification
645650
? (

0 commit comments

Comments
 (0)