Skip to content

Commit

Permalink
adding advertisement tile for the new browser ui
Browse files Browse the repository at this point in the history
  • Loading branch information
nnecla committed Oct 10, 2024
1 parent b0d989c commit 90f6a4d
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 6 deletions.
35 changes: 35 additions & 0 deletions src/browser/images/clusters.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion src/browser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,19 @@ import AppInit, { setupSentry } from './AppInit'
import './init'

setupSentry()
ReactDOM.render(<AppInit />, document.getElementById('mount'))
;(async () => {
const doesPreferQuery = localStorage.getItem('prefersOldBrowser') === 'false'

const response = await fetch('/preview/manifest.json')
if (response.status === 200) {
if (doesPreferQuery) {
window.location.pathname = '/preview/'
} else {
localStorage.setItem('previewAvailable', 'true')
}
} else {
localStorage.setItem('previewAvailable', 'false')
}

ReactDOM.render(<AppInit />, document.getElementById('mount'))
})()
12 changes: 12 additions & 0 deletions src/browser/modules/Carousel/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,18 @@
border: 0;
display: inline-block;
}
.btn-advertise {
padding: 1em;
background-color: #fff;
color: #008cc1;
border-radius: 4px;
border: 0;
display: inline-block;
margin-bottom: 5px;
margin-right: 5px;
font-size: 12px;
line-height: 18px;
}
.teasers {
display: flex;
justify-content: center;
Expand Down
12 changes: 12 additions & 0 deletions src/browser/modules/Carousel/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,18 @@ export const StyledSlide = styled.div`
background-color: ${props => props.theme.teaserCardBackground} !important;
}
&.slide .teaser-advertise {
color: white !important;
background-color: #0a6190 !important;
& .img-advertise {
position: absolute;
left: 0;
bottom: -10px;
opacity: 0.15;
}
}
&.slide input {
color: ${props => props.theme.inputText};
}
Expand Down
25 changes: 20 additions & 5 deletions src/browser/modules/Stream/PlayFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ import { isConnectedAuraHost } from 'shared/modules/connections/connectionsDuck'
import { getEdition, isEnterprise } from 'shared/modules/dbMeta/dbMetaDuck'
import { DARK_THEME } from 'shared/modules/settings/settingsDuck'
import { LAST_GUIDE_SLIDE } from 'shared/modules/udc/udcDuck'
import { PreviewFrame } from './StartPreviewFrame'
import {
experimentalFeaturePreviewName,
showFeature
} from 'shared/modules/experimentalFeatures/experimentalFeaturesDuck'

const AuraPromotion = () => {
const theme = useContext(ThemeContext)
Expand Down Expand Up @@ -88,13 +93,15 @@ type PlayFrameProps = {
showPromotion: boolean
isFullscreen: boolean
isCollapsed: boolean
isAdvertiseFlagOn: boolean
}
export function PlayFrame({
stack,
bus,
showPromotion,
isFullscreen,
isCollapsed
isCollapsed,
isAdvertiseFlagOn
}: PlayFrameProps): JSX.Element {
const [stackIndex, setStackIndex] = useState(0)
const [atSlideStart, setAtSlideStart] = useState<boolean | null>(null)
Expand Down Expand Up @@ -123,7 +130,8 @@ export function PlayFrame({
bus,
onSlide,
initialPlay,
showPromotion
showPromotion,
isAdvertiseFlagOn
)
if (stillMounted) {
setInitialPlay(false)
Expand Down Expand Up @@ -206,7 +214,8 @@ function generateContent(
bus: Bus,
onSlide: any,
shouldUseSlidePointer: boolean,
showPromotion = false
showPromotion = false,
isAdvertiseFlagOn: boolean
): Content | Promise<Content> {
// Not found
if (stackFrame.response && stackFrame.response.status === 404) {
Expand Down Expand Up @@ -287,15 +296,20 @@ function generateContent(

// Check if content exists locally
if (isPlayChapter(guideName)) {
const isPreviewAvailable =
localStorage.getItem('previewAvailable') === 'true'
const showAdvertiseTile = isAdvertiseFlagOn && isPreviewAvailable
const { content, title, subtitle, slides = null } = chapters[guideName]

const isPlayStart = stackFrame.cmd.trim() === ':play start'
const updatedContent =
isPlayStart && showPromotion ? (
<>
{content}
{showAdvertiseTile ? <PreviewFrame /> : content}
<AuraPromotion />
</>
) : showAdvertiseTile ? (
<PreviewFrame />
) : (
content
)
Expand Down Expand Up @@ -378,7 +392,8 @@ const mapStateToProps = (state: GlobalState) => ({
(getEdition(state) !== null &&
!isEnterprise(state) &&
!isConnectedAuraHost(state)) ||
inDesktop(state)
inDesktop(state),
isAdvertiseFlagOn: showFeature(state, experimentalFeaturePreviewName)
})

export default connect(mapStateToProps)(withBus(PlayFrame))
Loading

0 comments on commit 90f6a4d

Please sign in to comment.