From d2d8407d75af92b43daa3eaa8d2af2fc6594b2e7 Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Mon, 27 Feb 2023 09:10:19 +1300 Subject: [PATCH] New Tab Page Sponsored Image Clickbox (#17356) --- .../components/default/page/index.tsx | 23 +++++++++- .../sponsoredImageClickArea.tsx | 46 +++++++++++++++++++ .../containers/newTab/index.tsx | 5 ++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 components/brave_new_tab_ui/components/default/sponsoredImage/sponsoredImageClickArea.tsx diff --git a/components/brave_new_tab_ui/components/default/page/index.tsx b/components/brave_new_tab_ui/components/default/page/index.tsx index f6a2cc5c9a24..dc5f7f0b76ae 100644 --- a/components/brave_new_tab_ui/components/default/page/index.tsx +++ b/components/brave_new_tab_ui/components/default/page/index.tsx @@ -71,7 +71,7 @@ const StyledPage = styled('div')` width: 100%; display: grid; grid-template-rows: repeat(calc(var(--ntp-page-rows) - 1), min-content) auto; - grid-template-columns: min-content auto min-content; + grid-template-columns: min-content 1fr min-content; grid-auto-flow: row dense; padding: var(--ntp-page-padding); overflow: hidden; @@ -185,10 +185,29 @@ export const GridItemWidgetStack = styled('section')` ` export const GridItemTopSites = styled('section')` - grid-column: 1 / span 2; + grid-column: 1; ${singleColumnSmallViewport} ` +export const GridItemSponsoredImageClickArea = styled.section<{ otherWidgetsHidden: boolean }>` + grid-column: 2; + grid-row: 2 / span 3; + height: calc(100% - 200px); + width: 100%; + position: relative; + + @media screen and (max-width: ${breakpointEveryBlock}) { + ${(p) => + p.otherWidgetsHidden + ? css` + flex-grow: 2; + ` + : css` + display: none + `} + } +` + export const GridItemNotification = styled('section')` position: fixed; left: 50%; diff --git a/components/brave_new_tab_ui/components/default/sponsoredImage/sponsoredImageClickArea.tsx b/components/brave_new_tab_ui/components/default/sponsoredImage/sponsoredImageClickArea.tsx new file mode 100644 index 000000000000..3f369d4cdf8d --- /dev/null +++ b/components/brave_new_tab_ui/components/default/sponsoredImage/sponsoredImageClickArea.tsx @@ -0,0 +1,46 @@ +// Copyright (c) 2023 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at https://mozilla.org/MPL/2.0/. + +import { OpenNewIcon } from 'brave-ui/components/icons' +import * as React from 'react' +import styled from 'styled-components' + +const Indicator = styled.span` + display: none; + + position: absolute; + top: 8px; + right: 8px; + + width: 20px; + height: 20px; + color: white; +` + +const Link = styled.a` + position: absolute; + top: 8px; + left: 8px; + right: 56px; + bottom: 8px; + display: block; + + &:hover { + cursor: pointer; + ${Indicator} { + display: block; + } + } +` + +export default function SponsoredImageClickArea(props: { sponsoredImageUrl: string, onClick: () => void }) { + return ( + + + + + + ) +} diff --git a/components/brave_new_tab_ui/containers/newTab/index.tsx b/components/brave_new_tab_ui/containers/newTab/index.tsx index 840bc263fc67..996076de3511 100644 --- a/components/brave_new_tab_ui/containers/newTab/index.tsx +++ b/components/brave_new_tab_ui/containers/newTab/index.tsx @@ -37,6 +37,7 @@ import Settings, { TabType as SettingsTabType } from './settings' import { BraveNewsContextProvider } from '../../components/default/braveNews/customize/Context' import BraveNewsHint from '../../components/default/braveNews/hint' import GridWidget from './gridWidget' +import SponsoredImageClickArea from '../../components/default/sponsoredImage/sponsoredImageClickArea' interface Props { newTabData: NewTab.State @@ -640,6 +641,10 @@ class NewTabPage extends React.Component { /> } + {newTabData.brandedWallpaper?.isSponsored && + + } { gridSitesData.shouldShowSiteRemovedNotification ? (