astro-better-docs-sidebar 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/Sidebar.astro +38 -38
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -169,7 +169,7 @@ order: 1
|
|
|
169
169
|
|
|
170
170
|
The component uses Tailwind CSS `@apply` directives and expects Tailwind to be configured in the consuming project. All styles are injected with `<style is:global>` so they apply regardless of where the component is placed.
|
|
171
171
|
|
|
172
|
-
The sidebar renders a `<nav class="
|
|
172
|
+
The sidebar renders a `<nav class="abt-sidebar">` element, and every style is scoped to that class, so the sidebar works in any wrapper. To override a style, target `nav.abt-sidebar`, such as `nav.abt-sidebar a[aria-current="page"]`. Wrap the sidebar in `<aside class="aside">` to get the default width, border, and background:
|
|
173
173
|
|
|
174
174
|
```astro
|
|
175
175
|
<aside class="aside">
|
|
@@ -179,6 +179,10 @@ The sidebar renders a `<nav class="nav">` element. Wrap it in `<aside class="asi
|
|
|
179
179
|
|
|
180
180
|
Dark mode is supported via the `.dark` class on a parent element.
|
|
181
181
|
|
|
182
|
+
## Upgrading to 1.2.0
|
|
183
|
+
|
|
184
|
+
Styles are scoped to `nav.abt-sidebar` instead of `#side-nav nav`, so the sidebar no longer needs a `#side-nav` ancestor. The new selectors are less specific than the old ones. If your site overrides sidebar styles with selectors weaker than `#side-nav nav ...`, check that the overrides still apply.
|
|
185
|
+
|
|
182
186
|
## SidebarItem
|
|
183
187
|
|
|
184
188
|
The `SidebarItem` component renders individual tree nodes recursively. It is exported separately if you need to build a custom tree and render nodes manually:
|
package/Sidebar.astro
CHANGED
|
@@ -24,7 +24,7 @@ const treeArray = sidebarFor(collection, { basePath, folderBehavior, overviewLab
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
<nav>
|
|
27
|
+
<nav class="abt-sidebar">
|
|
28
28
|
{treeArray.map(node => <SidebarItem node={node} />)}
|
|
29
29
|
</nav>
|
|
30
30
|
|
|
@@ -32,58 +32,58 @@ const treeArray = sidebarFor(collection, { basePath, folderBehavior, overviewLab
|
|
|
32
32
|
@reference "tailwindcss";
|
|
33
33
|
|
|
34
34
|
aside.aside { @apply w-64 shrink-0 border-r border-gray-200 bg-white pt-2 pr-2; }
|
|
35
|
-
|
|
35
|
+
nav.abt-sidebar { @apply flex flex-col gap-1; }
|
|
36
36
|
|
|
37
37
|
/* depth line */
|
|
38
|
-
|
|
38
|
+
nav.abt-sidebar details > div { @apply flex flex-col gap-0.5 pl-3 ml-3 border-l border-slate-200; }
|
|
39
39
|
|
|
40
40
|
/* folder header row */
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
nav.abt-sidebar summary { @apply flex items-center justify-between cursor-pointer select-none rounded gap-1 transition-colors text-slate-700; list-style: none; }
|
|
42
|
+
nav.abt-sidebar summary::-webkit-details-marker { display: none; }
|
|
43
43
|
|
|
44
44
|
/* leaf links and folder labels */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
nav.abt-sidebar :is(a, span) { @apply flex-1 text-sm py-1 px-2 rounded transition-colors no-underline block text-slate-700; }
|
|
46
|
+
nav.abt-sidebar a { @apply cursor-pointer; }
|
|
47
|
+
nav.abt-sidebar span { @apply cursor-default; }
|
|
48
48
|
|
|
49
49
|
/* chevron */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
nav.abt-sidebar i { @apply flex items-center justify-center w-7 h-7 rounded text-gray-400 shrink-0 transition-transform; }
|
|
51
|
+
nav.abt-sidebar i::after { content: ''; @apply w-[0.4rem] h-[0.4rem] border-r-2 border-b-2 border-current block -rotate-45 transition-transform box-border; }
|
|
52
|
+
nav.abt-sidebar details[open] > summary i::after { @apply rotate-45; }
|
|
53
53
|
|
|
54
54
|
/* clicking a closed folder opens it; disables the link's own navigation */
|
|
55
|
-
|
|
55
|
+
nav.abt-sidebar details:not([open]) > summary a { pointer-events: none; }
|
|
56
56
|
|
|
57
57
|
/* HOVERS */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
nav.abt-sidebar a:not(summary a):hover { @apply bg-slate-100 text-indigo-600; }
|
|
59
|
+
nav.abt-sidebar details:not([open]) > summary:hover,
|
|
60
|
+
nav.abt-sidebar summary:not(:has(a)):hover { @apply bg-slate-100; }
|
|
61
|
+
nav.abt-sidebar details:not([open]) > summary:hover :is(a, span),
|
|
62
|
+
nav.abt-sidebar summary:not(:has(a)):hover span { @apply text-indigo-600; }
|
|
63
|
+
nav.abt-sidebar details[open] > summary:has(a) a:hover { @apply bg-slate-100 text-indigo-600; }
|
|
64
|
+
nav.abt-sidebar details[open] > summary:has(a) i:hover { @apply bg-slate-100 text-slate-700; }
|
|
65
65
|
|
|
66
66
|
/* ACTIVE & ANCESTOR STATES */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
nav.abt-sidebar a[aria-current="page"],
|
|
68
|
+
nav.abt-sidebar summary:has(> a[aria-current="page"]) :is(a, span) { @apply font-semibold text-indigo-600 bg-indigo-50; }
|
|
69
|
+
nav.abt-sidebar a[data-a],
|
|
70
|
+
nav.abt-sidebar summary[data-a] :is(a, span) { @apply font-semibold text-slate-900; }
|
|
71
|
+
nav.abt-sidebar summary:has(> [aria-current="page"]) i,
|
|
72
|
+
nav.abt-sidebar details:has([aria-current="page"]) > summary i { @apply text-indigo-500; }
|
|
73
73
|
|
|
74
74
|
/* DARK MODE */
|
|
75
75
|
.dark aside.aside { @apply border-gray-800 bg-gray-900; }
|
|
76
|
-
.dark
|
|
77
|
-
.dark
|
|
78
|
-
.dark
|
|
79
|
-
.dark
|
|
80
|
-
.dark
|
|
81
|
-
.dark
|
|
82
|
-
.dark
|
|
83
|
-
.dark
|
|
84
|
-
.dark
|
|
85
|
-
.dark
|
|
86
|
-
.dark
|
|
87
|
-
.dark
|
|
88
|
-
.dark
|
|
76
|
+
.dark nav.abt-sidebar :is(a, span) { @apply text-slate-400; }
|
|
77
|
+
.dark nav.abt-sidebar details > div { @apply border-slate-700; }
|
|
78
|
+
.dark nav.abt-sidebar a:not(summary a):hover { @apply bg-slate-800 text-indigo-400; }
|
|
79
|
+
.dark nav.abt-sidebar details:not([open]) > summary:hover,
|
|
80
|
+
.dark nav.abt-sidebar summary:not(:has(a)):hover { @apply bg-slate-800; }
|
|
81
|
+
.dark nav.abt-sidebar details:not([open]) > summary:hover :is(a, span),
|
|
82
|
+
.dark nav.abt-sidebar summary:not(:has(a)):hover span { @apply text-indigo-400; }
|
|
83
|
+
.dark nav.abt-sidebar details[open] > summary:has(a) a:hover { @apply bg-slate-800 text-indigo-400; }
|
|
84
|
+
.dark nav.abt-sidebar details[open] > summary:has(a) i:hover { @apply bg-slate-800 text-slate-200; }
|
|
85
|
+
.dark nav.abt-sidebar a[aria-current="page"],
|
|
86
|
+
.dark nav.abt-sidebar summary:has(> a[aria-current="page"]) :is(a, span) { @apply text-indigo-400 bg-indigo-950/40; }
|
|
87
|
+
.dark nav.abt-sidebar a[data-a],
|
|
88
|
+
.dark nav.abt-sidebar summary[data-a] :is(a, span) { @apply text-white; }
|
|
89
89
|
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-better-docs-sidebar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"astro",
|
|
6
6
|
"sidebar",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/better-static-sites/better-static-sites.github.io.git",
|
|
14
|
-
"directory": "
|
|
14
|
+
"directory": "lib/docs-sidebar"
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://better-static-sites.github.io",
|
|
17
17
|
"bugs": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"*.astro",
|
|
27
27
|
"tree.js"
|
|
28
28
|
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node --test test/"
|
|
31
|
+
},
|
|
29
32
|
"dependencies": {
|
|
30
33
|
"marked": "^17.0.0"
|
|
31
34
|
},
|
|
32
35
|
"peerDependencies": {
|
|
33
36
|
"astro": ">=4.0.0"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"test": "node --test test/"
|
|
37
37
|
}
|
|
38
38
|
}
|