feat: add dark theme and project attribution

This commit is contained in:
2026-12-05 14:52:21 +03:00
parent 7300f13195
commit 61b6034650
5 changed files with 187 additions and 5 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ксения Судакова
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+18 -2
View File
@@ -1,6 +1,14 @@
# Phone Store — Интернет-магазин мобильных телефонов
Полноценное web-приложение на Flask + SQLite для лабораторной работы.
Демонстрационное web-приложение на Flask + SQLite.
> **Важно! Демонстрационный проект.**
> Приложение создано исключительно в учебных и демонстрационных целях.
> Представленные товары, названия моделей, описания, изображения,
> характеристики и цены являются условными демонстрационными данными.
> Они не являются реальными предложениями о продаже, не связаны
> с действующими магазинами и не отражают актуальные рыночные цены.
> Оформление заказа носит исключительно демонстрационный характер.
## Возможности
@@ -82,4 +90,12 @@ phone_store/
## Автор
Учебный проект (лабораторная работа)
**Ксения Судакова**
## Лицензия
Проект распространяется на условиях лицензии [MIT](LICENSE).
Разрешается свободно использовать, копировать, изменять и распространять
проект, в том числе в коммерческих целях, при сохранении уведомления
об авторских правах и текста лицензии.
+88
View File
@@ -912,3 +912,91 @@ body {
grid-template-columns: 1fr;
}
}
/* ===== Light and dark themes ===== */
.theme-toggle {
width: 40px;
height: 40px;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
border: 1px solid var(--border);
border-radius: 50%;
background: var(--card-bg);
color: var(--text);
font-size: 22px;
cursor: pointer;
transition: background var(--transition), color var(--transition),
border-color var(--transition), transform var(--transition);
}
.theme-toggle:hover {
border-color: var(--accent);
color: var(--accent);
transform: rotate(12deg);
}
:root[data-theme="dark"] {
color-scheme: dark;
--primary: #172b45;
--primary-dark: #0f1f33;
--accent: #60a5fa;
--accent-hover: #3b82f6;
--bg: #111827;
--card-bg: #1f2937;
--text: #e5e7eb;
--text-muted: #9ca3af;
--border: #374151;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25),
0 2px 4px -2px rgba(0, 0, 0, 0.2);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3),
0 4px 6px -4px rgba(0, 0, 0, 0.25);
}
:root[data-theme="dark"] .filter-select,
:root[data-theme="dark"] .qty-btn,
:root[data-theme="dark"] .search-input,
:root[data-theme="dark"] .form-group input,
:root[data-theme="dark"] .form-group textarea {
background: #111827;
color: var(--text);
border-color: var(--border);
}
:root[data-theme="dark"] .product-image-link,
:root[data-theme="dark"] .product-detail-image,
:root[data-theme="dark"] .cart-item-image {
background: #273449;
}
:root[data-theme="dark"] .product-price,
:root[data-theme="dark"] .product-price-large,
:root[data-theme="dark"] .total-price {
color: #93c5fd;
}
:root[data-theme="dark"] .flash-success {
background: #123528;
color: #a7f3d0;
border-color: #166534;
}
:root[data-theme="dark"] .flash-error {
background: #3b1d24;
color: #fecaca;
border-color: #7f1d1d;
}
:root[data-theme="dark"] .flash-info {
background: #172d4a;
color: #bfdbfe;
border-color: #1e40af;
}
@media (prefers-reduced-motion: reduce) {
.theme-toggle {
transition: none;
}
}
+36
View File
@@ -4,6 +4,42 @@
*/
document.addEventListener('DOMContentLoaded', function () {
// Переключение светлой и тёмной темы
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = themeToggle?.querySelector('.theme-icon');
function applyTheme(theme) {
document.documentElement.dataset.theme = theme;
if (themeIcon) {
themeIcon.textContent = theme === 'dark' ? '☀' : '☾';
}
if (themeToggle) {
const label = theme === 'dark'
? 'Переключить на светлую тему'
: 'Переключить на тёмную тему';
themeToggle.setAttribute('aria-label', label);
themeToggle.setAttribute('title', label);
}
}
applyTheme(document.documentElement.dataset.theme || 'light');
themeToggle?.addEventListener('click', function () {
const nextTheme =
document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
applyTheme(nextTheme);
try {
localStorage.setItem('phone-store-theme', nextTheme);
} catch (error) {
// Тема останется активной до перезагрузки страницы.
}
});
// Автоматическое скрытие flash-сообщений через 4 секунды
const flashes = document.querySelectorAll('.flash');
flashes.forEach(function (flash) {
+24 -3
View File
@@ -4,6 +4,18 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Phone Store{% endblock %} — Интернет-магазин смартфонов</title>
<script>
(function () {
try {
const savedTheme = localStorage.getItem('phone-store-theme');
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
document.documentElement.dataset.theme =
savedTheme || (systemDark ? 'dark' : 'light');
} catch (error) {
document.documentElement.dataset.theme = 'light';
}
})();
</script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -26,6 +38,15 @@
<span class="cart-badge" id="cart-badge">{{ cart_count }}</span>
{% endif %}
</a>
<button
class="theme-toggle"
id="theme-toggle"
type="button"
aria-label="Переключить тему"
title="Переключить тему"
>
<span class="theme-icon" aria-hidden="true">☾</span>
</button>
</nav>
</div>
</header>
@@ -55,11 +76,11 @@
<div class="footer-content">
<div class="footer-brand">
<span class="logo-text">Phone<span class="logo-accent">Store</span></span>
<p>Ваш надёжный магазин смартфонов</p>
<p>Демонстрационный проект интернет-магазина</p>
</div>
<div class="footer-info">
<p>© 2024 Phone Store. Учебный проект.</p>
<p>Все цены указаны в рублях.</p>
<p>© 2026 Ксения Судакова. Лицензия MIT.</p>
<p>Товары и цены приведены только для демонстрации.</p>
</div>
</div>
</div>