forked from 1Hive/gardens-ui
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHeaderPopover.js
More file actions
88 lines (83 loc) · 2.03 KB
/
HeaderPopover.js
File metadata and controls
88 lines (83 loc) · 2.03 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React from 'react'
import PropTypes from 'prop-types'
import { GU, Popover, springs, textStyle, useTheme } from '@tecommons/ui'
import { Spring, animated } from 'react-spring/renderprops'
const AnimatedSection = animated.section
function HeaderPopover({
animateHeight,
children,
height,
width,
heading,
onClose,
opener,
visible,
}) {
const theme = useTheme()
return (
<Popover
closeOnOpenerFocus
onClose={onClose}
opener={opener}
placement="bottom-end"
visible={visible}
css={`
width: ${width}px;
`}
>
<Spring
config={springs.smooth}
from={{ height: `${38 * GU}px` }}
to={{ height: `${height}px` }}
immediate={!animateHeight}
native
>
{({ height }) => (
<AnimatedSection
style={{ height }}
css={`
display: flex;
flex-direction: column;
overflow: hidden;
`}
>
<h1
css={`
display: flex;
flex-grow: 0;
flex-shrink: 0;
align-items: center;
height: ${4 * GU}px;
padding-left: ${2 * GU}px;
border-bottom: 1px solid ${theme.border};
color: ${theme.contentSecondary};
${textStyle('label2')};
`}
>
{heading}
</h1>
<div
css={`
position: relative;
flex-grow: 1;
width: 100%;
`}
>
{children}
</div>
</AnimatedSection>
)}
</Spring>
</Popover>
)
}
HeaderPopover.propTypes = {
animateHeight: PropTypes.bool.isRequired,
children: PropTypes.node.isRequired,
heading: PropTypes.node.isRequired,
height: PropTypes.number.isRequired,
onClose: PropTypes.func.isRequired,
opener: PropTypes.any,
visible: PropTypes.bool.isRequired,
}
export default HeaderPopover