-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create more page/header variations (#33900)
- Loading branch information
Showing
4 changed files
with
69 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Box } from '@rocket.chat/fuselage'; | ||
import type { ComponentProps } from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import PageContent from './PageContent'; | ||
|
||
const PageBlock = forwardRef<HTMLElement, ComponentProps<typeof Box>>(function PageBlock(props, ref) { | ||
return <PageContent borderBlockEndColor='transparent' {...props} pb={16} ref={ref} borderBlockEndWidth='default' height='auto' />; | ||
}); | ||
|
||
export default PageBlock; |
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 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 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,51 @@ | ||
import { Box, IconButton } from '@rocket.chat/fuselage'; | ||
import { useDocumentTitle } from '@rocket.chat/ui-client'; | ||
import { useLayout } from '@rocket.chat/ui-contexts'; | ||
import type { ComponentPropsWithoutRef, ReactNode } from 'react'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { HeaderToolbar } from '../Header'; | ||
import SidebarToggler from '../SidebarToggler'; | ||
|
||
type PageHeaderProps = { | ||
title: ReactNode; | ||
onClickBack?: () => void; | ||
borderBlockEndColor?: string; | ||
} & Omit<ComponentPropsWithoutRef<typeof Box>, 'title'>; | ||
|
||
const PageHeaderNoShadow = ({ children = undefined, title, onClickBack, ...props }: PageHeaderProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const { isMobile } = useLayout(); | ||
|
||
useDocumentTitle(typeof title === 'string' ? title : undefined); | ||
|
||
return ( | ||
<Box is='header' borderBlockEndWidth='default' borderBlockEndColor='transparent' {...props}> | ||
<Box | ||
height='100%' | ||
marginInline={24} | ||
minHeight='x64' | ||
display='flex' | ||
flexDirection='row' | ||
flexWrap='wrap' | ||
alignItems='center' | ||
color='default' | ||
> | ||
{isMobile && ( | ||
<HeaderToolbar> | ||
<SidebarToggler /> | ||
</HeaderToolbar> | ||
)} | ||
{onClickBack && <IconButton small mie={8} icon='arrow-back' onClick={onClickBack} title={t('Back')} />} | ||
<Box is='h1' fontScale='h2' flexGrow={1} data-qa-type='PageHeader-title'> | ||
{title} | ||
</Box> | ||
{children} | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default PageHeaderNoShadow; |