Skip to content

Commit 0636877

Browse files
committed
add Sidebar
1 parent f74d58c commit 0636877

File tree

2 files changed

+369
-0
lines changed

2 files changed

+369
-0
lines changed

src/PlutoUI.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ end # 0.1 second
2626
@reexport module TableOfContentsNotebook
2727
include("./TableOfContents.jl")
2828
end # 0.1 second
29+
@reexport module SidebarNotebook
30+
include("./Sidebar.jl")
31+
end
2932
@reexport module ClockNotebook
3033
include("./Clock.jl")
3134
end # 0.04 second

src/Sidebar.jl

Lines changed: 366 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,366 @@
1+
### A Pluto.jl notebook ###
2+
# v0.19.25
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
8+
macro bind(def, element)
9+
quote
10+
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
11+
local el = $(esc(element))
12+
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
13+
el
14+
end
15+
end
16+
17+
# ╔═╡ 2d3f1d9d-2c06-4f15-a2f3-f72134e08235
18+
using PlutoUI
19+
20+
# ╔═╡ 18a62430-6ca5-4c7c-94bb-be7db46fe7d8
21+
using HypertextLiteral
22+
23+
# ╔═╡ cb0f1bfd-0ea9-42c6-b696-ab68a2aa703b
24+
25+
26+
# ╔═╡ 5b4c46e4-a4ab-43d9-98ef-bb69c75bdda6
27+
function _loc_to_style(loc::String)
28+
vert, hor = split(loc)
29+
res = Dict(
30+
"upper" => "top: 0;",
31+
"lower" => "bottom: 0;",
32+
"center" => "top: 50%; transform: translateY(-50%);",
33+
)[vert] * Dict(
34+
"right" => "right: 0;",
35+
"left" => "left: 0;",
36+
"center" => "left: 50%; transform: translateX(-50%);",
37+
)[hor] * get(Dict(
38+
# minor corrections for some locations:
39+
"lower right" => "bottom: 56px;",
40+
"center center" => "transform: translateX(-50%) translateY(-50%);",
41+
), loc, "")
42+
end
43+
44+
# ╔═╡ 959aba38-f7b6-11ed-3890-c1a32e414109
45+
Sidebar(elts...; location="upper right") = @htl("""
46+
<aside class="sidebar" style=$(_loc_to_style(location))>$elts</aside>
47+
48+
<style>
49+
aside.sidebar {
50+
position: fixed;
51+
max-width: min(80vw, 1000px);
52+
padding: 0.5rem;
53+
border: 3px solid rgba(0, 0, 0, 0.15);
54+
border-radius: 10px;
55+
box-shadow: 0 0 11px 0px #00000010;
56+
max-height: calc(100vh - 5rem);
57+
overflow: auto;
58+
z-index: 100;
59+
background-color: var(--main-bg-color);
60+
}
61+
62+
aside.aside-sticky table {
63+
margin: 0.2rem 0;
64+
}
65+
</style>
66+
""")
67+
68+
# ╔═╡ 8dfccfed-0561-407d-91c3-cc89023c83b2
69+
map(Iterators.product(["upper", "center", "lower"], ["left", "center", "right"])) do (v, h)
70+
Sidebar(embed_display((;v, h)), location="$v $h")
71+
end |> vec
72+
73+
# ╔═╡ 4175be46-cc6e-44bf-b853-aa4f6846a842
74+
Sidebar(
75+
"abc "^10,
76+
md"---",
77+
(@bind a Slider(1:10)),
78+
)
79+
80+
# ╔═╡ 48aecfd3-6954-47f0-970a-27533a7e23ec
81+
a
82+
83+
# ╔═╡ 00000000-0000-0000-0000-000000000001
84+
PLUTO_PROJECT_TOML_CONTENTS = """
85+
[deps]
86+
HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
87+
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
88+
89+
[compat]
90+
HypertextLiteral = "~0.9.4"
91+
PlutoUI = "~0.7.51"
92+
"""
93+
94+
# ╔═╡ 00000000-0000-0000-0000-000000000002
95+
PLUTO_MANIFEST_TOML_CONTENTS = """
96+
# This file is machine-generated - editing it directly is not advised
97+
98+
julia_version = "1.9.0"
99+
manifest_format = "2.0"
100+
project_hash = "11e58608bab65beeb6c78bd55bbc9fd3623da2fd"
101+
102+
[[deps.AbstractPlutoDingetjes]]
103+
deps = ["Pkg"]
104+
git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
105+
uuid = "6e696c72-6542-2067-7265-42206c756150"
106+
version = "1.1.4"
107+
108+
[[deps.ArgTools]]
109+
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
110+
version = "1.1.1"
111+
112+
[[deps.Artifacts]]
113+
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
114+
115+
[[deps.Base64]]
116+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
117+
118+
[[deps.ColorTypes]]
119+
deps = ["FixedPointNumbers", "Random"]
120+
git-tree-sha1 = "eb7f0f8307f71fac7c606984ea5fb2817275d6e4"
121+
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
122+
version = "0.11.4"
123+
124+
[[deps.CompilerSupportLibraries_jll]]
125+
deps = ["Artifacts", "Libdl"]
126+
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
127+
version = "1.0.2+0"
128+
129+
[[deps.Dates]]
130+
deps = ["Printf"]
131+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
132+
133+
[[deps.Downloads]]
134+
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
135+
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
136+
version = "1.6.0"
137+
138+
[[deps.FileWatching]]
139+
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
140+
141+
[[deps.FixedPointNumbers]]
142+
deps = ["Statistics"]
143+
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
144+
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
145+
version = "0.8.4"
146+
147+
[[deps.Hyperscript]]
148+
deps = ["Test"]
149+
git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
150+
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
151+
version = "0.0.4"
152+
153+
[[deps.HypertextLiteral]]
154+
deps = ["Tricks"]
155+
git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9"
156+
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
157+
version = "0.9.4"
158+
159+
[[deps.IOCapture]]
160+
deps = ["Logging", "Random"]
161+
git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6"
162+
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
163+
version = "0.2.3"
164+
165+
[[deps.InteractiveUtils]]
166+
deps = ["Markdown"]
167+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
168+
169+
[[deps.JSON]]
170+
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
171+
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
172+
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
173+
version = "0.21.4"
174+
175+
[[deps.LibCURL]]
176+
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
177+
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
178+
version = "0.6.3"
179+
180+
[[deps.LibCURL_jll]]
181+
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
182+
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
183+
version = "7.84.0+0"
184+
185+
[[deps.LibGit2]]
186+
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
187+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
188+
189+
[[deps.LibSSH2_jll]]
190+
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
191+
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
192+
version = "1.10.2+0"
193+
194+
[[deps.Libdl]]
195+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
196+
197+
[[deps.LinearAlgebra]]
198+
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
199+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
200+
201+
[[deps.Logging]]
202+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
203+
204+
[[deps.MIMEs]]
205+
git-tree-sha1 = "65f28ad4b594aebe22157d6fac869786a255b7eb"
206+
uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
207+
version = "0.1.4"
208+
209+
[[deps.Markdown]]
210+
deps = ["Base64"]
211+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
212+
213+
[[deps.MbedTLS_jll]]
214+
deps = ["Artifacts", "Libdl"]
215+
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
216+
version = "2.28.2+0"
217+
218+
[[deps.Mmap]]
219+
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
220+
221+
[[deps.MozillaCACerts_jll]]
222+
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
223+
version = "2022.10.11"
224+
225+
[[deps.NetworkOptions]]
226+
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
227+
version = "1.2.0"
228+
229+
[[deps.OpenBLAS_jll]]
230+
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
231+
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
232+
version = "0.3.21+4"
233+
234+
[[deps.Parsers]]
235+
deps = ["Dates", "PrecompileTools", "UUIDs"]
236+
git-tree-sha1 = "a5aef8d4a6e8d81f171b2bd4be5265b01384c74c"
237+
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
238+
version = "2.5.10"
239+
240+
[[deps.Pkg]]
241+
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
242+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
243+
version = "1.9.0"
244+
245+
[[deps.PlutoUI]]
246+
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"]
247+
git-tree-sha1 = "b478a748be27bd2f2c73a7690da219d0844db305"
248+
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
249+
version = "0.7.51"
250+
251+
[[deps.PrecompileTools]]
252+
deps = ["Preferences"]
253+
git-tree-sha1 = "259e206946c293698122f63e2b513a7c99a244e8"
254+
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
255+
version = "1.1.1"
256+
257+
[[deps.Preferences]]
258+
deps = ["TOML"]
259+
git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1"
260+
uuid = "21216c6a-2e73-6563-6e65-726566657250"
261+
version = "1.4.0"
262+
263+
[[deps.Printf]]
264+
deps = ["Unicode"]
265+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
266+
267+
[[deps.REPL]]
268+
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
269+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
270+
271+
[[deps.Random]]
272+
deps = ["SHA", "Serialization"]
273+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
274+
275+
[[deps.Reexport]]
276+
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
277+
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
278+
version = "1.2.2"
279+
280+
[[deps.SHA]]
281+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
282+
version = "0.7.0"
283+
284+
[[deps.Serialization]]
285+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
286+
287+
[[deps.Sockets]]
288+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
289+
290+
[[deps.SparseArrays]]
291+
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
292+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
293+
294+
[[deps.Statistics]]
295+
deps = ["LinearAlgebra", "SparseArrays"]
296+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
297+
version = "1.9.0"
298+
299+
[[deps.SuiteSparse_jll]]
300+
deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"]
301+
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
302+
version = "5.10.1+6"
303+
304+
[[deps.TOML]]
305+
deps = ["Dates"]
306+
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
307+
version = "1.0.3"
308+
309+
[[deps.Tar]]
310+
deps = ["ArgTools", "SHA"]
311+
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
312+
version = "1.10.0"
313+
314+
[[deps.Test]]
315+
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
316+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
317+
318+
[[deps.Tricks]]
319+
git-tree-sha1 = "aadb748be58b492045b4f56166b5188aa63ce549"
320+
uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
321+
version = "0.1.7"
322+
323+
[[deps.URIs]]
324+
git-tree-sha1 = "074f993b0ca030848b897beff716d93aca60f06a"
325+
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
326+
version = "1.4.2"
327+
328+
[[deps.UUIDs]]
329+
deps = ["Random", "SHA"]
330+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
331+
332+
[[deps.Unicode]]
333+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
334+
335+
[[deps.Zlib_jll]]
336+
deps = ["Libdl"]
337+
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
338+
version = "1.2.13+0"
339+
340+
[[deps.libblastrampoline_jll]]
341+
deps = ["Artifacts", "Libdl"]
342+
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
343+
version = "5.7.0+0"
344+
345+
[[deps.nghttp2_jll]]
346+
deps = ["Artifacts", "Libdl"]
347+
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
348+
version = "1.48.0+0"
349+
350+
[[deps.p7zip_jll]]
351+
deps = ["Artifacts", "Libdl"]
352+
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
353+
version = "17.4.0+0"
354+
"""
355+
356+
# ╔═╡ Cell order:
357+
# ╠═2d3f1d9d-2c06-4f15-a2f3-f72134e08235
358+
# ╠═8dfccfed-0561-407d-91c3-cc89023c83b2
359+
# ╠═4175be46-cc6e-44bf-b853-aa4f6846a842
360+
# ╠═48aecfd3-6954-47f0-970a-27533a7e23ec
361+
# ╠═cb0f1bfd-0ea9-42c6-b696-ab68a2aa703b
362+
# ╠═18a62430-6ca5-4c7c-94bb-be7db46fe7d8
363+
# ╠═959aba38-f7b6-11ed-3890-c1a32e414109
364+
# ╠═5b4c46e4-a4ab-43d9-98ef-bb69c75bdda6
365+
# ╟─00000000-0000-0000-0000-000000000001
366+
# ╟─00000000-0000-0000-0000-000000000002

0 commit comments

Comments
 (0)