Skip to content

Commit

Permalink
Header without truncation (#204)
Browse files Browse the repository at this point in the history
* add possibility of not truncating header title
  • Loading branch information
devgioele authored Jun 12, 2023
1 parent ba102c4 commit 555f28a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ReactElement, ReactNode } from 'react'
import { HeaderArea, HeaderTitle } from '.'
import { HeaderArea, HeaderTitle, HeaderTitleProps } from '.'

export type HeaderProps = {
/**
* Defines the title of the header.
**/
title: ReactNode
}
} & Pick<HeaderTitleProps, 'noTruncate'>

export function Header({ title }: HeaderProps): ReactElement {
export function Header({ title, noTruncate }: HeaderProps): ReactElement {
return (
<HeaderArea>
<HeaderTitle>{title}</HeaderTitle>
<HeaderTitle noTruncate={noTruncate}>{title}</HeaderTitle>
</HeaderArea>
)
}
21 changes: 18 additions & 3 deletions src/components/header/areas/HeaderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ import { ReactElement, ReactNode } from 'react'
import { useTheme } from '../../../framework'
import { ClassNameProps } from '../../types'

type Props = ClassNameProps & { children?: ReactNode }
export type HeaderTitleProps = ClassNameProps & {
children?: ReactNode
noTruncate?: boolean
}

export function HeaderTitle({ className, children }: Props): ReactElement {
export function HeaderTitle({
className,
children,
noTruncate = false,
}: HeaderTitleProps): ReactElement {
const { header } = useTheme()

return (
<h1 className={classNames(className, header.title.base)}>{children}</h1>
<h1
className={classNames(
className,
header.title.base,
!noTruncate && header.title.truncate
)}
>
{children}
</h1>
)
}
3 changes: 2 additions & 1 deletion src/components/header/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default {
base: 'flex items-center ml-2 lg:ml-3 space-x-3 lg:space-x-4',
},
title: {
base: 'flex-1 text-3xl leading-10 font-medium lg:text-4xl lg:leading-12 truncate',
base: 'flex-1 text-3xl leading-10 font-medium lg:text-4xl lg:leading-12',
truncate: 'truncate',
},
leftActionIcon: {
base: '-ml-2 lg:-ml-4',
Expand Down

0 comments on commit 555f28a

Please sign in to comment.