FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
structeezy-docs/src/components/tutorial/TutorialNav.astro at main · thewebforge/structeezy-docs · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
thewebforge
/
structeezy-docs
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
0
Code
Issues
8
Pull requests
1
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
structeezy-docs
/
src
/
components
/
tutorial
/
TutorialNav.astro
Copy path
More file actions
More file actions
Latest commit
History
History
History
138 lines (122 loc) · 3.36 KB
Breadcrumbs
structeezy-docs
/
src
/
components
/
tutorial
/
TutorialNav.astro
Copy path
File metadata and controls
138 lines (122 loc) · 3.36 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
---
import
{
tutorialPages
as
pages
}
from
'
~/content
'
;
import
{
getLanguageFromURL
,
stripLangFromSlug
}
from
'
~/utils
'
;
import
{
getTutorialPages
,
getTutorialUnits
}
from
'
~/utils
'
;
import
TabbedContent
from
'
../tabs/TabbedContent.astro
'
;
import
TabListItem
from
'
../tabs/TabListItem.astro
'
;
import
TabPanel
from
'
../tabs/TabPanel.astro
'
;
import
Progress
from
'
./Progress.astro
'
;
import
UnitProgressIcon
from
'
./UnitProgressIcon.astro
'
;
export
interface
Props
{
id
:
string
;
}
const
currentUrl
=
Astro
.
url
.
pathname
.
replace
(
/
\/
$
/
,
'
'
);
const
lang
=
getLanguageFromURL
(
Astro
.
url
.
pathname
);
const
tutorialPages
=
getTutorialPages
(
pages
,
lang
);
const
units
=
getTutorialUnits
(
tutorialPages
);
const
makeUnitId
=
(
index
:
number
)
=>
`
${
Astro
.
props
.
id
}__tutorial-unit-nav-panel-${
index
}
`
;
const
isCurrentUnit
=
(
unit
:
(
typeof
units
)[
number
])
=>
unit
.
lessons
.
some
((
lesson
)
=>
currentUrl
.
endsWith
(
stripLangFromSlug
(
lesson
.
slug
)));
---
<
div
class
=
"
tutorial-nav
"
>
<
TabbedContent
>
<
Fragment
slot
=
"
tab-list
"
>
{
units
.
map
((
unit
,
idx
)
=>
(
<
TabListItem
id
=
{
makeUnitId
(
idx
)
}
initial
=
{
isCurrentUnit
(
unit
)
}
>
<
UnitProgressIcon
unitNumber
=
{
idx
}
paths
=
{
unit
.
lessons
.
map
((
l
)
=>
'
/
'
+
l
.
slug
)
}
/>
</
TabListItem
>
))
}
</
Fragment
>
{
units
.
map
((
unit
,
idx
)
=>
(
<
TabPanel
id
=
{
makeUnitId
(
idx
)
}
initial
=
{
isCurrentUnit
(
unit
)
}
>
<
div
class
=
"
unit
"
>
<
h2
class
=
"
heading
"
>
{
unit
.
title
}
</
h2
>
<
ol
class
=
"
lessons
"
>
{
unit
.
lessons
.
map
(
async
(
lesson
,
index
)
=>
{
const
slugWithoutLang
=
stripLangFromSlug
(
lesson
.
slug
);
return
(
<
li
>
<
div
>
<
a
class
=
"
header-link
"
href
=
{
`
/${
lang
}/${
slugWithoutLang
}/
`
}
aria-current
=
{
currentUrl
.
endsWith
(
slugWithoutLang
)
}
>
<
Progress
{
index
}
path
=
{
'
/
'
+
lesson
.
slug
}
/>
{
lesson
.
data
.
title
}
</
a
>
</
div
>
{
currentUrl
.
endsWith
(
lesson
.
slug
)
&&
(
<
ul
class
=
"
on-this-page
"
>
{
(
await
lesson
.
render
()).
headings
.
filter
(({
depth
})
=>
depth
<=
2
)
.
map
((
h
)
=>
(
<
li
>
<
a
class
=
"
header-link
"
href
=
{
'
#
'
+
h
.
slug
}
>
{
h
.
text
}
</
a
>
</
li
>
))
}
</
ul
>
)
}
</
li
>
);
})
}
</
ol
>
</
div
>
</
TabPanel
>
))
}
</
TabbedContent
>
</
div
>
<
style
>
.tutorial-nav {
width: 100%;
font-size: var(--sl-text-xs);
}
.unit {
padding: 1em;
background-color: var(--sl-color-gray-6);
box-shadow: 0px 0px 0px 1px var(--sl-color-gray-5);
border-radius: 0.25rem;
}
:global(section:first-child) .unit {
border-radius: 0 0.25rem 0.25rem 0.25rem;
}
:global(section:last-child) .unit {
border-radius: 0.25rem 0 0.25rem 0.25rem;
}
.tutorial-nav ol.lessons {
margin: 0;
padding-inline-start: 0;
list-style: none;
}
h2.heading {
font-size: var(--sl-text-sm);
margin-top: 0;
padding: 0;
}
a[aria-current='true'] {
color: var(--sl-color-white);
font: bold;
}
a[aria-current='true'] :global(.circle) {
border-color: var(--sl-color-gray-1);
}
a[data-status='complete'] :global(.circle) {
border-color: transparent;
}
.header-link[data-status='complete'] {
color: var(--sl-color-green-high);
}
.header-link :global(.circle) {
opacity: 1;
margin-top: -0.125rem;
}
.on-this-page {
margin-bottom: 0.5rem;
}
</
style
>
Back
|
FazBrowse Home
|
New Git URL