feat: improve mobile responsiveness and dark mode UX

Mobile improvements:
- Fix content overflow issues on mobile devices
- Optimize code blocks and tables for small screens
- Add proper word-wrapping and container constraints

Dark mode enhancements:
- Replace icons with modern sun/moon designs
- Implement smooth icon switching with CSS transitions
- Simplify toggle logic for better performance

Resolves mobile layout issues and enhances theme switching experience
This commit is contained in:
Fechin committed 2025-06-21 10:07:49 +08:00
1 parent 0885f971d2
commit 43a3c7100f
8 files changed
+69 -17

No files matched your search

+2 -3
View File
@@ -1,4 +1,3 @@
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M525.65333333 967.11111147h-4.55111146a469.2195552 469.2195552 0 0 1-334.0515552-143.36 476.04622187 476.04622187 0 0 1-11.83288854-637.15555627 461.0275552 461.0275552 0 0 1 182.04444374-124.70044373 45.51111147 45.51111147 0 0 1 48.24177813 10.01244373 45.51111147 45.51111147 0 0 1 10.92266667 45.51111147 382.29333333 382.29333333 0 0 0 88.2915552 400.95288853 385.47911147 385.47911147 0 0 0 401.86311146 88.29155627 45.51111147 45.51111147 0 0 1 57.79911147 58.70933333A462.39288853 462.39288853 0 0 1 857.8844448 830.57777813a467.85422187 467.85422187 0 0 1-332.23111147 136.53333334z"
></path>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M9.528 1.718a.75.75 0 01.162.819A8.97 8.97 0 009 6a9 9 0 009 9 8.97 8.97 0 003.463-.69.75.75 0 01.981.98 10.503 10.503 0 01-9.694 6.46c-5.799 0-10.5-4.701-10.5-10.5 0-4.368 2.667-8.112 6.46-9.694a.75.75 0 01.818.162z"/>
</svg>

Before

Width:  |  Height:  |  Size: 741 B

After

Width:  |  Height:  |  Size: 346 B

+2 -3
View File
@@ -1,4 +1,3 @@
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M512 31.40266667c14.19946667 0 26.935296 8.14830933 31.93787733 20.447232l29.40381867 72.50466133c12.713984 31.30436267-4.456448 66.21320533-38.33856 77.96599467A70.34197333 70.34197333 0 0 1 512 206.16533333c-36.19771733 0-65.536-27.11005867-65.536-60.555264 0-7.25265067 1.41994667-14.46161067 4.17245867-21.25550933l29.425664-72.50466133C485.04285867 39.550976 497.75684267 31.40266667 512 31.40266667z m0 961.19466666c-14.221312 0-26.95714133-8.14830933-31.93787733-20.447232l-29.425664-72.50466133a56.492032 56.492032 0 0 1-4.17245867-21.25550933C446.464 844.96657067 475.80228267 817.83466667 512 817.83466667c7.86432 0 15.64125867 1.31072 23.003136 3.84477866 33.882112 11.75278933 51.052544 46.661632 38.33856 77.98784l-29.40381867 72.482816c-5.00258133 12.29892267-17.73841067 20.447232-31.93787733 20.447232z m480.59733333-480.59733333c0 14.19946667-8.14830933 26.935296-20.447232 31.93787733l-72.50466133 29.40381867c-31.30436267 12.713984-66.21320533-4.456448-77.96599467-38.33856A70.34197333 70.34197333 0 0 1 817.83466667 512c0-36.19771733 27.11005867-65.536 60.555264-65.536 7.25265067 0 14.46161067 1.41994667 21.25550933 4.17245867l72.50466133 29.425664c12.29892267 4.980736 20.447232 17.69472 20.447232 31.93787733zM31.40266667 512c0-14.221312 8.14830933-26.95714133 20.447232-31.93787733l72.50466133-29.425664c6.77205333-2.752512 13.98101333-4.17245867 21.25550933-4.17245867C179.03342933 446.464 206.16533333 475.80228267 206.16533333 512c0 7.86432-1.31072 15.64125867-3.84477866 23.003136-11.75278933 33.882112-46.661632 51.052544-77.98784 38.33856l-72.482816-29.40381867C39.550976 538.935296 31.40266667 526.19946667 31.40266667 512zM172.15214933 172.17399467c10.04885333-10.04885333 24.81629867-13.28196267 37.04968534-8.126464l72.06775466 30.45239466c31.1296 13.172736 43.66882133 49.98212267 28.00571734 82.24768a70.34197333 70.34197333 0 0 1-13.54410667 19.00544c-25.58088533 25.58088533-65.49230933 27.15374933-89.12896 3.49525334a56.492032 56.492032 0 0 1-12.10231467-17.97870934L164.04753067 209.22368c-5.177344-12.23338667-1.94423467-27.000832 8.10461866-37.04968533z m679.673856 679.673856c-10.04885333 10.04885333-24.81629867 13.28196267-37.04968533 8.10461866l-72.04590933-30.45239466a56.492032 56.492032 0 0 1-18.00055467-12.08046934c-23.63665067-23.658496-22.06378667-63.56992 3.51709867-89.15080533a70.34197333 70.34197333 0 0 1 19.00544-13.54410667c32.26555733-15.663104 69.074944-3.12388267 82.24768 28.00571734l30.45239466 72.06775466c5.15549867 12.23338667 1.92238933 26.97898667-8.126464 37.04968534z m0-679.69570134c10.04885333 10.04885333 13.28196267 24.81629867 8.126464 37.04968534l-30.45239466 72.06775466c-13.172736 31.1296-49.98212267 43.66882133-82.24768 28.00571734a70.34197333 70.34197333 0 0 1-19.00544-13.54410667c-25.58088533-25.58088533-27.15374933-65.49230933-3.49525334-89.12896 5.111808-5.15549867 11.206656-9.240576 17.97870934-12.10231467l72.04590933-30.45239466c12.23338667-5.177344 27.000832-1.94423467 37.04968533 8.10461866zM172.15214933 851.82600533c-10.04885333-10.04885333-13.28196267-24.81629867-8.10461866-37.04968533l30.45239466-72.04590933c2.83989333-6.77205333 6.946816-12.86690133 12.08046934-18.00055467 23.658496-23.63665067 63.56992-22.06378667 89.15080533 3.51709867 5.57056 5.57056 10.15808 12.01493333 13.54410667 19.00544 15.663104 32.26555733 3.12388267 69.074944-28.00571734 82.24768l-72.06775466 30.45239466c-12.23338667 5.15549867-26.97898667 1.92238933-37.04968534-8.126464zM512 752.29866667c-132.7104 0-240.29866667-107.58826667-240.29866667-240.29866667s107.58826667-240.29866667 240.29866667-240.29866667 240.29866667 107.58826667 240.29866667 240.29866667-107.58826667 240.29866667-240.29866667 240.29866667z"
></path>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 774 B

+6 -1
View File
@@ -45,9 +45,14 @@
<!-- Dark Mode Toggle -->
<button id="darkMode" class="inline-flex items-center justify-center flex-shrink-0 h-9 w-9 rounded-3xl ml-2 lg:ml-3 backdrop-blur-sm transition-colors duration-200 group <%- is_home() ? "bg-white/10 outline outline-1 outline-white/20 text-white hover:bg-white/20 hover:outline-white/30" : "bg-white outline outline-1 outline-slate-200 dark:bg-slate-800 dark:outline-slate-700 text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-700" %>">
<i class="icon-light <%- is_home() ? "text-white" : "text-slate-600 dark:text-slate-300" %>">
<!-- Sun icon (shown in dark mode) -->
<i class="icon-light transition-all duration-200 <%- is_home() ? "text-white" : "text-slate-600 dark:text-slate-300" %>">
<%- icon("light") %>
</i>
<!-- Moon icon (shown in light mode) -->
<i class="icon-dark transition-all duration-200 <%- is_home() ? "text-white" : "text-slate-600 dark:text-slate-300" %>">
<%- icon("dark") %>
</i>
</button>
<!-- Share Dropdown -->
+1 -1
View File
@@ -25,7 +25,7 @@ if (logoTheme === 'dark') {
%>
<a href="/" class="flex font-medium items-center justify-center md:justify-start text-slate-800 dark:text-slate-300">
<% if (icon) { %>
<div class="justify-center <%= iconColorClass %> mr-3 text-3xl md:text-4xl">
<div class="justify-center <%= iconColorClass %> mr-3 text-4xl">
<div class="self-center">
<%- icon("logo") %>
</div>
+17
View File
@@ -5,6 +5,8 @@ code {
pre {
line-height: 1.5;
word-wrap: break-word;
white-space: pre-wrap;
@apply overflow-hidden overflow-x-auto bg-white p-4;
}
@@ -34,6 +36,21 @@ pre > code.wrap {
@apply whitespace-pre-wrap break-words !important;
}
@media (width <= 768px) {
pre {
@apply text-sm;
max-width: 100%;
overflow-x: auto;
}
pre > code {
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
}
}
.mdLayout .line-highlight {
transform: translate3d(0, 2px, 0);
background: linear-gradient(to right, rgb(20 175 131 / 5%) 25%, transparent);
@@ -1,5 +1,7 @@
.mdLayout table {
width: 100%;
table-layout: fixed;
word-wrap: break-word;
}
.mdLayout .section > table:last-child::after {
@@ -41,6 +43,13 @@
white-space: nowrap;
}
@media (width <= 768px) {
.mdLayout table td:first-child {
white-space: normal;
word-wrap: break-word;
}
}
.mdLayout table td:first-child > code {
@apply text-indigo-600;
}
+32
View File
@@ -39,6 +39,14 @@ html.scrollbar {
@apply mx-auto p-3;
}
@media (max-width: 768px) {
.max-container {
@apply px-4;
max-width: 100%;
overflow-x: hidden;
}
}
.header-button {
@apply inline-flex items-center bg-slate-200 text-slate-600 transition duration-200 rounded-full border-0 p-3 ml-1 font-medium;
@apply hover:bg-slate-300 hover:text-slate-700 hover:shadow-lg;
@@ -86,6 +94,30 @@ html.scrollbar {
@apply flex flex-col space-y-14;
}
@media (max-width: 768px) {
.mdLayout {
overflow-x: hidden;
word-wrap: break-word;
}
}
/* Dark mode toggle icons */
.icon-light {
display: block;
}
.icon-dark {
display: none;
}
.dark .icon-light {
display: none;
}
.dark .icon-dark {
display: block;
}
.mdLayout h3 a.h-anchor, .mdLayout h4 a.h-anchor, .mdLayout h5 a.h-anchor {
@apply hidden;
}
-9
View File
@@ -504,18 +504,9 @@ window.addEventListener('load', () => {
fetchGitHubStars();
// Dark mode functionality
const isDarkMode = document.documentElement.classList.contains('dark');
if (!isDarkMode) {
const icon = document.querySelector('#darkMode > i').classList;
icon.toggle('icon-light');
icon.toggle('icon-dark');
}
document.querySelector('#darkMode').addEventListener('click', () => {
const html = document.documentElement.classList;
html.toggle('dark');
const icon = document.querySelector('#darkMode > i').classList;
icon.toggle('icon-light');
icon.toggle('icon-dark');
const isDarkMode = html.contains('dark');
localStorage.theme = isDarkMode ? 'dark' : '';
});