Skip to content

Commit b670b72

Browse files
committed
improve
1 parent 0a2c552 commit b670b72

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

python_docs_theme/layout.html

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ <h3>{{ _('Navigation') }}</h3>
7878
<script type="text/javascript" src="{{ pathto('_static/menu.js', 1) }}"></script>
7979
<script type="text/javascript" src="{{ pathto('_static/search-focus.js', 1) }}"></script>
8080
<script type="text/javascript" src="{{ pathto('_static/themetoggle.js', 1) }}"></script>
81+
<script type="text/javascript" src="{{ pathto('_static/sidebar-resizer.js', 1) }}"></script>
8182
{%- endif -%}
8283
{%- endif -%}
8384
{{ super() }}

python_docs_theme/static/pydoctheme.css

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
@import url('classic.css');
22

3+
/* Smooth scroll */
4+
html {
5+
scroll-behavior: smooth;
6+
}
7+
38
/* Common colours */
49
:root {
510
--good-color: rgb(41 100 51);
@@ -129,6 +134,7 @@ form.inline-search input[type='submit'] {
129134
}
130135

131136
div.document {
137+
animation: fadeIn 0.6s ease-in-out;
132138
display: flex;
133139
/* Don't let long code literals extend beyond the right side of the screen */
134140
overflow-wrap: break-word;
@@ -149,11 +155,7 @@ div.sphinxsidebar {
149155
border-radius: 5px;
150156
line-height: 130%;
151157
font-size: smaller;
152-
width: 300px;
153-
min-width: 200px;
154-
max-width: 500px;
155-
resize: horizontal;
156-
overflow: auto;
158+
transition: width 0.3s ease;
157159
}
158160

159161
div.sphinxsidebar h3,
@@ -162,7 +164,7 @@ div.sphinxsidebar h4 {
162164
}
163165

164166
div.sphinxsidebarwrapper {
165-
width: 300px;
167+
width: 217px;
166168
box-sizing: border-box;
167169
height: 100%;
168170
overflow-x: hidden;
@@ -210,6 +212,9 @@ div.sphinxsidebar input[type='text'] {
210212
width: 12px;
211213
border-radius: 0 5px 5px 0;
212214
border-left: none;
215+
position: absolute;
216+
right: 0;
217+
transition: background-color 0.3s ease, color 0.3s ease;
213218
}
214219

215220
#sidebarbutton span {
@@ -766,3 +771,13 @@ div.versionremoved .versionmodified {
766771
display: none;
767772
}
768773
}
774+
775+
/* Animation */
776+
@keyframes fadeIn {
777+
from {
778+
opacity: 0;
779+
}
780+
to {
781+
opacity: 1;
782+
}
783+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
const sidebar = document.querySelector('.sphinxsidebar');
3+
const resizer = document.createElement('div');
4+
resizer.className = 'sidebar-resizer';
5+
sidebar.appendChild(resizer);
6+
7+
resizer.addEventListener('mousedown', function(e) {
8+
document.addEventListener('mousemove', resizeSidebar);
9+
document.addEventListener('mouseup', stopResize);
10+
});
11+
12+
function resizeSidebar(e) {
13+
const newWidth = e.clientX - sidebar.getBoundingClientRect().left;
14+
if (newWidth > 150 && newWidth < window.innerWidth - 100) {
15+
sidebar.style.width = newWidth + 'px';
16+
}
17+
}
18+
19+
function stopResize() {
20+
document.removeEventListener('mousemove', resizeSidebar);
21+
document.removeEventListener('mouseup', stopResize);
22+
}
23+
});

0 commit comments

Comments
 (0)