Skip to content

Commit

Permalink
fix(FEC-6961): learn more button functionality in ads UI (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dvir Hazout authored and Dan Ziv committed Aug 3, 2017
1 parent 23989dd commit e0e21ee
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
Empty file.
16 changes: 16 additions & 0 deletions src/components/ad-learn-more/ad-learn-more.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@flow
import { h, Component } from 'preact';
import { connect } from 'preact-redux';

const mapStateToProps = state => ({
url: state.engine.adUrl
});

@connect(mapStateToProps)
class AdLearnMore extends Component {
render(props: any) {
return <a href={props.url} target='new' className='btn btn-dark-transparent'>Learn more</a>
}
}

export default AdLearnMore;
1 change: 1 addition & 0 deletions src/components/ad-learn-more/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default from './ad-learn-more';
1 change: 1 addition & 0 deletions src/components/engine-connector/engine-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class EngineConnector extends BaseComponent {
});

this.player.addEventListener(this.player.Event.AD_LOADED, e => {
this.props.updateAdClickUrl(e.payload.ad.g.clickThroughUrl);
this.props.updateAdSkipTimeOffset(e.payload.ad.getSkipTimeOffset());
this.props.updateAdSkippableState(e.payload.ad.getAdSkippableState());
});
Expand Down
15 changes: 12 additions & 3 deletions src/reducers/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const types = {
UPDATE_AD_BREAK_PROGRESS: 'engine/UPDATE_AD_BREAK_PROGRESS',
UPDATE_AD_IS_PLAYING: 'engine/UPDATE_AD_IS_PLAYING',
UPDATE_AD_SKIP_TIME_OFFSET: 'engine/UPDATE_AD_SKIP_TIME_OFFSET',
UPDATE_AD_SKIPPABLE_STATE: 'engine/UPDATE_AD_SKIPPABLE_STATE'
UPDATE_AD_SKIPPABLE_STATE: 'engine/UPDATE_AD_SKIPPABLE_STATE',
UPDATE_AD_URL: 'engine/UPDATE_AD_URL'
}

export const initialState = {
Expand All @@ -40,7 +41,8 @@ export const initialState = {
adProgress: {
currentTime: 0,
duration: 0
}
},
adUrl: ''
}

export default (state: Object = initialState, action: Object) => {
Expand Down Expand Up @@ -141,6 +143,12 @@ export default (state: Object = initialState, action: Object) => {
adSkippableState: action.adSkippableState
}

case types.UPDATE_AD_URL:
return {
...state,
adUrl: action.adUrl
}

default:
return state;
}
Expand All @@ -162,5 +170,6 @@ export const actions = {
updateAdBreakProgress: (currentTime: number, duration: number) => ({ type: types.UPDATE_AD_BREAK_PROGRESS, adProgress: {currentTime, duration} }),
updateAdIsPlaying: (adIsPlaying: boolean) => ({ type: types.UPDATE_AD_IS_PLAYING, adIsPlaying }),
updateAdSkipTimeOffset: (adSkipTimeOffset: boolean) => ({ type: types.UPDATE_AD_SKIP_TIME_OFFSET, adSkipTimeOffset }),
updateAdSkippableState: (adSkippableState: boolean) => ({ type: types.UPDATE_AD_SKIPPABLE_STATE, adSkippableState })
updateAdSkippableState: (adSkippableState: boolean) => ({ type: types.UPDATE_AD_SKIPPABLE_STATE, adSkippableState }),
updateAdClickUrl: (adUrl: string) => ({ type: types.UPDATE_AD_URL, adUrl })
}
3 changes: 3 additions & 0 deletions src/styles/_shell.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.kaltura-player-container {
position: absolute !important;
}
.player {
overflow: hidden;
user-select: none;
Expand Down
3 changes: 2 additions & 1 deletion src/ui-presets/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import VolumeControl from '../components/volume';
import FullscreenControl from '../components/fullscreen';
import TimeDisplayPlaybackContainer from '../components/time-display-playback-container';
import AdSkip from '../components/ad-skip';
import AdLearnMore from '../components/ad-learn-more';
import TopBar from '../components/top-bar';
import BottomBar from '../components/bottom-bar';

Expand All @@ -31,7 +32,7 @@ export default function adsUI(props: any) {
<span className='font-size-base'>Adverisment</span>
</div>
<div className='right-controls'>
<a href='' className='btn btn-dark-transparent'>Learn more</a>
<AdLearnMore />
</div>
</TopBar>
<AdSkip player={props.player} />
Expand Down

0 comments on commit e0e21ee

Please sign in to comment.