forked from polkadot-js/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSidebar.tsx
62 lines (56 loc) · 1.46 KB
/
Sidebar.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
// Copyright 2017-2022 @polkadot/app-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import styled from 'styled-components';
import Button from './Button';
interface Props {
button?: React.ReactNode;
children: React.ReactNode;
className?: string;
dataTestId?: string;
offset?: number | string;
onClose: () => void;
position: 'left' | 'right';
sidebarRef: React.RefObject<HTMLDivElement>;
}
function Sidebar ({ button, children, className = '', dataTestId = '', onClose, sidebarRef }: Props): React.ReactElement<Props> {
return (
<div
className={`ui--Sidebar ${className}`}
data-testid={dataTestId}
ref={sidebarRef}
>
<Button.Group className='ui--Sidebar-buttons'>
{button}
<Button
dataTestId='close-sidebar-button'
icon='times'
isBasic
isCircular
onClick={onClose}
/>
</Button.Group>
{children}
</div>
);
}
export default React.memo(styled(Sidebar)(({ offset = 0, position }: Props) => `
background: var(--bg-page);
bottom: 0;
box-shadow: ${position === 'right' ? '-6px' : '6px'} 0px 20px 0px rgba(0, 0, 0, 0.3);
margin-left: -0.125rem;
max-width: 24rem;
min-width: 24rem;
position: fixed;
padding: 1rem;
overflow-y: auto;
top: 0;
z-index: 999;
${position}: ${offset};
.ui--Sidebar-buttons {
margin: 0;
position: absolute;
right: 0.5rem;
top: 0.5rem;
}
`));