This repository was archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathMethodTable.js
84 lines (72 loc) · 1.69 KB
/
MethodTable.js
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
import React from "react";
import styled from "styled-components";
import PropTypes from "prop-types";
import { PALETTE, FONT_WEIGHT } from "constants/styles";
import { Code, Table } from "basics/Text";
const MethodTableEl = styled.div`
display: flex;
flex-direction: column;
overflow: hidden;
background: ${PALETTE.white80};
border: 1px solid ${PALETTE.white60};
border-radius: 4px;
max-height: 56.25rem;
width: 100%;
margin-bottom: 2rem;
thead {
display: none;
}
td {
border: none;
padding: 0.5rem 0;
vertical-align: top;
line-height: 1.5;
&:first-child {
font-weight: ${FONT_WEIGHT.bold};
padding-right: 1rem;
}
}
`;
const TitleEl = styled.div`
display: flex;
justify-content: space-between;
position: relative;
padding: 1rem;
border-bottom: 1px solid ${PALETTE.white60};
font-size: 0.875rem;
font-weight: ${FONT_WEIGHT.bold};
`;
const ContentEl = styled.div`
overflow-y: auto;
padding: 0;
padding: 1rem 0;
${Code} {
padding-left: 1rem;
}
${Table} {
padding: 0 1rem;
}
::-webkit-scrollbar {
width: 0px; /* Remove scrollbar space */
background: transparent; /* Optional: just make scrollbar invisible */
}
`;
/**
* Note: This exports a React component instead of a styled-component.
* [Design Mockup](https://zpl.io/V1DGqJ5)
*/
export const MethodTable = React.forwardRef(function MethodTable(
{ title, children, ...props },
ref,
) {
return (
<MethodTableEl ref={ref} {...props}>
<TitleEl>{title}</TitleEl>
<ContentEl>{children}</ContentEl>
</MethodTableEl>
);
});
MethodTable.propTypes = {
title: PropTypes.node.isRequired,
children: PropTypes.node.isRequired,
};