Skip to content

Commit 339aed8

Browse files
committed
add a auto-detected dark-style
1 parent de64e61 commit 339aed8

File tree

5 files changed

+255
-18
lines changed

5 files changed

+255
-18
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,49 @@ This book is designed for Persian-speaking learners without prior experience wit
3333

3434
To get started with this book, you can:
3535

36-
- Simply visit [PythonPersian.com](https://pythonpersian.com/) and start reading.
36+
- Simply visit [PythonPersian.com](https://pythonpersian.com/) and start reading.
3737

3838
- Download the source code from GitHub and run it on your local machine:
3939

4040
```
4141
$ git clone https://github.com/saeiddrv/PythonPersianTutorial.git
42-
42+
43+
$ cd PythonPersianTutorial
44+
4345
$ pip install -U pip
4446
$ pip install virtualenv
4547
$ python -m virtualenv .venv
4648
$ source .venv/bin/activate
47-
48-
$ cd PythonPersianTutorial
49+
4950
$ pip install -r requirements.txt
50-
51+
5152
$ make html
52-
53+
5354
$ cd ./build/html
5455
$ python -m http.server 8000
5556
```
5657
then visit http://127.0.0.1:8000
57-
58+
5859
- Download the source code from GitHub and run it in Docker:
59-
60+
6061
```
6162
$ git clone https://github.com/saeiddrv/PythonPersianTutorial.git
62-
63+
6364
$ cd PythonPersianTutorial
64-
65+
6566
$ docker build -t pypersian .
6667
$ docker run -d --name pypersian -p 80:8000 pypersian
6768
```
6869
then visit http://127.0.0.1
69-
70+
7071

7172
## Contributions
7273

7374
If you'd like to contribute to the book, you can fork the repository on GitHub and submit a pull request with your changes. You can also open an issue to **report errors**.
7475

7576
## Credits
7677

77-
This book was authored by [**Saeid Darvish**](https://saeiddrv.com).
78+
This book was authored by [**Saeid Darvishghazvini**](https://saeiddrv.com).
7879

7980
## License
8081

@@ -83,4 +84,3 @@ This book is licensed under the Creative Commons Attribution-NonCommercial-Share
8384
## Acknowledgments
8485

8586
Special thanks to the Python community and the contributors of open-source Python packages and libraries, without whom this book would not have been possible.
86-

source/_templates/sphinx_minoo_theme/includes/header.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
{% if theme_direction == "ltr" %}
3939
<link rel="stylesheet" type=text/css href="{{ pathto('_static/minoo-ltr.css', 1) }}">
4040
{% else %}
41-
<link rel="stylesheet" type=text/css href="{{ pathto('_static/minoo-20240224.css', 1) }}">
41+
<link rel="stylesheet" type="text/css" href="{{ pathto('_static/minoo-20240224.css', 1) }}">
4242
{% endif %}
4343

44+
<link id="dark-style" rel="stylesheet" type="text/css" href="{{ pathto('_static/minoo-dark.css', 1) }}" disabled>
45+
4446
{%- block linktags %}
4547
{%- if hasdoc('about') %}
4648
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
@@ -99,3 +101,15 @@
99101
<script type="text/javascript" src="{{ pathto('_static/modernizr.min.js', 1) }}"></script>
100102

101103
<script async defer src="https://buttons.github.io/buttons.js"></script>
104+
105+
<script>
106+
const darkThemeLink = document.getElementById('dark-style');
107+
function applySystemThemePreference() {
108+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
109+
darkThemeLink.disabled = !prefersDark;
110+
}
111+
// Initial check
112+
applySystemThemePreference();
113+
// Listen for changes to system theme
114+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applySystemThemePreference);
115+
</script>

source/_templates/sphinx_minoo_theme/includes/top.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<a><i class="fa fa-folder-open-o"></i>&nbsp; {{ title }}</a>
1111
{% else %}
1212
<a><i class="fa fa-folder-o"></i>&nbsp; {{glossary.root_page}}</a>
13-
<a href="https://coderz.club/python" class="top-src" target="_blank"><i class="fa fa-map-marker"></i>&nbsp; در کدرز</a>
1413
{% endif %}
1514
{% if pagename != "search" %}
1615
{% if display_github %}
@@ -38,7 +37,7 @@
3837
<i class="fa fa-gift" aria-hidden="true"></i> حمایت مالی
3938
</a>
4039
</div>
41-
40+
4241

4342

4443
<div class="top-links" style="direction: ltr;float: right;">
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/* Base Layout */
2+
body {
3+
background-color: #121212;
4+
color: #e0e0e0;
5+
}
6+
7+
a, ul>li>a, ol>li>a {
8+
color: #81D4FA;
9+
}
10+
a:hover, ul>li>a:hover, ol>li>a:hover {
11+
color: #66BB6A;
12+
}
13+
14+
/* Headers */
15+
h1, h2, h3, h4, h5, h6 {
16+
color: #ffffff;
17+
}
18+
h1 {
19+
background-color: #303F9F;
20+
border-color: #1A237E;
21+
}
22+
h2, h3 {
23+
background-color: #1A237E;
24+
border-color: #303F9F !important;
25+
}
26+
27+
/* Tables and Lines */
28+
thead, caption {
29+
background-color: #1A237E;
30+
color: #ffffff;
31+
}
32+
hr {
33+
border-top: 1px solid #333;
34+
}
35+
.table-striped > tbody > tr:nth-of-type(odd),
36+
tr.row-even {
37+
background-color: #1E1E1E;
38+
}
39+
.table-bordered th, .table-bordered td {
40+
border-color: #424242;
41+
}
42+
43+
/* Code Blocks */
44+
code, kbd, pre, samp {
45+
background-color: #1E1E1E;
46+
color: #ECEFF1;
47+
}
48+
.linenodiv pre {
49+
background-color: #303F9F;
50+
color: #ECEFF1;
51+
}
52+
53+
/* Highlighting */
54+
.highlighted {
55+
background-color: #FBC02D;
56+
color: #212121;
57+
}
58+
59+
/* Sidebar and Navigation */
60+
#page-sidebar,
61+
#sidebar-top,
62+
#wrapper-page-sidebar,
63+
#wrapper-sidebar-bottom,
64+
#sidebar-bottom,
65+
#sidebar-bottom-versions {
66+
background-color: #263238;
67+
color: #ffffff;
68+
}
69+
#sidebar-top-title a,
70+
#sidebar-top-links a {
71+
color: #B3E5FC;
72+
}
73+
#sidebar-top-title a:hover,
74+
#sidebar-top-links a:hover {
75+
color: #80CBC4;
76+
}
77+
#navigation-toggle {
78+
background-color: #263238;
79+
}
80+
#input-search {
81+
color: #e0e0e0;
82+
box-shadow: inset 0 -1px 0 #80CBC4;
83+
}
84+
85+
/* Top and Footer */
86+
#body-top {
87+
color: #90CAF9;
88+
border-bottom-color: #333;
89+
}
90+
#body-btn a {
91+
background-color: #303F9F;
92+
}
93+
#body-btn a:hover {
94+
background-color: #66BB6A;
95+
}
96+
#body-footer {
97+
background-color: #1A237E;
98+
color: #e0e0e0;
99+
}
100+
101+
/* Back to Top */
102+
.back-to-top {
103+
color: #90CAF9;
104+
}
105+
106+
/* Sidebar Block */
107+
.sidebar {
108+
background-color: #263238;
109+
border-color: #37474F;
110+
}
111+
.sidebar .sidebar-title {
112+
background-color: #303F9F;
113+
}
114+
115+
/* Contents Tree Navigation */
116+
.contents.topic li > a,
117+
.toctree-wrapper li > a {
118+
background-color: #37474F;
119+
color: #ffffff;
120+
}
121+
.contents.topic li > a:hover,
122+
.toctree-wrapper li > a:hover {
123+
background-color: #546E7A;
124+
}
125+
.contents.topic li > ul > li > a,
126+
.toctree-wrapper li > ul > li > a {
127+
background-color: #455A64;
128+
color: #ffffff;
129+
}
130+
.contents.topic li > ul > li > a:hover,
131+
.toctree-wrapper li > ul > li > a:hover {
132+
background-color: #546E7A;
133+
}
134+
135+
/* Selection */
136+
::selection {
137+
background-color: #3949AB;
138+
color: #FAFAFA;
139+
}
140+
141+
/* === Admonitions (Dark Theme Adjusted) === */
142+
.admonition {
143+
background-color: #263238;
144+
color: #e0e0e0;
145+
}
146+
.admonition .admonition-title {
147+
color: #ffffff;
148+
}
149+
150+
/* NOTE & ATTENTION */
151+
.admonition.note,
152+
.admonition.attention {
153+
background-color: #263238;
154+
}
155+
.admonition.note .admonition-title,
156+
.admonition.attention .admonition-title {
157+
background-color: #42A5F5;
158+
}
159+
160+
/* TIP & IMPORTANT */
161+
.admonition.tip,
162+
.admonition.important {
163+
background-color: #263238;
164+
}
165+
.admonition.tip .admonition-title,
166+
.admonition.important .admonition-title {
167+
background-color: #26A69A;
168+
}
169+
170+
/* HINT & WARNING */
171+
.admonition.hint,
172+
.admonition.warning {
173+
background-color: #263238;
174+
}
175+
.admonition.hint .admonition-title,
176+
.admonition.warning .admonition-title {
177+
background-color: #F57C00;
178+
}
179+
180+
/* ERROR & DANGER */
181+
.admonition.error,
182+
.admonition.danger {
183+
background-color: #263238;
184+
}
185+
.admonition.error .admonition-title,
186+
.admonition.danger .admonition-title {
187+
background-color: #E53935;
188+
}
189+
190+
/* CAUTION */
191+
.admonition.caution {
192+
background-color: #263238;
193+
}
194+
.admonition.caution .admonition-title {
195+
background-color: #C0CA33;
196+
}
197+
198+
/* Generic fallback */
199+
.admonition:not(
200+
.note,
201+
.attention,
202+
.tip,
203+
.important,
204+
.hint,
205+
.warning,
206+
.error,
207+
.danger,
208+
.caution
209+
) {
210+
background-color: #37474F;
211+
}
212+
.admonition:not(
213+
.note,
214+
.attention,
215+
.tip,
216+
.important,
217+
.hint,
218+
.warning,
219+
.error,
220+
.danger,
221+
.caution
222+
) .admonition-title {
223+
background-color: #78909C;
224+
}

source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

99
project = 'پایتون به پارسی'
10-
copyright = '2015, Saeid Darvish'
11-
author = 'Saeid Darvish'
10+
copyright = '2015, Saeid Darvishghazvini'
11+
author = 'Saeid Darvishghazvini'
1212

1313
# -- General configuration ---------------------------------------------------
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

0 commit comments

Comments
 (0)