-
Notifications
You must be signed in to change notification settings - Fork 330
/
Copy pathHeader.tsx
74 lines (66 loc) · 1.68 KB
/
Header.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React from 'react';
import { Col, descriptors, Heading, Text, useAppearance } from '../customizables';
import type { PropsOfComponent, ThemableCssProp } from '../styledSystem';
import { ApplicationLogo } from './ApplicationLogo';
export type HeaderProps = PropsOfComponent<typeof Col> & {
showLogo?: boolean;
contentSx?: ThemableCssProp;
};
const Root = React.memo(
React.forwardRef<HTMLDivElement, HeaderProps>((props, ref) => {
const { sx, children, contentSx, gap = 6, showLogo = false, ...rest } = props;
const appearance = useAppearance();
const logoIsVisible = appearance.parsedLayout.logoPlacement === 'inside' && showLogo;
return (
<Col
ref={ref}
elementDescriptor={descriptors.header}
gap={gap}
sx={sx}
{...rest}
>
{logoIsVisible && <ApplicationLogo />}
<Col
gap={1}
sx={contentSx}
{...rest}
>
{children}
</Col>
</Col>
);
}),
);
const Title = React.memo((props: PropsOfComponent<typeof Heading>): JSX.Element => {
const { sx, textVariant = 'h2', ...rest } = props;
return (
<Heading
elementDescriptor={descriptors.headerTitle}
textVariant={textVariant}
sx={sx}
{...rest}
/>
);
});
const Subtitle = React.memo((props: PropsOfComponent<typeof Text>): JSX.Element => {
const { sx, ...rest } = props;
return (
<Text
elementDescriptor={descriptors.headerSubtitle}
variant='body'
colorScheme='neutral'
sx={[
{
wordWrap: 'break-word',
},
sx,
]}
{...rest}
/>
);
});
export const Header = {
Root,
Title,
Subtitle,
};