Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Add centerText option to PanelTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
mvaivre committed Aug 3, 2023
1 parent 1efdb2a commit 6b44c93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/components/PageComponents/PanelTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface PanelTitleProps {
size?: 'small' | 'big'
useLayoutId?: boolean
isSticky?: boolean
centerText?: boolean
}

const PanelTitle: FC<PanelTitleProps> = ({
Expand All @@ -34,14 +35,15 @@ const PanelTitle: FC<PanelTitleProps> = ({
onBackButtonClick,
size,
useLayoutId = true,
isSticky = false
isSticky = false,
centerText = false
}) => {
const { scrollY } = useScroll()

const titleScale = useTransform(scrollY, [0, 50], [1, 0.6])

return (
<TitleContainer layoutId={useLayoutId ? 'sectionTitle' : ''} isSticky={isSticky}>
<TitleContainer layoutId={useLayoutId ? 'sectionTitle' : ''} isSticky={isSticky} centerText={centerText}>
{onBackButtonClick && (
<BackArrow
onClick={onBackButtonClick}
Expand All @@ -60,11 +62,13 @@ const PanelTitle: FC<PanelTitleProps> = ({

export default PanelTitle

export const TitleContainer = styled(motion.div)<{ isSticky: boolean }>`
export const TitleContainer = styled(motion.div)<Pick<PanelTitleProps, 'isSticky' | 'centerText'>>`
display: flex;
align-items: center;
top: 0;
${({ centerText }) => centerText && 'text-align: center'};
${({ isSticky }) =>
isSticky &&
css`
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage/UnlockPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const UnlockPanel = ({ onNewWalletLinkClick }: UnlockPanelProps) => {

return (
<>
<PanelTitle useLayoutId={false} size="big">
<PanelTitle useLayoutId={false} size="big" centerText>
{dAppName ? t('Connect to dApp') : t('Welcome back.')}
</PanelTitle>
<ParagraphStyled centered secondary>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const HomePage = () => {
<FloatingPanel verticalAlign="center" horizontalAlign="center" transparentBg borderless>
{showNewWalletActions ? (
<>
<PanelTitle useLayoutId={false} size="big">
<PanelTitle useLayoutId={false} size="big" centerText>
{t('New wallet')}
</PanelTitle>
<NewWalletActions onExistingWalletLinkClick={() => setShowNewWalletActions(false)} />
Expand All @@ -48,7 +48,7 @@ const HomePage = () => {
<UnlockPanel onNewWalletLinkClick={() => setShowNewWalletActions(true)} />
) : (
<>
<PanelTitle useLayoutId={false} size="big">
<PanelTitle useLayoutId={false} size="big" centerText>
{t('Welcome.')}
</PanelTitle>
<NewWalletActions />
Expand Down

0 comments on commit 6b44c93

Please sign in to comment.