Skip to content

Commit e6cb7ab

Browse files
authored
Add theme switch and dark theme; fix links and text (#48)
1 parent 1c91266 commit e6cb7ab

File tree

6 files changed

+113
-14
lines changed

6 files changed

+113
-14
lines changed

doc/source/_static/custom.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,35 @@
99
}
1010
.yellow {
1111
color: yellow;
12-
}
12+
}
13+
14+
/* dark theme */
15+
body.dark {
16+
background-color: #2c2c2c;
17+
color: #e0e0e0;
18+
}
19+
20+
body.dark a {
21+
color: #58a6ff;
22+
}
23+
24+
body.dark a:hover {
25+
color: #4a90d9;
26+
}
27+
body.dark p.caption {
28+
color: #f3e5ab;
29+
}
30+
31+
/* You may need to add more styles to override other Alabaster elements */
32+
/* For example: headers, code blocks, navigation menus, etc. */
33+
body.dark h1, body.dark h2, body.dark h3, body.dark h4, body.dark h5, body.dark h6 {
34+
color: #ffffff;
35+
}
36+
37+
body.dark div.body {
38+
background-color: #2c2c2c;
39+
}
40+
41+
body.dark div.body p {
42+
color: #f3e5ab;
43+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
document.addEventListener('DOMContentLoaded', () => {
2+
const themeToggle = document.getElementById('theme-toggle');
3+
if (themeToggle) { // Add this check to prevent errors if the element isn't found
4+
const body = document.body;
5+
6+
// Check for a saved theme preference in local storage
7+
const savedTheme = localStorage.getItem('theme');
8+
if (savedTheme) {
9+
body.classList.add(savedTheme);
10+
} else {
11+
// Fallback to the user's system preference
12+
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
13+
body.classList.add('dark');
14+
} else {
15+
body.classList.add('light');
16+
}
17+
}
18+
19+
// Set the initial state of the toggle button
20+
themeToggle.textContent = body.classList.contains('dark') ? '☀️' : '🌙';
21+
22+
// Add click event listener to the toggle button
23+
themeToggle.addEventListener('click', () => {
24+
if (body.classList.contains('dark')) {
25+
body.classList.remove('dark');
26+
body.classList.add('light');
27+
localStorage.setItem('theme', 'light');
28+
themeToggle.textContent = '🌙';
29+
} else {
30+
body.classList.remove('light');
31+
body.classList.add('dark');
32+
localStorage.setItem('theme', 'dark');
33+
themeToggle.textContent = '☀️';
34+
}
35+
});
36+
}
37+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h3>Theme Switcher</h3>
2+
<p class="theme-toggle-container">
3+
<button id="theme-toggle" class="btn-theme-toggle">
4+
🌙
5+
</button>
6+
</p>

doc/source/conf.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,29 @@
1818
templates_path = ['_templates']
1919
exclude_patterns = []
2020

21-
22-
2321
# -- Options for HTML output -------------------------------------------------
2422
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
2523

2624
html_theme = 'alabaster'
27-
2825
html_static_path = ['_static']
29-
3026
html_logo = "_static/images/logo.jpeg"
27+
28+
# Alabaster theme requires a list of sidebar templates
29+
# This tells Sphinx to include your new HTML file in the sidebar
30+
html_sidebars = {
31+
'**': [
32+
'about.html', # Retains the default Alabaster sidebar
33+
'navigation.html',
34+
'searchbox.html',
35+
'theme_switcher_sidebar.html', # Your new custom sidebar
36+
]
37+
}
38+
39+
# The other options remain the same
40+
html_css_files = [
41+
'custom.css',
42+
]
43+
44+
html_js_files = [
45+
'theme_switcher.js',
46+
]

doc/source/my-friends.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Ali is passionate about technology, mathematics, and empowering others through e
3535

3636
**Social Links**
3737

38-
- 🐙 `GitHub <https://github.com/BaseMax>`_
38+
- 🐙 `GitHub <https://github.com/BaseMax>`__
3939
- 💬 `Telegram <https://t.me/MAX_BASE>`_
4040
- 💼 `LinkedIn <https://www.linkedin.com/in/maxbase>`_
4141
- 📚 `Stack Overflow <https://stackoverflow.com/users/10096230/max-base>`_
@@ -49,7 +49,7 @@ Anuradha
4949

5050
**Links**
5151

52-
- 🐙 `GitHub <https://github.com/anufdo>`_
52+
- 🐙 `GitHub <https://github.com/anufdo>`__
5353
- 💼 `Upwork <https://www.upwork.com/freelancers/~012a7a1cb09da35c41>`_
5454

5555
--------

doc/source/what-i-like-doing.rst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ Dr Martens
3636

3737
* Seeing my friends **Jonah** and **Rue** at the Brisbane `Dr Martens <https://www.drmartens.com.au>`__ shoe store also
3838
on Albert Street almost directly across from Coles. There is another young lady that works there that is really
39-
*sweet* she has helped before and I must get her name next time. ``Dr. Martens (also known as Doc Martens) is a
39+
*sweet* she has helped before and I must get her name next time.
40+
41+
``Dr. Martens (also known as Doc Martens) is a
4042
British footwear and clothing brand known for its iconic, durable, and distinctive air-cushioned boots, distinguished
4143
by yellow stitching and a welted construction. Originally created by a German doctor and his partner for comfortable
4244
post-war footwear, the brand found its cultural home in the UK's counterculture movements, eventually becoming a globally
@@ -49,7 +51,9 @@ Lowes Menswear
4951

5052
* Shopping at `Lowes Menswear <https://www.lowes.com.au/>`__ in Uptown is such a great experience. The two gentleman
5153
that work there have been a tremendous help and are extremely polite and friendly. Most often **Stephen** helps me
52-
find all the best fitting clothes in the store. ``Lowes Menswear, also currently known as Lowes Manhattan Pty Ltd is a
54+
find all the best fitting clothes in the store.
55+
56+
``Lowes Menswear, also currently known as Lowes Manhattan Pty Ltd is a
5357
private, family-owned leading Australian menswear and retail chain established in 1898 by William Lowe. There are now
5458
over 200 stores nationally because of expansion driven by Hans Mueller who established Lowes Manhattan Pty Ltd in
5559
1948.``
@@ -62,7 +66,9 @@ QBD Books
6266
* `QBD Books <https://www.qbd.com.au/>`__ in Uptown is full of great products and they always have discounts and
6367
specials on some products. I have spoken with at least five staff members and at least 4 on multiple occassions. Most
6468
often I see **Sean** working there and he provides excellent service. I do also visit Dymocks bookstore but I much
65-
prefer QBD. ``QBD Books (originally Queensland Book Depot) is Australia's largest specialty book retailer, offering a
69+
prefer QBD.
70+
71+
``QBD Books (originally Queensland Book Depot) is Australia's largest specialty book retailer, offering a
6672
wide range of books in-store and online at discounted prices. Founded in Queensland in the late 1800s, the company is
6773
Australian-owned and operated, with over 80 stores nationwide. They provide a broad selection of genres, new releases,
6874
classics, and children's books, along with loyalty rewards and author events``
@@ -75,7 +81,9 @@ Swatch
7581
* Visiting the Brisbane Queen Street `Swatch <https://www.swatch.com/en-au/>`__ store and talking to my friend **Tim**
7682
the *amazing* and *wonderful* Assistant Manager. Tim is extremely knowledgable about watches and fashion and he is
7783
very helpful. Another staff member **Lachy** works there and seems to know his *Basketball* which impressed me. Lachy
78-
is also a slick knowledgable sales guy. ``A Swatch watch is a Swiss-made, quartz-powered watch characterized by its
84+
is also a slick knowledgable sales guy.
85+
86+
``A Swatch watch is a Swiss-made, quartz-powered watch characterized by its
7987
colorful, artistic designs and affordable, casual, and collectible nature, originally created to revolutionize the
8088
Swiss watch industry with an innovative, mass-produced plastic design. The brand name "Swatch" is a portmanteau of
8189
"Swiss" and "watch" or a contraction of "second watch," and the company's success revitalized the Swiss watch
@@ -106,12 +114,13 @@ Sitar Indian Restaurant Albion
106114
Chermside Shopping Center
107115
^^^^^^^^^^^^^^^^^^^^^^^^^
108116

109-
* Sometimes I go to `Chermside Shopping Center <https://en.wikipedia.org/wiki/Westfield_Chermside>`__ instead of going to the city center but it is much less often. For me
110-
Chermside is further away and takes longer to get to than the city center.
117+
* Sometimes I go to `Chermside Shopping Center <https://en.wikipedia.org/wiki/Westfield_Chermside>`__ instead of going
118+
to the city center but it is much less often. For me Chermside is further away and takes longer to get to than the
119+
city center.
111120

112121
`Chermside Shopping Centre <https://www.westfield.com.au/chermside>`__
113122

114-
* ``officially Westfield Chermside, is a large regional shopping complex in Chermside,
123+
* ``Officially Westfield Chermside, is a large regional shopping complex in Chermside,
115124
Brisbane, Australia, operating as the second-largest Westfield in the country. It houses major department stores like
116125
Myer and David Jones, supermarkets, hundreds of specialty stores, a cinema complex, and a dining and leisure precinct.
117126
It is a major transport hub, with an integrated bus station, and is significant to the retail trade of Brisbane's

0 commit comments

Comments
 (0)