-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33757 from software-mansion-labs/ts/HeaderPageLayout
[TS migration] Migrate 'HeaderPageLayout' and 'IllustratedHeaderPageLayout' components to TypeScript
- Loading branch information
Showing
3 changed files
with
92 additions
and
115 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 was deleted.
Oops, something went wrong.
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,50 @@ | ||
import React from 'react'; | ||
import type {ReactNode} from 'react'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import HeaderPageLayout from './HeaderPageLayout'; | ||
import type {HeaderPageLayoutProps} from './HeaderPageLayout'; | ||
import Lottie from './Lottie'; | ||
import type DotLottieAnimation from './LottieAnimations/types'; | ||
|
||
type IllustratedHeaderPageLayoutProps = HeaderPageLayoutProps & { | ||
/** The illustration to display in the header. Can be a JSON object representing a Lottie animation. */ | ||
illustration: DotLottieAnimation; | ||
|
||
/** The background color to apply in the upper half of the screen. */ | ||
backgroundColor?: string; | ||
|
||
/** Overlay content to display on top of animation */ | ||
overlayContent?: () => ReactNode; | ||
}; | ||
|
||
function IllustratedHeaderPageLayout({backgroundColor, children, illustration, overlayContent, ...rest}: IllustratedHeaderPageLayoutProps) { | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
return ( | ||
<HeaderPageLayout | ||
backgroundColor={backgroundColor ?? theme.appBG} | ||
headerContent={ | ||
<> | ||
<Lottie | ||
source={illustration} | ||
style={styles.w100} | ||
webStyle={styles.w100} | ||
autoPlay | ||
loop | ||
/> | ||
{overlayContent?.()} | ||
</> | ||
} | ||
headerContainerStyles={[styles.justifyContentCenter, styles.w100]} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...rest} | ||
> | ||
{children} | ||
</HeaderPageLayout> | ||
); | ||
} | ||
|
||
IllustratedHeaderPageLayout.displayName = 'IllustratedHeaderPageLayout'; | ||
|
||
export default IllustratedHeaderPageLayout; |