forked from moshiuzzaman/devsonket.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSheet.js
More file actions
124 lines (121 loc) · 2.61 KB
/
Copy pathSheet.js
File metadata and controls
124 lines (121 loc) · 2.61 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import React from "react"
import styled from "@emotion/styled"
import { FiLink } from "react-icons/fi"
const SheetContainer = styled.div`
& h3 {
font-size: 20px;
margin-bottom: 15px;
@media print {
color: #000;
}
}
:hover a {
opacity: 0.85;
}
.single-item {
background-color: #fff;
margin-bottom: 25px;
border-radius: 4px;
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.3);
@media print {
display: flex;
flex-wrap: wrap;
padding: 0;
box-shadow: none;
}
}
.single-item .item {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 15px 20px;
border-bottom: solid 1px var(--accentaction);
:nth-of-type(even) {
background: var(--accentlight);
}
@media print {
margin: 0 5px;
padding-bottom: 0px;
flex: 2 2 calc(50% - 10px);
border: none;
}
}
.single-item .item:last-child {
margin-bottom: 0;
border-bottom: none;
}
.single-item .def {
flex: 1 1 50%;
padding: 5px;
}
.single-item .def a {
color: #000;
}
.single-item .code,
.single-item p {
margin-bottom: 0;
}
.single-item pre {
padding: 5px;
background-color: transparent;
color: #1565c0;
}
@media only screen and (max-width: 940px) {
pre.code {
overflow-y: hidden;
white-space: pre-wrap;
overflow: hidden;
word-wrap: break-word;
}
}
`
const SheetTitle = styled.div`
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
& a {
text-decoration: none;
color: var(--accentdark);
font-weight: 900;
text-transform: uppercase;
font-size: 13px;
padding: 1px 10px;
border-radius: 4px;
margin-bottom: 15px;
opacity: 0;
}
`
export const Sheet = ({ title, slug, items, onlyCode }) => (
<SheetContainer id={title}>
<SheetTitle className="sheet-title">
<h3>{title}</h3>
<a href={`${slug}#${title}`}>
<FiLink />
</a>
</SheetTitle>
<ul className="single-item">
{items ? (
items.map(({ definition, code }, index) => (
<li key={index} className="item">
{definition && (
<p
className="def"
dangerouslySetInnerHTML={{ __html: definition }}
/>
)}
{code && (
<pre className="code">
<code>{code}</code>
</pre>
)}
</li>
))
) : (
<pre className="code">
<code>{onlyCode}</code>
</pre>
)}
</ul>
</SheetContainer>
)