This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1566653 - Topsites promo back end. (#5250)
* Bug 1566653 - Topsites promo back end.
- Loading branch information
1 parent
cd3914f
commit 5fb6a1a
Showing
17 changed files
with
1,012 additions
and
270 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
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
78 changes: 78 additions & 0 deletions
78
content-src/components/DiscoveryStreamComponents/DSDismiss/DSDismiss.jsx
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { actionCreators as ac } from "common/Actions.jsm"; | ||
import React from "react"; | ||
import { LinkMenuOptions } from "content-src/lib/link-menu-options"; | ||
|
||
export class DSDismiss extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.onDismissClick = this.onDismissClick.bind(this); | ||
this.onHover = this.onHover.bind(this); | ||
this.offHover = this.offHover.bind(this); | ||
this.state = { | ||
hovering: false, | ||
}; | ||
} | ||
|
||
onDismissClick() { | ||
const index = 0; | ||
const source = "DISCOVERY_STREAM"; | ||
const blockUrlOption = LinkMenuOptions.BlockUrl( | ||
this.props.data, | ||
index, | ||
source | ||
); | ||
|
||
const { action, impression, userEvent } = blockUrlOption; | ||
|
||
this.props.dispatch(action); | ||
const userEventData = Object.assign( | ||
{ | ||
event: userEvent, | ||
source, | ||
action_position: index, | ||
}, | ||
this.props.data | ||
); | ||
this.props.dispatch(ac.UserEvent(userEventData)); | ||
if (impression && this.props.shouldSendImpressionStats) { | ||
this.props.dispatch(impression); | ||
} | ||
} | ||
|
||
onHover() { | ||
this.setState({ | ||
hovering: true, | ||
}); | ||
} | ||
|
||
offHover() { | ||
this.setState({ | ||
hovering: false, | ||
}); | ||
} | ||
|
||
render() { | ||
let className = "ds-dismiss"; | ||
if (this.state.hovering) { | ||
className += " hovering"; | ||
} | ||
return ( | ||
<div className={className}> | ||
{this.props.children} | ||
<button | ||
className="ds-dismiss-button" | ||
onHover={this.onHover} | ||
onClick={this.onDismissClick} | ||
onMouseEnter={this.onHover} | ||
onMouseLeave={this.offHover} | ||
> | ||
<span className="icon icon-dismiss" /> | ||
</button> | ||
</div> | ||
); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
content-src/components/DiscoveryStreamComponents/DSDismiss/_DSDismiss.scss
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.ds-dismiss { | ||
position: relative; | ||
overflow: hidden; | ||
border-radius: 8px; | ||
transition-delay: 100ms; | ||
transition-duration: 100ms; | ||
transition-property: background; | ||
|
||
&.hovering { | ||
background: var(--newtab-element-hover-color); | ||
} | ||
|
||
&:hover { | ||
.ds-dismiss-button { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.ds-dismiss-button { | ||
border: 0; | ||
cursor: pointer; | ||
height: 32px; | ||
width: 32px; | ||
padding: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
border-radius: 50%; | ||
margin: 16px 24px 0 0; | ||
transition-duration: 200ms; | ||
transition-property: opacity; | ||
opacity: 0; | ||
background: var(--newtab-element-active-color); | ||
} | ||
} |
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
Oops, something went wrong.