Skip to content

Commit

Permalink
Added subtitle web variant
Browse files Browse the repository at this point in the history
  • Loading branch information
cgerrard-pass committed Feb 7, 2025
1 parent a546a2f commit a577adb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ exports[`RemoteBanner matches the snapshot 1`] = `
]
}
>
subtitle 1
subtitleMobile 1
</Text>
</View>
<View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ describe('<HomeBanner/>', () => {
beforeEach(() => {
setFeatureFlags([RemoteStoreFeatureFlags.SHOW_REMOTE_BANNER], {
title: 'title 1',
subtitle: 'subtitle 1',
subtitleMobile: 'subtitleMobile 1',
subtitleWeb: 'subtitleWeb 1',
redirectionUrl: 'https://www.test.fr',
redirectionType: 'external',
redirectionType: 'store',
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,32 @@ describe('RemoteBanner', () => {

const bannerAppStore: RemoteBannerType = {
title: 'title 1',
subtitle: 'subtitle 1',
subtitleMobile: 'subtitleMobile 1',
subtitleWeb: 'subtitleWeb 1',
redirectionUrl: 'https://www.test.fr',
redirectionType: RemoteBannerRedirectionType.STORE,
}

const bannerExternalUrl: RemoteBannerType = {
title: 'title 1',
subtitle: 'subtitle 1',
subtitleMobile: 'subtitleMobile 1',
subtitleWeb: 'subtitleWeb 1',
redirectionUrl: 'https://www.test.fr',
redirectionType: RemoteBannerRedirectionType.EXTERNAL,
}

const bannerExternalUrlWithMissingUrl: Partial<RemoteBannerType> = {
title: 'title 1',
subtitle: 'subtitle 1',
subtitleMobile: 'subtitleMobile 1',
subtitleWeb: 'subtitleWeb 1',
redirectionUrl: '',
redirectionType: RemoteBannerRedirectionType.EXTERNAL,
}

const bannerBadType: Partial<RemoteBannerType> = {
title: 'title 1',
subtitle: 'subtitle 1',
subtitleMobile: 'subtitleMobile 1',
subtitleWeb: 'subtitleWeb 1',
redirectionUrl: 'https://www.test.fr',
redirectionType: 'other',
}
7 changes: 5 additions & 2 deletions src/features/remoteBanner/components/RemoteBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { Platform } from 'react-native'
import styled from 'styled-components/native'

import { STORE_LINK } from 'features/forceUpdate/constants'
Expand All @@ -15,11 +16,13 @@ import { BannerWithBackground } from 'ui/components/ModuleBanner/BannerWithBackg
import { ArrowAgain } from 'ui/svg/icons/ArrowAgain'
import { TypoDS } from 'ui/theme'

const isWeb = Platform.OS === 'web'

export const RemoteBanner = () => {
const { options } = useFeatureFlagOptions(RemoteStoreFeatureFlags.SHOW_REMOTE_BANNER)
const validatedOptions = validateRemoteBanner(options)
if (!validatedOptions) return null
const { title, subtitle, redirectionUrl, redirectionType } = validatedOptions
const { title, subtitleMobile, subtitleWeb, redirectionUrl, redirectionType } = validatedOptions

const isStoreRedirection = redirectionType === RemoteBannerRedirectionType.STORE
const isExternalRedirection = redirectionType === RemoteBannerRedirectionType.EXTERNAL
Expand All @@ -42,7 +45,7 @@ export const RemoteBanner = () => {
onPress={onPress}
{...accessibilityAndTestId(accessibilityLabel)}>
<StyledButtonText>{title}</StyledButtonText>
<StyledBodyText>{subtitle}</StyledBodyText>
<StyledBodyText>{isWeb ? subtitleWeb : subtitleMobile}</StyledBodyText>
</BannerWithBackground>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/features/remoteBanner/components/remoteBannerSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { InferType, object, string } from 'yup'

const remoteBannerSchema = object({
title: string().required(),
subtitle: string().nullable(),
subtitleWeb: string().nullable(),
subtitleMobile: string().nullable(),
redirectionUrl: string().url().nullable(),
redirectionType: string().oneOf(['external', 'store']).required(),
})
Expand Down

0 comments on commit a577adb

Please sign in to comment.