FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mcjava-wiki/src/components/DocLayout.tsx at main · mcjava-wiki/mcjava-wiki · GitHub
mcjava-wiki
mcjava-wiki
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mcjava-wiki
/
src
/
components
/
DocLayout.tsx
Copy path
More file actions
More file actions
Latest commit
History
History
History
240 lines (219 loc) · 5.38 KB
Breadcrumbs
mcjava-wiki
/
src
/
components
/
DocLayout.tsx
Copy path
File metadata and controls
240 lines (219 loc) · 5.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import
*
as
React
from
'react'
import
{
graphql
,
useStaticQuery
}
from
'gatsby'
import
styled
,
{
x
,
css
,
up
,
down
,
th
,
useUp
}
from
'@xstyled/styled-components'
import
{
useDialogState
,
Dialog
,
DialogDisclosure
}
from
'ariakit/dialog'
import
{
Portal
}
from
'ariakit/portal'
import
{
FaBars
}
from
'react-icons/fa'
import
{
RiEditCircleFill
,
RiGithubFill
}
from
'react-icons/ri'
import
{
ScreenContainer
}
from
'./ScreenContainer'
import
{
SideNav
,
useSideNavState
,
useSideNavPrevNext
}
from
'./SideNav'
import
{
PageLayout
}
from
'./PageLayout'
import
{
SiblingNav
,
SiblingNavLink
}
from
'./SiblingNav'
import
{
Article
}
from
'./Article'
import
{
TableOfContents
}
from
'./TableOfContents'
import
{
Contributors
}
from
'./Contributors'
import
{
DocSearch
}
from
'./DocSearch'
const
SidebarDialog
=
styled
.
div
`
background-color: background-light-a50;
backdrop-filter: blur(3px);
position: fixed;
top: 50;
right: 0;
bottom: 0;
left: 0;
z-index: 20;
overflow: auto;
transition: base;
opacity: 0;
transition: opacity 250ms ease-in-out, transform 250ms ease-in-out;
transform: translate3d(0, 10vh, 0);
&[data-enter] {
opacity: 1;
transform: translate3d(0, 0, 0);
}
&:focus {
outline: none;
}
`
const
Container
=
styled
.
div
`
z-index: 0;
position: relative;
${
up
(
'md'
,
css
`
display: grid;
grid-template-columns: 288px minmax(0, 1fr);
grid-gap:
${
th
.
space
(
5
)
}
;
.sidebar-container {
display: none;
}
`
,
)
}
${
up
(
'xl'
,
css
`
grid-template-columns: 288px minmax(0, 1fr) 288px;
.sidebar-container {
display: none;
}
`
,
)
}
`
const
TocContainer
=
styled
.
div
`
${
down
(
'xl'
,
css
`
display: none;
`
,
)
}
`
const
SidebarSticky
=
styled
.
aside
`
position: sticky;
top:
${
th
.
px
(
50
)
}
;
padding: 4 0;
overflow-y: auto;
height: calc(100vh - 50px);
width: 288px;
${
down
(
'md'
,
css
`
display: none;
`
,
)
}
`
const
MenuButton
=
styled
.
button
`
appearance: none;
border: 0;
border-radius: 20%;
width: 60;
height: 60;
position: fixed;
right:
${
th
.
size
(
8
)
}
;
top:
${
th
.
size
(
55
)
}
;
z-index: 25;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: background;
background-color: on-background;
transition: base;
transition-property: color;
&:focus {
color: background;
}
> svg {
width: 30;
height: 30;
transition: transform 200ms ease-in-out;
}
&[aria-expanded='true'] {
> svg:last-child {
transform: rotate(90deg);
}
}
`
const
DocSearchQuery
=
graphql
`
query DocSearch {
site {
siteMetadata {
docSearch {
apiKey
indexName
appId
}
}
}
}
`
function
MobileSidebar
(
{
children
}
:
{
children
:
React
.
ReactNode
}
)
{
const
dialog
=
useDialogState
(
{
animated
:
true
}
)
const
data
:
Queries
.
DocSearchQuery
=
useStaticQuery
(
DocSearchQuery
)
if
(
!
data
.
site
||
!
data
.
site
.
siteMetadata
)
return
null
;
const
docSearch
=
data
.
site
.
siteMetadata
.
docSearch
;
if
(
!
docSearch
)
return
null
;
return
(
<
>
<
Dialog
state
=
{
dialog
}
as
=
{
SidebarDialog
}
>
<
div
style
=
{
{
paddingLeft
:
20
,
paddingTop
:
20
}
}
>
<
DocSearch
apiKey
=
{
docSearch
.
apiKey
}
indexName
=
{
docSearch
.
indexName
}
appId
=
{
docSearch
.
appId
||
''
}
/>
</
div
>
{
children
}
</
Dialog
>
<
Portal
>
<
DialogDisclosure
state
=
{
dialog
}
as
=
{
MenuButton
}
>
<
FaBars
/>
</
DialogDisclosure
>
</
Portal
>
</
>
)
}
function
PrevNextLinks
(
{
editLink
,
...
props
}
:
{
navGroups
:
any
;
}
&
{
[
x
:
string
]
:
any
;
}
)
{
const
{
prev
,
next
}
=
useSideNavPrevNext
(
props
)
if
(
!
prev
&&
!
next
)
return
null
return
(
<
SiblingNav
>
{
prev
&&
(
<
SiblingNavLink
type
=
"previous"
to
=
{
prev
.
fields
.
slug
}
>
{
prev
.
fields
.
title
}
</
SiblingNavLink
>
)
}
<
div
style
=
{
{
gridArea
:
"edit"
,
fontSize
:
32
}
}
>
{
editLink
&&
(
<
x
.
a
mt
=
{
0
}
display
=
"grid"
gridTemplateColumns
=
"min-content max-content"
href
=
{
editLink
}
>
<
RiEditCircleFill
/>
<
RiGithubFill
/>
</
x
.
a
>
)
}
</
div
>
{
next
&&
(
<
SiblingNavLink
type
=
"next"
to
=
{
next
.
fields
.
slug
}
>
{
next
.
fields
.
title
}
</
SiblingNavLink
>
)
}
</
SiblingNav
>
)
}
export
function
DocLayout
(
{
children
,
tableOfContents
,
editLink
,
contributors
,
title
,
...
props
}
:
{
children
:
React
.
ReactNode
,
tableOfContents
:
any
,
editLink
:
string
,
contributors
:
any
,
title
:
string
,
props
?:
any
}
)
{
const
upMd
=
useUp
(
'md'
)
const
sideNav
:
any
=
useSideNavState
(
)
return
(
<
PageLayout
title
=
{
title
}
{
...
props
}
>
<
ScreenContainer
px
=
{
0
}
>
<
Container
>
<
SidebarSticky
>
<
SideNav
{
...
sideNav
}
/>
</
SidebarSticky
>
<
div
className
=
"sidebar-container"
>
{
!
upMd
&&
(
<
MobileSidebar
>
<
SideNav
{
...
sideNav
}
/>
</
MobileSidebar
>
)
}
</
div
>
<
x
.
div
pb
=
{
6
}
px
=
{
3
}
>
<
Article
>
{
children
}
<
Contributors
contributors
=
{
contributors
}
/>
<
PrevNextLinks
{
...
sideNav
}
editLink
=
{
editLink
}
/>
</
Article
>
</
x
.
div
>
<
TocContainer
>
<
TableOfContents
/>
</
TocContainer
>
</
Container
>
</
ScreenContainer
>
</
PageLayout
>
)
}
Back
|
FazBrowse Home
|
New Git URL